@@ -42,21 +42,35 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
4242 setRuntimeResourcePath (LibPath.str ());
4343}
4444
45- static void updateRuntimeLibraryPath (SearchPathOptions &SearchPathOpts,
46- llvm::Triple &Triple) {
45+ static void updateRuntimeLibraryPaths (SearchPathOptions &SearchPathOpts,
46+ llvm::Triple &Triple) {
4747 llvm::SmallString<128 > LibPath (SearchPathOpts.RuntimeResourcePath );
4848
4949 llvm::sys::path::append (LibPath, getPlatformNameForTriple (Triple));
5050 SearchPathOpts.RuntimeLibraryPath = LibPath.str ();
5151
52+ // Set up the import paths containing the swiftmodules for the libraries in
53+ // RuntimeLibraryPath.
54+ SearchPathOpts.RuntimeLibraryImportPaths .clear ();
55+
56+ // If this is set, we don't want any runtime import paths.
57+ if (SearchPathOpts.SkipRuntimeLibraryImportPaths )
58+ return ;
59+
5260 if (!Triple.isOSDarwin ())
5361 llvm::sys::path::append (LibPath, swift::getMajorArchitectureName (Triple));
54- SearchPathOpts.RuntimeLibraryImportPath = LibPath.str ();
62+ SearchPathOpts.RuntimeLibraryImportPaths .push_back (LibPath.str ());
63+
64+ if (!SearchPathOpts.SDKPath .empty ()) {
65+ LibPath = SearchPathOpts.SDKPath ;
66+ llvm::sys::path::append (LibPath, " usr" , " lib" , " swift" );
67+ SearchPathOpts.RuntimeLibraryImportPaths .push_back (LibPath.str ());
68+ }
5569}
5670
5771void CompilerInvocation::setRuntimeResourcePath (StringRef Path) {
5872 SearchPathOpts.RuntimeResourcePath = Path;
59- updateRuntimeLibraryPath (SearchPathOpts, LangOpts.Target );
73+ updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
6074}
6175
6276void CompilerInvocation::setTargetTriple (StringRef Triple) {
@@ -65,7 +79,12 @@ void CompilerInvocation::setTargetTriple(StringRef Triple) {
6579
6680void CompilerInvocation::setTargetTriple (const llvm::Triple &Triple) {
6781 LangOpts.setTarget (Triple);
68- updateRuntimeLibraryPath (SearchPathOpts, LangOpts.Target );
82+ updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
83+ }
84+
85+ void CompilerInvocation::setSDKPath (const std::string &Path) {
86+ SearchPathOpts.SDKPath = Path;
87+ updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
6988}
7089
7190SourceFileKind CompilerInvocation::getSourceFileKind () const {
@@ -561,7 +580,7 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts,
561580 if (const Arg *A = Args.getLastArg (OPT_resource_dir))
562581 Opts.RuntimeResourcePath = A->getValue ();
563582
564- Opts.SkipRuntimeLibraryImportPath |= Args.hasArg (OPT_nostdimport);
583+ Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
565584
566585 // Opts.RuntimeIncludePath is set by calls to
567586 // setRuntimeIncludePath() or setMainExecutablePath().
@@ -1273,7 +1292,7 @@ bool CompilerInvocation::parseArgs(
12731292 return true ;
12741293 }
12751294
1276- updateRuntimeLibraryPath (SearchPathOpts, LangOpts.Target );
1295+ updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
12771296
12781297 return false ;
12791298}
0 commit comments