This is an archive of the discontinued LLVM Phabricator instance.

[DWARFLinker][dsymutil][NFC] Move DwarfStreamer into DWARFLinker.
ClosedPublic

Authored by avl on Mar 31 2020, 1:41 PM.

Details

Summary

For implementing "remove obsolete debug info in lld", it is neccesary
to have DWARF generation code implementation. dsymutil uses DwarfStreamer
for that purpose. DwarfStreamer uses AsmPrinter. It is considered OK
to use AsmPrinter based code in lld(D74169). This patch moves
DwarfStreamer implementation into DWARFLinker, so that it could be reused
from lld.

Generally, a better place for such a common DWARF generation code would be
not DWARFLinker but an additional separate library. Such a library could
contain a single version of DWARF generation routines and could also
be independent of AsmPrinter. At the current moment, DwarfStreamer
does not pretend to be such a general implementation of DWARF generation.
So I decided to put it into DWARFLinker since it is the only user
of DwarfStreamer.

Testing: it passes "check-all" lit testing. MD5 checksum for clang .dSYM
bundle matches for the dsymutil with/without that patch.

Diff Detail

Event Timeline

avl created this revision.Mar 31 2020, 1:41 PM
avl updated this revision to Diff 254143.Apr 1 2020, 3:09 AM

added mistakenly missed part of patch.

JDevlieghere accepted this revision.Apr 3 2020, 11:44 AM
This revision is now accepted and ready to land.Apr 3 2020, 11:44 AM
This revision was automatically updated to reflect the committed changes.

Folks, we have a problem with this fix - when running a build that dynamically links tools with libLLVM.so (LVM_LINK_LLVM_DYLIB) we have massive failures on llvm-readobj
which asserts because it now has a conflict between MC "-W" and readobj "-W" command line options.
Seems like moving DWARFStreamer.cpp into the library w/o first removing its

static mc::RegisterMCTargetOptionsFlags MOF;

was a mistake.

avl added a comment.Apr 8 2020, 4:49 AM

@fedor.sergeev Thank you for the info and sorry for the problem. I would make a fix shortly.

avl added a comment.Apr 8 2020, 7:16 AM

@fedor.sergeev I integrated the fix for the problem: https://reviews.llvm.org/rG0ed2170dc47718b0c0f4907d14676839a1210a8a , would you mind to check that the problem is cured on your side, please ?