Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove C++-STL/Boost debug symbols (... or do not create them)

Tags:

c++

debugging

stl

Linux/Gcc/LD - Toolchain.

I would like to remove STL/Boost debug symbols from libraries and executable, for two reasons:

  1. Linking gets very slow for big programs
  2. Debugging jumps into stl/boost code, which is annoying

For 1. incremental linking would be a big improvement, but AFAIK ld does not support incremental linking. There is a workaround "pseudo incremental linking" in an 1999 dr.dobb's journal (not in the web any more, but at archive.org (the idea is to put everything in a dynamic library and all updated object files in an second one that is loaded first) but this is not really a general solution.

For 2. there is a script here, but a) it did not work for me (it did not remove symbols), b) it is very slow as it works at the end of the pipe, while it would be more efficient to remove the symbols earlier.

Obviously, the other debug symbols should stay in place.

like image 324
Weidenrinde Avatar asked Sep 16 '08 15:09

Weidenrinde


1 Answers

GNU strip accepts regex arguments to --strip-symbols= The STL and boost symbols are name-mangled because of the namespaces they're in. I don't have GCC binutils handy at this moment, but just peek at the name mangling used for namespaces and construct the regex for 'symbols from namespace X' and pass this to --strip-symbols=

like image 145
MSalters Avatar answered Oct 11 '22 11:10

MSalters