This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Output debug info by default, unless the -s parameter is passed
ClosedPublic

Authored by mstorsjo on Nov 2 2017, 3:16 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Nov 2 2017, 3:16 AM
smeenai added a subscriber: smeenai.Nov 2 2017, 8:34 AM

lld-link will include debug info sections in the linked binary if you pass -debug (and you probably also want to pass -nopdb to prevent PDB emission if you're using DWARF). Perhaps you should make the MinGW driver pass those two options by default and then not pass them if -s is passed to it?

ruiu edited edge metadata.Nov 2 2017, 10:32 AM

I think it does if your object file contains .debug_ sections, as Shoaib pointed out.

rnk edited edge metadata.Nov 2 2017, 10:35 AM

Assuming we're still committed to the translation layer approach, it sounds like we will need a /debug:dwarf flag or something similar to enable this behavior in a more sensible way. /debug /nopdb is a surprising spelling for "I want DWARF in my image".

mstorsjo updated this revision to Diff 121381.Nov 2 2017, 2:32 PM
mstorsjo retitled this revision from [LLD] [MinGW] Ignore the -s parameter to [LLD] [MinGW] Output debug info by default, unless the -s parameter is passed.
mstorsjo edited the summary of this revision. (Show Details)

Output debug info by default.

Not sure whether it actually works though, because the gdb version I have (which is a tad old admittedly) refuses to load the lld produced exe, saying "not in executable format: File format not recognized". Although maybe the dwarf debug info does work with some other tools?

ruiu added inline comments.Nov 3 2017, 2:05 PM
COFF/Options.td
74 ↗(On Diff #121381)

Move this to below "LLD extensions" comment in this file.

MinGW/Options.td
27 ↗(On Diff #121381)

Can you define --strip-all as a primary option and define -s as an alias to it, in order to avoid cryptic variable name OPT_s?

mstorsjo updated this revision to Diff 121550.Nov 3 2017, 2:13 PM

Moved the COFF option, made --strip-all the main option and -s an alias.

ruiu accepted this revision.Nov 3 2017, 2:16 PM

LGTM

MinGW/Options.td
27 ↗(On Diff #121381)

I think you want to use F instead of Flags because both -strip-all and --strip-all are valid.

This revision is now accepted and ready to land.Nov 3 2017, 2:16 PM
This revision was automatically updated to reflect the committed changes.