Menu

#23 Build fails with LTO

open
nobody
None
5
2024-04-07
2024-04-07
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:

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 -Wl,--export-dynamic -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o xoscope xoscope.o xoscope_gtk.o file.o func.o display.o  alsa.o fft.o -lgtk-3 -lgdk-3 -lharfbuzz -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo -lcairo-gobject -lgdk_pixbuf-2.0 -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lgtkdatabox -lgtk-3 -lgdk-3 -lharfbuzz -lpangocairo-1.0 -latk-1.0 -lcairo-gobject -lgdk_pixbuf-2.0 -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lpango-1.0 -lcairo -lasound -lfftw3 -lm 
file.h:11:6: error: type of handle_opt does not match original declaration [-Werror=lto-type-mismatch]
   11 | void handle_opt(char opt, char *optarg);
      |      ^
file.c:38:6: note: type mismatch in parameter 1
   38 | void handle_opt(int opt, char *optarg)
      |      ^
file.c:38:6: note: type int should match type char
file.c:38:6: note: handle_opt was previously declared here
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[1]: *** [Makefile:485: xoscope] Error 1

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

1 Attachments

Discussion


Log in to post a comment.