I would like to improve the build speed of a large project. The opt build is compiled with -O2 -g. I noticed that without -g, compilation becomes faster, about 10-20%. The resulting binary has enough information to analyze crashes, except for the line numbers. Is there a way to include line number information but nothing else?
According to http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html, line numbers are produced only at level 2 (i.e. -g2 or the default of -g) or above. But according to this http://gcc.gnu.org/wiki/DebugFission, line numbers are only a fraction of the debug information (1%). So for me it would be best to have -g0 or -g1 but with line numbers. Is this possible?
Best regards, Martin
GDB can give you the line where a crash occurred with the "bt" (short for "backtrace") command after the program has seg faulted. This will give you not only the line of the crash, but the whole stack of the program (so you can see what called the function where the crash happened).
gcc -g generates debug information to be used by GDB debugger.
exerpt: "RelwithDebInfo is quite similar to Release mode. It produces fully optimized code, but also builds the program database, and inserts debug line information to give a debugger a good chance at guessing where in the code you are at any time."
Googling the Clang option mentioned by Matthieu, I found a patch for gcc that does what I want. It has been submitted for trunk but has been pending since two years. This means stock GCC is not able to do this, but with this patch it can do it using the option "-gmlt"
http://old.nabble.com/-patch--Add-new--gmlt-option-for-min.-debug-info-with-line-tables-%28issue4440072%29-td31482851.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With