gcc LTO appears to strip debugging symbols
The situation should have improved by now. GCC 8 finally got the early debug info improvements: http://hubicka.blogspot.com/2018/06/gcc-8-link-time-and-interprocedural.html
While it was possible to build with LTO and -g and debug the resulting binary, the debug information was kind of messed up C, instead of debug info corresponding to the language program was originally written in. This is finally solved. [...] The main idea is to produce DWARF early during compilation, store it into object files and during link-time just copy necessary fragments to final object files without need for compiler to parse it and update it.
But note that -gsplit-dwarf
won't work with LTO.
It's because gcc does not support combine -flto
with -g
.
You can find the details GCC Online Docs - Optimize Options
"Combining
-flto
with-g
is currently experimental and expected to produce unexpected results."
When you use -flto
, the -g
will be ignored.