@@ -2124,6 +2124,7 @@ static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModule
2124
2124
2125
2125
static bool ParseSearchPathArgs (SearchPathOptions &Opts, ArgList &Args,
2126
2126
DiagnosticEngine &Diags,
2127
+ const llvm::Triple &Triple,
2127
2128
const CASOptions &CASOpts,
2128
2129
const FrontendOptions &FrontendOpts,
2129
2130
StringRef workingDirectory) {
@@ -2258,6 +2259,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
2258
2259
2259
2260
if (const Arg *A = Args.getLastArg (OPT_resource_dir))
2260
2261
Opts.RuntimeResourcePath = A->getValue ();
2262
+ else if (!Triple.isOSDarwin () && Args.hasArg (OPT_sdk)) {
2263
+ llvm::SmallString<128 > SDKResourcePath (Opts.getSDKPath ());
2264
+ llvm::sys::path::append (
2265
+ SDKResourcePath, " usr" , " lib" ,
2266
+ FrontendOpts.UseSharedResourceFolder ? " swift" : " swift_static" ,
2267
+ getPlatformNameForTriple (Triple));
2268
+ // Check for eg <sdkRoot>/usr/lib/swift/linux/
2269
+ if (llvm::sys::fs::exists (SDKResourcePath)) {
2270
+ llvm::sys::path::remove_filename (SDKResourcePath); // Remove <os> name
2271
+ Opts.RuntimeResourcePath = SDKResourcePath.str ();
2272
+ }
2273
+ }
2261
2274
2262
2275
Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
2263
2276
Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdlibimport);
@@ -3847,7 +3860,7 @@ bool CompilerInvocation::parseArgs(
3847
3860
3848
3861
ParseSymbolGraphArgs (SymbolGraphOpts, ParsedArgs, Diags, LangOpts);
3849
3862
3850
- if (ParseSearchPathArgs (SearchPathOpts, ParsedArgs, Diags,
3863
+ if (ParseSearchPathArgs (SearchPathOpts, ParsedArgs, Diags, LangOpts. Target ,
3851
3864
CASOpts, FrontendOpts, workingDirectory)) {
3852
3865
return true ;
3853
3866
}
0 commit comments