Skip to content

Commit 317a6ab

Browse files
authored
[Immediate]: Workaround for loading Foundation in immediate mode (#59730)
* [Immediate]: Workaround for loading Foundation in immediate mode rdar://94645534 * Update Immediate.cpp * Update Immediate.cpp
1 parent c99083e commit 317a6ab

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/Immediate/Immediate.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,25 @@ bool swift::immediate::autolinkImportedModules(ModuleDecl *M,
201201

202202
M->collectLinkLibraries(addLinkLibrary);
203203

204+
// Workaround for rdar://94645534.
205+
//
206+
// The framework layout of Foundation has changed in 13.0, causing unresolved symbol
207+
// errors to libswiftFoundation in immediate mode when running on older OS versions
208+
// with a 13.0 SDK. This workaround scans through the list of dependencies and
209+
// manually adds libswiftFoundation if necessary.
210+
auto &Target = M->getASTContext().LangOpts.Target;
211+
if (Target.isMacOSX() && Target.getOSMajorVersion() < 13) {
212+
bool linksFoundation = std::any_of(AllLinkLibraries.begin(),
213+
AllLinkLibraries.end(), [](auto &Lib) {
214+
return Lib.getName() == "Foundation";
215+
});
216+
217+
if (linksFoundation) {
218+
AllLinkLibraries.push_back(LinkLibrary("libswiftFoundation.dylib",
219+
LibraryKind::Library));
220+
}
221+
}
222+
204223
tryLoadLibraries(AllLinkLibraries, M->getASTContext().SearchPathOpts,
205224
M->getASTContext().Diags);
206225
return false;

0 commit comments

Comments
 (0)