Skip to content

Commit 786e178

Browse files
committed
[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
1 parent a2a2083 commit 786e178

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ void CompilerInvocation::setDefaultBlocklistsIfNecessary() {
186186
}
187187

188188
static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
189-
LangOptions &LangOpts) {
190-
llvm::Triple &Triple = LangOpts.Target;
189+
const FrontendOptions &FrontendOpts,
190+
const LangOptions &LangOpts) {
191+
const llvm::Triple &Triple = LangOpts.Target;
191192
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);
192193

193194
StringRef LibSubDir = getPlatformNameForTriple(Triple);
@@ -220,15 +221,18 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
220221
}
221222

222223
if (!SearchPathOpts.getSDKPath().empty()) {
224+
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
225+
? "swift" : "swift_static";
226+
223227
if (tripleIsMacCatalystEnvironment(Triple)) {
224228
LibPath = SearchPathOpts.getSDKPath();
225229
llvm::sys::path::append(LibPath, "System", "iOSSupport");
226-
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
230+
llvm::sys::path::append(LibPath, "usr", "lib", swiftDir);
227231
RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
228232
}
229233

230234
LibPath = SearchPathOpts.getSDKPath();
231-
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
235+
llvm::sys::path::append(LibPath, "usr", "lib", swiftDir);
232236
if (!Triple.isOSDarwin()) {
233237
// Use the non-architecture suffixed form with directory-layout
234238
// swiftmodules.
@@ -298,7 +302,7 @@ setBridgingHeaderFromFrontendOptions(ClangImporterOptions &ImporterOpts,
298302

299303
void CompilerInvocation::setRuntimeResourcePath(StringRef Path) {
300304
SearchPathOpts.RuntimeResourcePath = Path.str();
301-
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
305+
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
302306
}
303307

304308
void CompilerInvocation::setTargetTriple(StringRef Triple) {
@@ -307,12 +311,12 @@ void CompilerInvocation::setTargetTriple(StringRef Triple) {
307311

308312
void CompilerInvocation::setTargetTriple(const llvm::Triple &Triple) {
309313
LangOpts.setTarget(Triple);
310-
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
314+
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
311315
}
312316

313317
void CompilerInvocation::setSDKPath(const std::string &Path) {
314318
SearchPathOpts.setSDKPath(Path);
315-
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
319+
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
316320
}
317321

318322
bool CompilerInvocation::setModuleAliasMap(std::vector<std::string> args,
@@ -3260,7 +3264,7 @@ bool CompilerInvocation::parseArgs(
32603264
return true;
32613265
}
32623266

3263-
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts);
3267+
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
32643268
setDefaultPrebuiltCacheIfNecessary();
32653269
setDefaultBlocklistsIfNecessary();
32663270

0 commit comments

Comments
 (0)