views:

1140

answers:

5

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.

A: 

Which compiler are you using? For example, if I understand your question correctly, this is a trivial matter in MS Visual Studio.

hatcat
tell him how to do it then.
gbjbaanb
It may be trivial, but it's a lot of typing... Turns out he's not in VS.
hatcat
A: 

You probably don't want to strip the debug symbols from the shared libraries, as you may need that at some point.

If you are using GDB or DDD to debug, you may be able to get away with removing the Boost source files from the Source Path so it can't trace into the functions. (Or just don't trace into them, trace over!)

You can remove the option to compile the program with debug symbols, which will speed the link time.

Like the script you link to, you can consult the strip program ("man strip") to remove all or certain symbols.

Kris Kumler
+1  A: 

You may want to use strip. strip --strip-unneeded --strip-debug libfoo.so

Why don't you just build without debugging in the first place though?

Leon Timmermans
+1  A: 

As far as I know there's no real option to do what you want in gcc. The main problem being that all the code you want to strip debug symbols for is defined in headers.

Otherwhise it would be possible to build a library separatly, strip that, and link with the stripped version.

But only getting debug symbols from certain parts of a compilation unit, while building and linking (for your desired link time speedup) is not possible in gcc as far as I know.

Pieter
+3  A: 

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=

MSalters