This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] For catalyst outputs, tolerate implicitly linking against mac-only tbd files
ClosedPublic

Authored by thakis on Apr 23 2022, 11:22 AM.

Details

Summary

Before this,

clang empty.cc -target x86_64-apple-ios13.1-macabi \
    -framework CoreServices -fuse-ld=lld

would error out with

ld64.lld: error: path/to/MacOSX.sdk/System/Library/Frameworks/
     CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
     Versions/A/CarbonCore.tbd(
         /System/Library/Frameworks/
         CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
         Versions/A/CarbonCore) is incompatible with x86_64 (macCatalyst)

Now it works, like with ld64.

Diff Detail

Event Timeline

thakis created this revision.Apr 23 2022, 11:22 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 23 2022, 11:22 AM
Herald added a subscriber: pengfei. · View Herald Transcript
thakis requested review of this revision.Apr 23 2022, 11:22 AM

This is much simpler than D124275. The only thing that makes it slightly awkward is that we now need explicitlyLinked in the ctor already, so we need to plumb it around a bit.

thakis updated this revision to Diff 424738.Apr 23 2022, 11:25 AM

restore accidental deletion

thakis added inline comments.Apr 23 2022, 11:36 AM
lld/MachO/DriverUtils.cpp
212

Setting this on an already-loaded dylib is needed for the %t/foo_with_bar.dylib %t/bar.dylib case in line 29 in dead-strip-dylibs.s.

For tbd files, this means if a tbd file is loaded implicitly at first and then explicitly later on, we won't emit the diag. But I think at least once https://github.com/llvm/llvm-project/issues/55042 is fixed, you can't explicitly link a tbd's implicit exports?

In practice, I think this is probably fine as-is.

int3 accepted this revision.Apr 23 2022, 11:48 AM
int3 added a subscriber: int3.

nice, definitely simpler than the previous patch!

This revision is now accepted and ready to land.Apr 23 2022, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2022, 6:44 PM