@@ -254,7 +254,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
254
254
SearchPathOpts.RuntimeLibraryPaths .push_back (DARWIN_OS_LIBRARY_PATH);
255
255
256
256
// If this is set, we don't want any runtime import paths.
257
- if (SearchPathOpts.SkipRuntimeLibraryImportPaths ) {
257
+ if (SearchPathOpts.SkipAllImplicitImportPaths ) {
258
258
SearchPathOpts.setRuntimeLibraryImportPaths ({});
259
259
return ;
260
260
}
@@ -270,7 +270,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
270
270
RuntimeLibraryImportPaths.push_back (std::string (LibPath.str ()));
271
271
}
272
272
273
- if (!SearchPathOpts.ExcludeSDKPathsFromRuntimeLibraryImportPaths && !SearchPathOpts.getSDKPath ().empty ()) {
273
+ if (!SearchPathOpts.SkipSDKImportPaths && !SearchPathOpts.getSDKPath ().empty ()) {
274
274
const char *swiftDir = FrontendOpts.UseSharedResourceFolder
275
275
? " swift" : " swift_static" ;
276
276
@@ -300,6 +300,35 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
300
300
SearchPathOpts.setRuntimeLibraryImportPaths (RuntimeLibraryImportPaths);
301
301
}
302
302
303
+ static void
304
+ updateImplicitFrameworkSearchPaths (SearchPathOptions &SearchPathOpts,
305
+ const LangOptions &LangOpts) {
306
+ if (SearchPathOpts.SkipAllImplicitImportPaths ) {
307
+ SearchPathOpts.setImplicitFrameworkSearchPaths ({});
308
+ return ;
309
+ }
310
+
311
+ std::vector<std::string> ImplicitFrameworkSearchPaths;
312
+ if (LangOpts.Target .isOSDarwin ()) {
313
+ if (!SearchPathOpts.SkipSDKImportPaths &&
314
+ !SearchPathOpts.getSDKPath ().empty ()) {
315
+ StringRef SDKPath = SearchPathOpts.getSDKPath ();
316
+ SmallString<128 > systemFrameworksScratch (SDKPath);
317
+ llvm::sys::path::append (systemFrameworksScratch, " System" , " Library" ,
318
+ " Frameworks" );
319
+ SmallString<128 > systemSubFrameworksScratch (SDKPath);
320
+ llvm::sys::path::append (systemSubFrameworksScratch, " System" , " Library" ,
321
+ " SubFrameworks" );
322
+ SmallString<128 > frameworksScratch (SDKPath);
323
+ llvm::sys::path::append (frameworksScratch, " Library" , " Frameworks" );
324
+ ImplicitFrameworkSearchPaths = {systemFrameworksScratch.str ().str (),
325
+ systemSubFrameworksScratch.str ().str (),
326
+ frameworksScratch.str ().str ()};
327
+ }
328
+ }
329
+ SearchPathOpts.setImplicitFrameworkSearchPaths (ImplicitFrameworkSearchPaths);
330
+ }
331
+
303
332
static void
304
333
setIRGenOutputOptsFromFrontendOptions (IRGenOptions &IRGenOpts,
305
334
const FrontendOptions &FrontendOpts) {
@@ -411,11 +440,13 @@ void CompilerInvocation::setTargetTriple(StringRef Triple) {
411
440
void CompilerInvocation::setTargetTriple (const llvm::Triple &Triple) {
412
441
LangOpts.setTarget (Triple);
413
442
updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
443
+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
414
444
}
415
445
416
446
void CompilerInvocation::setSDKPath (const std::string &Path) {
417
447
SearchPathOpts.setSDKPath (Path);
418
448
updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
449
+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
419
450
}
420
451
421
452
bool CompilerInvocation::setModuleAliasMap (std::vector<std::string> args,
@@ -2387,8 +2418,8 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
2387
2418
if (const Arg *A = Args.getLastArg (OPT_resource_dir))
2388
2419
Opts.RuntimeResourcePath = A->getValue ();
2389
2420
2390
- Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
2391
- Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdlibimport);
2421
+ Opts.SkipAllImplicitImportPaths |= Args.hasArg (OPT_nostdimport);
2422
+ Opts.SkipSDKImportPaths |= Args.hasArg (OPT_nostdlibimport);
2392
2423
2393
2424
Opts.DisableModulesValidateSystemDependencies |=
2394
2425
Args.hasArg (OPT_disable_modules_validate_system_headers);
@@ -4056,6 +4087,7 @@ bool CompilerInvocation::parseArgs(
4056
4087
}
4057
4088
4058
4089
updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
4090
+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
4059
4091
setDefaultPrebuiltCacheIfNecessary ();
4060
4092
setDefaultBlocklistsIfNecessary ();
4061
4093
setDefaultInProcessPluginServerPathIfNecessary ();
0 commit comments