Aleph-One-Marathon / alephone

Aleph One is the open source continuation of Bungie’s Marathon 2 game engine.
https://alephone.lhowon.org/
GNU General Public License v3.0
621 stars 100 forks source link

Build fails with LTO #475

Closed eli-schwartz closed 2 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

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-g++  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o alephone shell.o shell_misc.o shell_options.o main.o CSeries/libcseries.a Files/libfiles.a FFmpeg/libffmpeg.a GameWorld/libgameworld.a Input/libinput.a Lua/liba1lua.a Misc/libmisc.a ModelView/libmodelview.a Network/libnetwork.a Network/Metaserver/libmetaserver.a RenderMain/librendermain.a RenderOther/librenderother.a Sound/libsound.a XML/libxml.a CSeries/libcseries.a Files/libfiles.a FFmpeg/libffmpeg.a GameWorld/libgameworld.a Input/libinput.a Lua/liba1lua.a Misc/libmisc.a ModelView/libmodelview.a Network/libnetwork.a Network/Metaserver/libmetaserver.a RenderMain/librendermain.a RenderOther/librenderother.a Sound/libsound.a TCPMess/libtcpmess.a XML/libxml.a -lpng16 -lzzip -lz -lavcodec -lavformat -lavutil -lswscale -lswresample -lSDL2_image -lSDL2 -lopenal -lsndfile -lz -lSDL2_net -lSDL2 -lSDL2_ttf -lSDL2 -lboost_filesystem -lboost_system  -lSDL2 -lGL -lpthread -lGLU
GameWorld/flood_map.cpp:61:8: error: type ‘struct node_data’ violates the C++ One Definition Rule [-Werror=odr]
   61 | struct node_data /* 16 bytes */
      |        ^
RenderMain/RenderVisTree.h:134:8: note: a different type is defined in another translation unit
  134 | struct node_data
      |        ^
GameWorld/flood_map.cpp:65:15: note: the first difference of corresponding definitions is field ‘parent_node_index’
   65 |         int16 parent_node_index; /* node index of the node we came from to get here; only used for backtracking */
      |               ^
RenderMain/RenderVisTree.h:137:15: note: a field with different name is defined in another translation unit
  137 |         short polygon_index;
      |               ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-g++ 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[3]: *** [Makefile:532: alephone] Error 1

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