Menu

#76 Build fails with LTO

v1.0 (example)
open
nobody
None
5
2024-04-11
2024-04-11
No

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:

/bin/sh ./libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -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 -Wall -W -Wno-sign-compare -D_REENTRANT -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/fuse -D_FILE_OFFSET_BITS=64   -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o curlftpfs ftpfs.o libcurlftpfs.a -lglib-2.0 -lfuse -pthread -lcurl
libtool: link: x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -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 -Wall -W -Wno-sign-compare -D_REENTRANT -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/fuse -D_FILE_OFFSET_BITS=64 -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o curlftpfs ftpfs.o  -Wl,--as-needed libcurlftpfs.a -lglib-2.0 -lfuse -lcurl -pthread
ftpfs-ls.c:33:21: error: type of 'cache' does not match original declaration [-Werror=lto-type-mismatch]
   33 | extern struct cache cache;
      |                     ^
cache.c:28:14: note: 'cache' was previously declared here
   28 | struct cache cache;
      |              ^
cache.c:28:14: 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
make[2]: *** [Makefile:511: curlftpfs] Error 1

Originally reported downstream: https://bugs.gentoo.org/861299
Full build log is attached.

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB