Describe the bug
When switching the system default gcc version, e. g. upgrading to gcc 9 on Ubuntu 18.04, the compiling fails with following error:
lto1: fatal error: bytecode stream in file ‘apriltag_pywrap.o’ generated with LTO version 8.1 instead of the expected 6.2
compilation terminated.
lto-wrapper: fatal error: x86_64-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [apriltag.cpython-36m-x86_64-linux-gnu.so] Error 1
make[1]: *** [CMakeFiles/apriltag_python.dir/all] Error 2
make: *** [all] Error 2
To Reproduce
Upgrade your gcc version on your system to a version using a higher LTO version.
Try to build the package
Operating Sytem
Tested on Ubuntu 18.04 using gcc 9.4
Code version
Current github HEAD
Additional context
The issue is that LTO is activated, which requires that the same LTO versions are used of the linked libraries.
The system libraries are build with the system default compiler, which in this case comes with an older LTO version.
Describe the bug When switching the system default gcc version, e. g. upgrading to gcc 9 on Ubuntu 18.04, the compiling fails with following error:
To Reproduce
Operating Sytem Tested on Ubuntu 18.04 using gcc 9.4
Code version Current github HEAD
Additional context The issue is that LTO is activated, which requires that the same LTO versions are used of the linked libraries. The system libraries are build with the system default compiler, which in this case comes with an older LTO version.
LTO is activated because all the python C build flags are simply copied over and used in this line: https://github.com/AprilRobotics/apriltag/blob/bee5efb1cc263ec1459bca46193e3428220d52ba/CMakeLists.txt#L150
This includes the
-ftlo
flag to activate LTO. Manually copying the flags and removing then the-flto
flag resolves the issue for me.