TheOpenSpaceProgram / osp-magnum

A spaceship game
https://www.openspaceprogram.org/
MIT License
216 stars 32 forks source link

Build fails on Clang Release with LTO #223

Closed Capital-Asterisk closed 1 year ago

Capital-Asterisk commented 1 year ago
[100%] Linking CXX executable ../Release/osp-magnum
/usr/bin/ld: /tmp/lto-llvm-ad2d68.o: in function `Magnum::Trade::MaterialAttributeData::value() const':
MaterialData.cpp:(.text._ZNK6Magnum5Trade21MaterialAttributeData5valueEv+0x31): undefined reference to `Corrade::Containers::Implementation::stringFindCharacter(char const*, unsigned long, char)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [src/CMakeFiles/osp-magnum.dir/build.make:717: Release/osp-magnum] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:3004: src/CMakeFiles/osp-magnum.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:3011: src/CMakeFiles/osp-magnum.dir/rule] Error 2
gmake: *** [Makefile:980: osp-magnum] Error 2

Magnum and Corrade are statically linked. The stringFindCharacter function is present in libCorradeUtility.a and is part of the link command. I tried a few things, but only disabling LTO worked.

This might have something to do with how Corrade is doing some kind of runtime CPU dispatching to optimize certain functions (stringFindCharacter specifically) depending on the machine.