Largefile support

When building 32 bit apps for 64 bit files.

getconf LFS_CFLAGS return

-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

When building, I get an error

"ptvalidate.cc", line 1414: Error: O_LARGEFILE is not defined.

This is defined within

#ifdef __USE_LARGEFILE64

# define O_LARGEFILE0100000

#endif

So I am uncertain how gcc was doing this, but it was.

[403 byte] By [Brett_Tiplitza] at [2007-11-27 0:35:55]
# 1
A way to use largefile64 is to specify -D_LARGEFILE64_SOURCE:] getconf LFS64_CFLAGS-D_LARGEFILE64_SOURCE]regards,__Fedor.
SFVa at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Problem is that it's not following the standard. We run getconf and that specifies the flags the architecture wants. I think this needs to work unaltered.
Brett_Tiplitza at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
Indeed, you should probably report it to the glibc maintainers then: they provide getconf, and they provide headers that require other macros, everything is in their control.
Marc_Glissea at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
> Problem is that it's not following the standard.Which standard do you believe it is not following?
SFVa at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
Been told even by Sun to use getconf.And the code works in Linux, so when trying to break into a market, you can not just change it. Why does gcc work just fine?
Brett_Tiplitza at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6

32-bit programs on Solaris do not provide large-file support by default. If you need large file support in a 32-bit program, you must ask for it.

Large file support is expensive in a 32-bit program, so you pay for it only if you need it. This decision reflects the situation in earlier days. Solaris provides continued binary compatibility from Solaris 2.x in the early 1990's right up to Solaris Express in 2007. Since large-file support requires different data types for referencing files, changing the default to support large files would break programs using old binaries.

clamage45a at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7
Not talking about getting what I did not ask for. I pass `getconf LFS_CFLAGS` to the build and this should work. It does not work for only this compiler.
Brett_Tiplitza at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 8

> I pass `getconf LFS_CFLAGS` to the build and this should work

I have already shown you that largfile64 (note 64!) is yet another part of largfile support and getconf has a different configuration variable for it.

As for "Why does gcc work just fine?" - glibc headers are *mostly* written with gcc in mind only.

There were problems that we had to resolve by interposing those headers and fixing mismatches in macroses (which work with gcc just because it defines GNU_SOURCE).

Btw, tried the following test on all my Linuxes (SuSE/Red Hat 32/64 bit) and all fail the same:

] cat lf.c

#include <fcntl.h>

void foo() {

open("", O_LARGEFILE);

}

] gcc lf.c `getconf LFS_CFLAGS`

lf.c: In function `foo':

lf.c:4: error: `O_LARGEFILE' undeclared (first use in this function)

lf.c:4: error: (Each undeclared identifier is reported only once

lf.c:4: error: for each function it appears in.)

]

SFVa at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 9
Yeah, and it passes with gcc lf.c `getconf LFS64_CFLAGS`
SFVa at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 10

I think I agree that the compiler is doing the correct action. I have not been able to determine why this works on Solaris and gcc right now as it does, but it appears that there is mixing between the transition environment and the normal large file mode. It seems that this flag should only be used in mode when calls will manually be made to lseek64, etc.

Would this be a correct assesment?

Brett_Tiplitza at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 11

No.

You do not need to do anything special in your source code to get large file support in a 32-bit program on Solaris. Simply add the largefile macro definitions to the cc and CC command lines, and the system takes care of everything for you. When these macros are defined, all usages of the 32-bit file types and functions are automatically redirected to the 64-bit versions.

On Soalris, run

man largefile

and

man lfcompile

for details.

A 64-bit Solaris program automatically has largefile support.

clamage45a at 2007-7-11 22:44:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...