jasper-software / xv

XV Software
Other
26 stars 9 forks source link

Build fails with LTO #25

Closed eli-schwartz closed 3 months ago

eli-schwartz commented 3 months ago

I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Link-Time Optimization is a massively global compiler optimization pass which is pretty handy for producing faster executables. It also has the interesting property that because the compiler does whole-program analysis using bytecode, it can save type information and perform error checks that it normally doesn’t have enough insight for. In particular, checking for ODR issues and checking function type signature mismatches.

Note that all 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:

FAILED: src/xv 
: && /usr/sbin/cc -pipe -march=native -fstack-protector-all -O2 -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 -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 src/CMakeFiles/xv.dir/vprintf.c.o src/CMakeFiles/xv.dir/xv24to8.c.o src/CMakeFiles/xv.dir/xvalg.c.o src/CMakeFiles/xv.dir/xvbmp.c.o src/CMakeFiles/xv.dir/xvbrowse.c.o src/CMakeFiles/xv.dir/xvbutt.c.o src/CMakeFiles/xv.dir/xv.c.o src/CMakeFiles/xv.dir/xvcolor.c.o src/CMakeFiles/xv.dir/xvcpmask.c.o src/CMakeFiles/xv.dir/xvctrl.c.o src/CMakeFiles/xv.dir/xvcut.c.o src/CMakeFiles/xv.dir/xvdflt.c.o src/CMakeFiles/xv.dir/xvdial.c.o src/CMakeFiles/xv.dir/xvdir.c.o src/CMakeFiles/xv.dir/xvevent.c.o src/CMakeFiles/xv.dir/xvfits.c.o src/CMakeFiles/xv.dir/xvgam.c.o src/CMakeFiles/xv.dir/xvgif.c.o src/CMakeFiles/xv.dir/xvgifwr.c.o src/CMakeFiles/xv.dir/xvgrab.c.o src/CMakeFiles/xv.dir/xvgraf.c.o src/CMakeFiles/xv.dir/xvhips.c.o src/CMakeFiles/xv.dir/xviff.c.o src/CMakeFiles/xv.dir/xvimage.c.o src/CMakeFiles/xv.dir/xvinfo.c.o src/CMakeFiles/xv.dir/xviris.c.o src/CMakeFiles/xv.dir/xvjp2k.c.o src/CMakeFiles/xv.dir/xvjpeg.c.o src/CMakeFiles/xv.dir/xvmag.c.o src/CMakeFiles/xv.dir/xvmaki.c.o src/CMakeFiles/xv.dir/xvmask.c.o src/CMakeFiles/xv.dir/xvmeko.c.o src/CMakeFiles/xv.dir/xvmgcsfx.c.o src/CMakeFiles/xv.dir/xvmisc.c.o src/CMakeFiles/xv.dir/xvml.c.o src/CMakeFiles/xv.dir/xvpbm.c.o src/CMakeFiles/xv.dir/xvpcd.c.o src/CMakeFiles/xv.dir/xvpcx.c.o src/CMakeFiles/xv.dir/xvpds.c.o src/CMakeFiles/xv.dir/xvpi.c.o src/CMakeFiles/xv.dir/xvpic2.c.o src/CMakeFiles/xv.dir/xvpic.c.o src/CMakeFiles/xv.dir/xvpm.c.o src/CMakeFiles/xv.dir/xvpng.c.o src/CMakeFiles/xv.dir/xvpopup.c.o src/CMakeFiles/xv.dir/xvps.c.o src/CMakeFiles/xv.dir/xvrle.c.o src/CMakeFiles/xv.dir/xvroot.c.o src/CMakeFiles/xv.dir/xvscrl.c.o src/CMakeFiles/xv.dir/xvsmooth.c.o src/CMakeFiles/xv.dir/xvsunras.c.o src/CMakeFiles/xv.dir/xvtarga.c.o src/CMakeFiles/xv.dir/xvtext.c.o src/CMakeFiles/xv.dir/xvtiff.c.o src/CMakeFiles/xv.dir/xvtiffwr.c.o src/CMakeFiles/xv.dir/xvvd.c.o src/CMakeFiles/xv.dir/xvwbmp.c.o src/CMakeFiles/xv.dir/xvwebp.c.o src/CMakeFiles/xv.dir/xvxbm.c.o src/CMakeFiles/xv.dir/xvxpm.c.o src/CMakeFiles/xv.dir/xvxwd.c.o src/CMakeFiles/xv.dir/xvzx.c.o -o src/xv  /usr/lib64/libX11.so  /usr/lib64/libXt.so  -lm  /usr/lib64/libpng.so  /usr/lib64/libjpeg.so  /usr/lib64/libX11.so  /usr/lib64/libICE.so  /usr/lib64/libSM.so  /usr/lib64/libz.so && :
/tmp/xv/src/xv.h:1318:21: error: type of ‘initdir’ does not match original declaration [-Werror=lto-type-mismatch]
 1318 | WHERE char          initdir[MAXPATHLEN];   /* cwd when xv was started */
      |                     ^
/tmp/xv/src/xv.h:1318:21: note: array types have different bounds
 1318 | WHERE char          initdir[MAXPATHLEN];   /* cwd when xv was started */
      |                     ^
/tmp/xv/src/xv.h:1318:21: note: ‘initdir’ was previously declared here
/tmp/xv/src/xv.h:1319:21: error: type of ‘searchdir’ does not match original declaration [-Werror=lto-type-mismatch]
 1319 | WHERE char          searchdir[MAXPATHLEN]; /* '-dir' option */
      |                     ^
/tmp/xv/src/xv.h:1319:21: note: array types have different bounds
 1319 | WHERE char          searchdir[MAXPATHLEN]; /* '-dir' option */
      |                     ^
/tmp/xv/src/xv.h:1319:21: note: ‘searchdir’ was previously declared here
/tmp/xv/src/xv.h:1320:21: error: type of ‘fullfname’ does not match original declaration [-Werror=lto-type-mismatch]
 1320 | WHERE char          fullfname[MAXPATHLEN]; /* full name of current file */
      |                     ^
/tmp/xv/src/xv.h:1320:21: note: array types have different bounds
 1320 | WHERE char          fullfname[MAXPATHLEN]; /* full name of current file */
      |                     ^
/tmp/xv/src/xv.h:1320:21: note: ‘fullfname’ was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/sbin/cc 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

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