@@ -2166,6 +2166,7 @@ static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModule
2166
2166
2167
2167
static bool ParseSearchPathArgs (SearchPathOptions &Opts, ArgList &Args,
2168
2168
DiagnosticEngine &Diags,
2169
+ const llvm::Triple &Triple,
2169
2170
const CASOptions &CASOpts,
2170
2171
const FrontendOptions &FrontendOpts,
2171
2172
StringRef workingDirectory) {
@@ -2300,6 +2301,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
2300
2301
2301
2302
if (const Arg *A = Args.getLastArg (OPT_resource_dir))
2302
2303
Opts.RuntimeResourcePath = A->getValue ();
2304
+ else if (!Triple.isOSDarwin () && Args.hasArg (OPT_sdk)) {
2305
+ llvm::SmallString<128 > SDKResourcePath (Opts.getSDKPath ());
2306
+ llvm::sys::path::append (
2307
+ 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
2313
+ Opts.RuntimeResourcePath = SDKResourcePath.str ();
2314
+ }
2315
+ }
2303
2316
2304
2317
Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
2305
2318
Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdlibimport);
@@ -3908,7 +3921,7 @@ bool CompilerInvocation::parseArgs(
3908
3921
3909
3922
ParseSymbolGraphArgs (SymbolGraphOpts, ParsedArgs, Diags, LangOpts);
3910
3923
3911
- if (ParseSearchPathArgs (SearchPathOpts, ParsedArgs, Diags,
3924
+ if (ParseSearchPathArgs (SearchPathOpts, ParsedArgs, Diags, LangOpts. Target ,
3912
3925
CASOpts, FrontendOpts, workingDirectory)) {
3913
3926
return true ;
3914
3927
}
0 commit comments