This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by thakis on Apr 22 2022, 10:18 AM.

Details

Reviewers
int3
Group Reviewers
Restricted Project
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 22 2022, 10:18 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 22 2022, 10:18 AM
Herald added a subscriber: pengfei. · View Herald Transcript
thakis requested review of this revision.Apr 22 2022, 10:18 AM
thakis updated this revision to Diff 424523.Apr 22 2022, 10:33 AM

zap trailing newlines

thakis updated this revision to Diff 424531.Apr 22 2022, 10:39 AM

s/Both/Separate/

int3 accepted this revision.Apr 22 2022, 11:24 AM
int3 added a subscriber: int3.

lgtm

lld/MachO/InputFiles.cpp
1129

should we have a test case that covers re-exports with separate versions?

This revision is now accepted and ready to land.Apr 22 2022, 11:24 AM
thakis updated this revision to Diff 424572.Apr 22 2022, 12:30 PM

clang-format, and try to get test passing on windows

thanks!

lld/MachO/InputFiles.cpp
1129

Oh hmm good point, I'll look into it (before landing).

thakis added inline comments.Apr 23 2022, 10:22 AM
lld/MachO/InputFiles.cpp
1129

While writing the test for this, I noticed that ld64 doesn't actually accept the MacOnly.framework case in the existing test here.

This patch is incorrect: I misread the

// Normally linked dylibs need to support all the platforms we are building for,
// with the exception of zippered binaries linking to macOS only libraries in the OS.
// To handle that case we exit early when the commandline platform is iOSMac, if
// the platforms also contain macOS.
if (cmdLinePlatform == ld::Platform::iOSMac && contains(ld::Platform::macOS) && !isUnzipperedTwin)
    return;

in ld64's PlatformSupport.cpp. This doesn't check the dylib architecture at all, it only checks the output platforms. We don't support writing zippered outputs yet, so we don't need this code at all yet.

What makes the thing mentioned in the patch description work in ld64 is instead the next few lines I think:

// <rdar://problem/48416765> spurious warnings when iOSMac binary is built links with zippered dylib that links with macOS dylib
// <rdar://problem/50517845> iOSMac app links simulator frameworks without warning/error
if  ( indirectDylib && dylibPlatforms.contains(ld::Platform::macOS) && contains(ld::Platform::iOSMac) )
    return;

We don't need all that hasSeparateMacAndCatalystVersion machinery for that.

I'll make a new patch for that, I think.

thakis abandoned this revision.Apr 23 2022, 11:23 AM

New patch is at D124336.

The machinery in this patch here will be useful if we ever add support for creating zippered libraries, but for now we don't need it.