Martin Richtarsky
Martin Richtarsky

Reputation: 679

GCC: How to generate line number debug information only?

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

Upvotes: 11

Views: 5755

Answers (3)

Johan Boulé
Johan Boulé

Reputation: 2090

Time has passed.

GCC know includes line numbers with -g1.

You can also add two more options to save more space: -g1 -gz -gsplit-dwarf

Upvotes: 3

Martin Richtarsky
Martin Richtarsky

Reputation: 679

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

Upvotes: 7

Matthieu M.
Matthieu M.

Reputation: 299850

Could you be mistaken ? I know that Clang supports -gline-tables-only, however as far as I could see gcc does not; it does support -g1, but there is no line information.

Upvotes: 6

Related Questions