Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with LTO #128

Open
eli-schwartz opened this issue Aug 5, 2024 · 1 comment · May be fixed by #129
Open

Build fails with LTO #128

eli-schwartz opened this issue Aug 5, 2024 · 1 comment · May be fixed by #129

Comments

@eli-schwartz
Copy link

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:

make[2]: Entering directory '/var/tmp/portage/net-dialup/freeradius-client-1.1.7-r3/work/freeradius-client-1.1.7/lib'
/bin/sh ../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=3 -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 -version-info 2:0:0 -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=3 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o libfreeradius-client.la -rpath /usr/lib64 buildreq.lo clientid.lo env.lo sendserver.lo avpair.lo config.lo dict.lo ip_util.lo log.lo util.lo rc-md5.lo md5.lo  -lcrypt -lnsl 
libtool: link: x86_64-pc-linux-gnu-gcc -shared  -fPIC -DPIC  .libs/buildreq.o .libs/clientid.o .libs/env.o .libs/sendserver.o .libs/avpair.o .libs/config.o .libs/dict.o .libs/ip_util.o .libs/log.o .libs/util.o .libs/rc-md5.o .libs/md5.o   -Wl,--as-needed -lcrypt -lnsl  -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=3 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 -Wl,-z -Wl,pack-relative-relocs -flto=3 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0   -Wl,-soname -Wl,libfreeradius-client.so.2 -o .libs/libfreeradius-client.so.2.0.0
../include/freeradius-client.h:524:6: error: type of 'rc_md5_calc' does not match original declaration [-Werror=lto-type-mismatch]
  524 | void rc_md5_calc(unsigned char *, unsigned char const *, unsigned int);
      |      ^
rc-md5.c:15:6: note: type mismatch in parameter 3
   15 | void rc_md5_calc(unsigned char *output, unsigned char const *input,
      |      ^
rc-md5.c:15:6: note: type 'size_t' should match type 'unsigned int'
rc-md5.c:15:6: note: 'rc_md5_calc' was previously declared here
rc-md5.c:15:6: 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/libexec/gcc/x86_64-pc-linux-gnu/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:444: libfreeradius-client.la] Error 1
make[2]: Leaving directory '/var/tmp/portage/net-dialup/freeradius-client-1.1.7-r3/work/freeradius-client-1.1.7/lib'
make[1]: *** [Makefile:427: all-recursive] Error 1
make: *** [Makefile:359: all] Error 2

Originally reported downstream: https://bugs.gentoo.org/927175
Full build log: build.log

Indeed, if we look at the current versions of the affected code, we see they are untruthful and disagree with each other:

void rc_md5_calc(unsigned char *output, unsigned char const *input,
size_t inlen)

void rc_md5_calc(unsigned char *, unsigned char const *, unsigned int);

@alandekok
Copy link
Member

This is Open Source. Patches are appreciated.

@DimitriPapadopoulos DimitriPapadopoulos linked a pull request Aug 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants