@@ -232,8 +232,35 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
232232 if (LangOpts.hasFeature (Feature::Embedded))
233233 LibSubDir = " embedded" ;
234234
235- llvm::sys::path::append (LibPath, LibSubDir);
236235 SearchPathOpts.RuntimeLibraryPaths .clear ();
236+
237+ #if defined(_WIN32)
238+ // Resource path looks like this:
239+ //
240+ // C:\...\Swift\Toolchains\6.0.0+Asserts\usr\lib\swift
241+ //
242+ // The runtimes are in
243+ //
244+ // C:\...\Swift\Runtimes\6.0.0\usr\bin
245+ //
246+ llvm::SmallString<128 > RuntimePath (LibPath);
247+
248+ llvm::sys::path::remove_filename (RuntimePath);
249+ llvm::sys::path::remove_filename (RuntimePath);
250+ llvm::sys::path::remove_filename (RuntimePath);
251+
252+ llvm::SmallString<128 > VersionWithAttrs (llvm::sys::path::filename (RuntimePath));
253+ size_t MaybePlus = VersionWithAttrs.find_first_of (' +' );
254+ StringRef Version = VersionWithAttrs.substr (0 , MaybePlus);
255+
256+ llvm::sys::path::remove_filename (RuntimePath);
257+ llvm::sys::path::remove_filename (RuntimePath);
258+ llvm::sys::path::append (RuntimePath, " Runtimes" , Version, " usr" , " bin" );
259+
260+ SearchPathOpts.RuntimeLibraryPaths .push_back (std::string (RuntimePath.str ()));
261+ #endif
262+
263+ llvm::sys::path::append (LibPath, LibSubDir);
237264 SearchPathOpts.RuntimeLibraryPaths .push_back (std::string (LibPath.str ()));
238265 if (Triple.isOSDarwin ())
239266 SearchPathOpts.RuntimeLibraryPaths .push_back (DARWIN_OS_LIBRARY_PATH);
0 commit comments