This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Allow requesting PDB output without giving a file name
ClosedPublic

Authored by mstorsjo on May 16 2019, 5:31 AM.

Details

Summary

Opinions on naming options wanted!

When integrating PDB output in mingw targeting build systems, it might be a lot of extra work to specify unique file names for the pdb output. Therefore allow omitting the actual file name and let it implicitly be the same name as the linker output, with a pdb extension.

As the current form of the pdb option takes a separate parameter value, e.g. "-pdb out.pdb", it is impractical to leave out the parameter value.

Therefore, introduce a second syntax for the option, with an equals sign, like -pdb=out.pdb, where the value easily can be omitted.

The form -pdb= for requesting pdb files with an implicit name should work fine, even though it looks a bit unconventional in that form.

Alternatively, a flag with a different name could be introduced (e.g. --default-pdb), or we could consider changing the flag name altogether (having -pdb be the default with an implicit name, and "--out-pdb out.pdb" for the case when naming the output file, just like the existing --out-implib). The current number of users of the lld specific pdb option is probably low, so in case renaming the option altogether is deemed the best path forward, that could also be doable.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

mstorsjo created this revision.May 16 2019, 5:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2019, 5:31 AM
ruiu added a comment.May 16 2019, 6:01 AM

I think I'm fine with the --pdb= option, although it looks a bit odd. Does this work both for --pdb= and --pdb ''? I think logically they should be identical.

I think I'm fine with the --pdb= option, although it looks a bit odd. Does this work both for --pdb= and --pdb ''? I think logically they should be identical.

Yes, the latter should also work, although I didn't make the testcase try it (in case there's issues with quoting in various environments).

dmajor added inline comments.May 16 2019, 6:46 AM
MinGW/Driver.cpp
168–170

Is the StringRef on the RHS necessary?

MinGW/Options.td
61

Should the new behavior be advertised in the HelpText or a doc somewhere?

mstorsjo marked 2 inline comments as done.May 16 2019, 12:25 PM
mstorsjo added inline comments.
MinGW/Driver.cpp
168–170

Ah right, no it isn't.

MinGW/Options.td
61

Hmm, yes, ideally. I don't think there's much other general usage docs for the MinGW driver, so I guess it has to be squeezed into the HelpText here. I'd document it on my page for my MinGW distribution at least, for general usage of PDBs in a MinGW context (for the combination of passing -gcodeview to the compiler, and this option to the linker).

Maybe HelpText<"Specify output PDB debug information file. Defaults to the output filename, with a pdb suffix, if given an empty argument.">? Or can you come up with a more concise way of describing it?

ruiu added inline comments.May 16 2019, 6:41 PM
MinGW/Options.td
61

Other help messages don't end with a full stop, so I'd try to explain it in a single sentence rather than two sentences.

mstorsjo marked an inline comment as done.May 16 2019, 11:32 PM
mstorsjo added inline comments.
MinGW/Options.td
61

What about Output PDB debug info file, chosen implicitly if the arguent is empty? That's pretty short, no full stops, and still conveys the main point.

ruiu accepted this revision.May 17 2019, 3:05 AM

LGTM

MinGW/Options.td
61

Sounds good!

This revision is now accepted and ready to land.May 17 2019, 3:05 AM
This revision was automatically updated to reflect the committed changes.