Comment 11 for bug 2000009

Revision history for this message
Michael Pujos (bobbie424242) wrote (last edit ):

After much trial and error comparing build log of last working and failing builds, I finally found the cause of this problem.

The maintainer of the sbcl package (which I'm not) recently modified the build (RPM spec file), adding -D_GNU_SOURCE to CFLAGS, exported for use by all gcc invocations. With this comment:

"Inject -D_GNU_SOURCE to CFLAGS: fixes Fixes build issue due to O_LARGEFILE hiding behind feature test macro."

Which can be seen on line 136:
https://build.opensuse.org/package/view_file/openSUSE:Factory/sbcl/sbcl.spec?expand=1

This was done, because otherwise the build (both i586 and x86_64) would now fail on this error:

[ 39s] make: Entering directory '/home/abuild/rpmbuild/BUILD/sbcl-2.2.10/tools-for-build'
[ 39s] cc -I../src/runtime -fomit-frame-pointer -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto grovel-headers.c -o grovel-headers
[ 39s] grovel-headers.c: In function 'main':
[ 39s] grovel-headers.c:228:32: error: 'O_LARGEFILE' undeclared (first use in this function)
[ 39s] 228 | defconstant("o_largefile", O_LARGEFILE);
[ 39s] | ^~~~~~~~~~~
[ 39s] grovel-headers.c:228:32: note: each undeclared identifier is reported only once for each function it appears in
[ 39s] make: *** [<builtin>: grovel-headers] Error 1

Note that this error was new, as compiler, gcc and build tools and other packages are an ever moving target in openSUSE TW.

So adding -D_GNU_SOURCE to CFLAGS made the build work on x86_64, but produced a broken sbcl binary on i586.

The proper workaround for the build to pass the compile error above is instead to add "-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" to CFLAGS, which after some man reading, Googling and various failed attempts, I took from src/runtime/Config.x86-linux.
Maybe a change to the build system in SBCL could be done so this is not necessary.

I hadn't initially paid much attention to this -D_GNU_SOURCE addition, as I did not know what it did and thought it to be benign, until I read about it.