This is an archive of the discontinued LLVM Phabricator instance.

[lld-link] initialize targets and asmparsers before invoking lib
ClosedPublic

Authored by inglorion on May 8 2019, 1:53 PM.

Details

Summary

When using lld-link to build static libraries containing object files
with module assembly, the program would crash with "Assertion `T &&
T->hasMCAsmParser()' failed". This change causes the code in lld-link
that initialized Targets, TargetInfos, and AsmParsers (which already
existed) to be run before entering the lib building path (which needs
it). This avoids the error (and is what llvm-lib and llvm-ar do, too).

Fixes PR41803.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

inglorion created this revision.May 8 2019, 1:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2019, 1:53 PM
rnk added a comment.May 8 2019, 2:18 PM

Nice.

lld/test/COFF/lib-module-asm.ll
4 ↗(On Diff #198722)

Please extend this to put some symbols in the module assembly and then run llvm-nm on the archive to show that the archiver actually parsed the module level assembly and didn't just ignore it. There's a test at llvm/test/Object/X86/archive-ir-asm.ll that does this that you can steal.

inglorion updated this revision to Diff 198728.May 8 2019, 2:29 PM

added symbols and check they are listed

inglorion marked an inline comment as done.May 8 2019, 2:29 PM
ruiu accepted this revision.May 8 2019, 2:36 PM

LGTM

This revision is now accepted and ready to land.May 8 2019, 2:36 PM
This revision was automatically updated to reflect the committed changes.