Build fails with LTO
Network transparent, client/server audio transport system
Brought to you by:
jon13
I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Note the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.
I got this error:
x86_64-pc-linux-gnu-gcc -o nasd -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -L../lib/audio -L/usr/lib64 -L/usr/lib64 dia/libdia.a dda/voxware/libvoxware.a os/libos.a -lfl
os/WaitFor.c:279:32: error: type of ‘AuEventQueue’ does not match original declaration [-Werror=lto-type-mismatch]
279 | extern pointer AuEventQueue;
| ^
dia/auevents.c:53:15: note: type ‘struct _EventQueueRec *’ should match type ‘unsigned char *’
53 | EventQueuePtr AuEventQueue;
| ^
dia/auevents.c:53:15: note: ‘AuEventQueue’ was previously declared here
dia/auevents.c:53:15: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
gmake[1]: *** [Makefile:1102: nasd] Error 1
Downstream report: https://bugs.gentoo.org/859934
Full build log is attached.
Also while testing this with
make -kI got a highly confusing error because somehow make succeeded instead of failing??? Even though a rule failed to compile.As a result my build script continued on to the install phase and compiled the failing program without any CFLAGS or LDFLAGS, which "worked" but should not have. It would be ideal if CFLAGS / LDFLAGS defined when the build is configured would persist across invocations... GNU autotools or meson would both do so. (imake is deprecated; xorg uses meson now.)