[Frontend] Use the swift_static directory when appropriate.

We should be using `/usr/lib/swift_static` and not `/usr/lib/swift`
when we're using the static resource directory.

rdar://123506588
This commit is contained in:
Alastair Houghton
2024-02-23 14:52:42 +00:00
parent a2a208379d
commit 786e178113

View File

@@ -186,8 +186,9 @@ void CompilerInvocation::setDefaultBlocklistsIfNecessary() {
}
static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
LangOptions &LangOpts) {
llvm::Triple &Triple = LangOpts.Target;
const FrontendOptions &FrontendOpts,
const LangOptions &LangOpts) {
const llvm::Triple &Triple = LangOpts.Target;
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);
StringRef LibSubDir = getPlatformNameForTriple(Triple);
@@ -220,15 +221,18 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
}
if (!SearchPathOpts.getSDKPath().empty()) {
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
? "swift" : "swift_static";
if (tripleIsMacCatalystEnvironment(Triple)) {
LibPath = SearchPathOpts.getSDKPath();
llvm::sys::path::append(LibPath, "System", "iOSSupport");
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
llvm::sys::path::append(LibPath, "usr", "lib", swiftDir);
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
}
LibPath = SearchPathOpts.getSDKPath();
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
llvm::sys::path::append(LibPath, "usr", "lib", swiftDir);
if (!Triple.isOSDarwin()) {
// Use the non-architecture suffixed form with directory-layout
// swiftmodules.
@@ -298,7 +302,7 @@ setBridgingHeaderFromFrontendOptions(ClangImporterOptions &ImporterOpts,
void CompilerInvocation::setRuntimeResourcePath(StringRef Path) {
SearchPathOpts.RuntimeResourcePath = Path.str();
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
}
void CompilerInvocation::setTargetTriple(StringRef Triple) {
@@ -307,12 +311,12 @@ void CompilerInvocation::setTargetTriple(StringRef Triple) {
void CompilerInvocation::setTargetTriple(const llvm::Triple &Triple) {
LangOpts.setTarget(Triple);
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
}
void CompilerInvocation::setSDKPath(const std::string &Path) {
SearchPathOpts.setSDKPath(Path);
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
}
bool CompilerInvocation::setModuleAliasMap(std::vector<std::string> args,
@@ -3260,7 +3264,7 @@ bool CompilerInvocation::parseArgs(
return true;
}
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
setDefaultPrebuiltCacheIfNecessary();
setDefaultBlocklistsIfNecessary();