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.
# 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.
# 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.
# 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 >

# 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?
# 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.