This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Fix --start-lib/--end-lib with split thinlto inputs
ClosedPublic

Authored by thakis on Dec 2 2022, 7:06 AM.

Details

Summary

Fixes #59162. The test has a comment explaining what's going on.
See also Symbol::extract() in lld/ELF/Symbols.cpp.

The included test sadly also passes if I pass just bd448f01a62,
while doing that isn't enough to make my bigger repro case work
(if I port just that, something else asserts later on, but with
this fix here everything's fine in my bigger repro).

Diff Detail

Event Timeline

thakis created this revision.Dec 2 2022, 7:06 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 2 2022, 7:06 AM
thakis requested review of this revision.Dec 2 2022, 7:06 AM
MaskRay accepted this revision.Dec 2 2022, 9:38 PM
MaskRay added a subscriber: MaskRay.

__ZTI1S is a LazyObject referring to vtable.o but appears in vtable.o twice.
When vtable.o is parsed as a lazy bitcode file due to __ZN1SC1Ev, the first __ZTI1S (undefined) causes vtable.o to be extracted again and makes an assert fail.

lld/test/MachO/thinlto-split-unit-start-lib.ll
10

I find the sentences since "When something then ..." are somewhat difficult to understand...

24

-lc++ isn't necessary. I suggest a relocatable file with

.section __DATA,__data
.globl __ZTVN10__cxxabiv117__class_type_infoE
__ZTVN10__cxxabiv117__class_type_infoE:
81

These #* and !* can all be removed to denoise the test file.

This revision is now accepted and ready to land.Dec 2 2022, 9:38 PM
thakis marked 2 inline comments as done.Dec 5 2022, 7:49 AM

Thanks!

lld/test/MachO/thinlto-split-unit-start-lib.ll
10

Reworded it using your suggestion, thanks!

24

-lc++ just links to a tbd file that contains what you suggested (and 5 other symbols), it doesn't link against a real libc++.

81

Done. (I kind of like using the output of clang unedited, but since I had to edit anyways to add the type metadata to the typeinfo, might as well.)

This revision was automatically updated to reflect the committed changes.
thakis marked 2 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 7:51 AM