You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting Link Time optimization working takes certain combinations of modern tools and build settings. It would be great to have some general docs on this so that LTO is demystified and more commonly used.
Doc should cover:
Linux details
upgraded binutils gold (can be installed via mason)
at least clang++ 3.9.1 via mason
llvm-ar and llvm-ranlib on path (and set in environment AR=/path/to/llvm-arRANLIB=/path/to/llvm-ranlib)
-flto in the CXXFLAGS
OS X details
Apple built in compiler or clang++ via mason
-flto in the CXXFLAGS and LDFLAGS
Troubleshooting:
This error indicates that the linker does not understand the LTO format. This will happen on linux if you've not installed binutils from mason.
file.o: file not recognized: File format not recognized
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
Flagging: CMake's interprocedural optimization property does not enable lto on gcc and clang - it only does so for the Intel compiler. I ran into this some time ago since it looks fitting. Something to look out for.
Related: maybe a note or two about how to check cxxflags and ldflags in CMake's generated files would be great for debugging - I think the files are called CMakeFiles/TARGET.dir/{flags.make,link.txt}.
per mapbox/carmen-cache#117 (comment) also we need to ensure the same clang++ major version is used to compile all binaries and libraries" otherwise you'll see an error like:
LLVM gold plugin has failed to create LTO module:
Invalid value (Producer: 'LLVM5.0.0git-30c4647' Reader: 'LLVM 3.9.1')
Activity
daniel-j-h commentedon May 4, 2017
Flagging: CMake's interprocedural optimization property does not enable lto on gcc and clang - it only does so for the Intel compiler. I ran into this some time ago since it looks fitting. Something to look out for.
Related: maybe a note or two about how to check cxxflags and ldflags in CMake's generated files would be great for debugging - I think the files are called
CMakeFiles/TARGET.dir/{flags.make,link.txt}.springmeyer commentedon Feb 27, 2018
per mapbox/carmen-cache#117 (comment) also we need to ensure the same clang++ major version is used to compile all binaries and libraries" otherwise you'll see an error like:
springmeyer commentedon Apr 24, 2018
node-cpp-skel now enables LTO by default: mapbox/node-cpp-skel#110
jfirebaugh commentedon Jul 27, 2018
It seems that
-fltoand-Oscannot currently be used simultaneously when using the Android NDK: android/ndk#721.