Skip to content

Commit 45714f1

Browse files
committed
Have the frontend and new swift-driver look in an external -sdk for non-Darwin platform runtime libraries and modules too
as done originally in #25990 with the legacy C++ Driver, but since lost in the new swift-driver
1 parent d49dd18 commit 45714f1

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/ClangImporter/ClangImporter.cpp

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

764-
// Prefer `-sdk` paths.
765-
if (!searchPathOpts.getSDKPath().empty()) {
766-
llvm::SmallString<261> path{searchPathOpts.getSDKPath()};
767-
llvm::sys::path::append(path, "usr", "lib", "swift", "apinotes");
768-
769-
invocationArgStrs.push_back("-iapinotes-modules");
770-
invocationArgStrs.push_back(path.str().str());
771-
}
772-
773-
// Fallback to "legacy" `-resource-dir` paths.
774-
{
775764
llvm::SmallString<261> path{searchPathOpts.RuntimeResourcePath};
776765
llvm::sys::path::append(path, "apinotes");
777766

778767
invocationArgStrs.push_back("-iapinotes-modules");
779768
invocationArgStrs.push_back(path.str().str());
780-
}
781769
}
782770

783771
static void

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,7 @@ static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModule
22812281

22822282
static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
22832283
DiagnosticEngine &Diags,
2284+
const llvm::Triple &Triple,
22842285
const CASOptions &CASOpts,
22852286
const FrontendOptions &FrontendOpts,
22862287
StringRef workingDirectory) {
@@ -2415,6 +2416,13 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
24152416

24162417
if (const Arg *A = Args.getLastArg(OPT_resource_dir))
24172418
Opts.RuntimeResourcePath = A->getValue();
2419+
else if (Args.hasArg(OPT_sdk)) {
2420+
llvm::SmallString<128> SDKResourcePath(Opts.getSDKPath());
2421+
llvm::sys::path::append(
2422+
SDKResourcePath, "usr", "lib",
2423+
FrontendOpts.UseSharedResourceFolder ? "swift" : "swift_static");
2424+
Opts.RuntimeResourcePath = SDKResourcePath.str();
2425+
}
24182426

24192427
Opts.SkipAllImplicitImportPaths |= Args.hasArg(OPT_nostdimport);
24202428
Opts.SkipSDKImportPaths |= Args.hasArg(OPT_nostdlibimport);
@@ -4060,7 +4068,7 @@ bool CompilerInvocation::parseArgs(
40604068

40614069
ParseSymbolGraphArgs(SymbolGraphOpts, ParsedArgs, Diags, LangOpts);
40624070

4063-
if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags,
4071+
if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags, LangOpts.Target,
40644072
CASOpts, FrontendOpts, workingDirectory)) {
40654073
return true;
40664074
}

0 commit comments

Comments
 (0)