Skip to content

[Immediate]: Workaround for loading Foundation in immediate mode #59730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/Immediate/Immediate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,25 @@ bool swift::immediate::autolinkImportedModules(ModuleDecl *M,

M->collectLinkLibraries(addLinkLibrary);

// Workaround for rdar://94645534.
//
// The framework layout of Foundation has changed in 13.0, causing unresolved symbol
// errors to libswiftFoundation in immediate mode when running on older OS versions
// with a 13.0 SDK. This workaround scans through the list of dependencies and
// manually adds libswiftFoundation if necessary.
auto &Target = M->getASTContext().LangOpts.Target;
if (Target.isMacOSX() && Target.getOSMajorVersion() < 13) {
bool linksFoundation = std::any_of(AllLinkLibraries.begin(),
AllLinkLibraries.end(), [](auto &Lib) {
return Lib.getName() == "Foundation";
});

if (linksFoundation) {
AllLinkLibraries.push_back(LinkLibrary("libswiftFoundation.dylib",
LibraryKind::Library));
}
}

tryLoadLibraries(AllLinkLibraries, M->getASTContext().SearchPathOpts,
M->getASTContext().Diags);
return false;
Expand Down