This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Generate a codeview build id signature for MinGW even when not creating a PDB
ClosedPublic

Authored by mstorsjo on Nov 22 2018, 1:21 AM.

Details

Summary

GNU ld, which doesn't generate PDBs, can optionally generate a build id by passing the --build-id option. LLD's MinGW frontend knows about this option but ignores it, as I had incorrectly assumed that LLD already generated build IDs even in those cases.

If debug info is requested and no PDB path is set, generate a build id signature as a hash of the binary itself. This allows associating a binary to a minidump, even if debug info isn't written in PDB form by the linker.

I guess the main question is if we should add an lld specific option for this to the lld-link inteface, which we pass from the MinGW frontend when --build-id is received, or if we just should always generate it for the "mingw && debug && !pdb" case.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Nov 22 2018, 1:21 AM
ruiu added inline comments.Nov 26 2018, 11:22 AM
COFF/Writer.cpp
1574 ↗(On Diff #175020)

I think Config->MinGW && Config->Debug && Config->PDBPath.empty() is fine, but it seems this code needs a bit more explanation, because we create build id even if GenerateBuildId is false (if we are creating a PDB file.)

mstorsjo updated this revision to Diff 175309.Nov 26 2018, 11:57 AM

Added a comment explaining why the added code is there, renamed the variable to GenerateSyntheticBuildId to differentiate it a bit further from the normal build id generated in a PDB file.

mstorsjo updated this revision to Diff 175312.Nov 26 2018, 12:11 PM

Missed renaming the variable in one place in the previous version of the patch.

ruiu added a comment.Nov 26 2018, 1:01 PM

Could you add a test?

ruiu accepted this revision.Nov 26 2018, 1:02 PM

Oh sorry you have already added tests. For some reason they weren't displayed at first, but I can now see them. LGTM.

This revision is now accepted and ready to land.Nov 26 2018, 1:02 PM
This revision was automatically updated to reflect the committed changes.