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.
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.)