Skip to content

Commit 32f01c9

Browse files
committed
Don't check for the OS in the Swift resource directory and fix apinotes too
1 parent bbf58b9 commit 32f01c9

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -753,23 +753,11 @@ void importer::getNormalInvocationArguments(
753753
invocationArgStrs.push_back("-fapinotes-swift-version=" +
754754
languageVersion.asAPINotesVersionString());
755755

756-
// Prefer `-sdk` paths.
757-
if (!searchPathOpts.getSDKPath().empty()) {
758-
llvm::SmallString<261> path{searchPathOpts.getSDKPath()};
759-
llvm::sys::path::append(path, "usr", "lib", "swift", "apinotes");
760-
761-
invocationArgStrs.push_back("-iapinotes-modules");
762-
invocationArgStrs.push_back(path.str().str());
763-
}
764-
765-
// Fallback to "legacy" `-resource-dir` paths.
766-
{
767756
llvm::SmallString<261> path{searchPathOpts.RuntimeResourcePath};
768757
llvm::sys::path::append(path, "apinotes");
769758

770759
invocationArgStrs.push_back("-iapinotes-modules");
771760
invocationArgStrs.push_back(path.str().str());
772-
}
773761
}
774762

775763
static void

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,12 +2305,16 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
23052305
llvm::SmallString<128> SDKResourcePath(Opts.getSDKPath());
23062306
llvm::sys::path::append(
23072307
SDKResourcePath, "usr", "lib",
2308-
FrontendOpts.UseSharedResourceFolder ? "swift" : "swift_static",
2309-
getPlatformNameForTriple(Triple));
2310-
// Check for eg <sdkRoot>/usr/lib/swift/linux/
2311-
if (llvm::sys::fs::exists(SDKResourcePath)) {
2312-
llvm::sys::path::remove_filename(SDKResourcePath); // Remove <os> name
2308+
FrontendOpts.UseSharedResourceFolder ? "swift" : "swift_static");
2309+
// Check for eg <sdkRoot>/usr/lib/swift/
2310+
if (llvm::sys::fs::exists(SDKResourcePath))
23132311
Opts.RuntimeResourcePath = SDKResourcePath.str();
2312+
else {
2313+
llvm::outs() << "You passed in an external -sdk without a Swift runtime.\n";
2314+
llvm::outs() << "Either specify a directory containing the runtime libraries with\n";
2315+
llvm::outs() << "the -resource-dir flag, or use -sysroot instead to point at a C/C++\n";
2316+
llvm::outs() << "sysroot alone. Falling back to << Opts.RuntimeResourcePath << for\n";
2317+
llvm::outs() << "the Swift runtime modules and libraries.\n";
23142318
}
23152319
}
23162320

0 commit comments

Comments
 (0)