Build issue in tests when LTO enabled
Hey there,
The issue is impacting Debian and Ubuntu, it has been reported on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015432 which includes the build log; https://wiki.debian.org/ToolChain/LTO has details on how LTO is being enabled in Debian, but basically 'Enabling LTO adds the flags -flto=auto -ffat-lto-objects to CFLAGS, CXXFLAGS, OBJCFLAGS ... and the flag -flto=auto to LDFLAGS'
the build is errors out on
/bin/bash ./libtool --tag=CC --mode=link gcc -fvisibility=hidden -DUNITDIR=\""./unit/"\" -DCERTDIR=\""./unit/"\" -DJSMN_PARENT_LINKS -DJSMN_STRICT -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -o unit/test-util src/util.o src/band.o unit/test-util.o -lell /usr/bin/ld: /tmp/cckxZfEz.ltrans0.ltrans.o: in function `sae_choose_next_group':./src/sae.c:144: undefined reference to `__wrap_l_ecc_supported_ike_groups'/usr/bin/ld: /tmp/cckxZfEz.ltrans0.ltrans.o: in function `sae_rx_authenticate':./src/sae.c:186: undefined reference to `__wrap_l_ecc_supported_ike_groups'/usr/bin/ld: /tmp/cckxZfEz.ltrans0.ltrans.o: in function `handshake_state_free':./src/handshake.c:49: undefined reference to `__wrap_l_ecc_supported_ike_groups'/usr/bin/ld: /tmp/cckxZfEz.ltrans0.ltrans.o:./src/handshake.c:49: undefined reference to `__wrap_l_ecc_supported_ike_groups'
collect2: error: ld returned 1 exit status
That's still a problem with 1.30
Cheers,
Sebastien Bacher
Hi Sebastien,
Quoted 6 lines · Sebastien Bacher
Hey there,
The issue is impacting Debian and Ubuntu, it has been reported on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015432 which includes the build log; https://wiki.debian.org/ToolChain/LTO has details on how LTO is being enabled in Debian, but basically 'Enabling LTO adds the flags -flto=auto -ffat-lto-objects to CFLAGS, CXXFLAGS, OBJCFLAGS ... and the flag -flto=auto to
LDFLAGS'
I think this came up before. The issue is that we need to override certain implementation details to force certain behavior in unit tests. The easiest way for us to accomplish this is to use -Wl,--wrap on a particular function. For example, test-sae uses this to override l_ecc_supported_ike_groups() implementation to force the use of 256 bit ECC keys by default. Ell unit tests do something similar for l_getrandom to force generating of known random numbers.
Quoted 2 lines
the build is errors out on
Problem is, -Wl,--wrap seems to not work with LTO:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88643
So I'm not sure what can be done about this. One idea might be to not compile unit tests unless in maintainer-mode or disable unit tests at configure time. If you wish to run the unit tests (for build checks, sanity checks, etc) then you could compile the package without LTO first.
Regards,
-Denis