[Frontend][Win32] Fix runtime path to point at runtime libs.

The code that generates the runtime path is not right for Windows;
fix it to point at the correct place.

This makes simple use of `swift test.swift` work.

rdar://132598892
This commit is contained in:
Alastair Houghton
2024-08-08 12:54:32 +01:00
parent 0ccbc7b4e6
commit dfeee81dfb

View File

@@ -232,8 +232,35 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
if (LangOpts.hasFeature(Feature::Embedded))
LibSubDir = "embedded";
llvm::sys::path::append(LibPath, LibSubDir);
SearchPathOpts.RuntimeLibraryPaths.clear();
#if defined(_WIN32)
// Resource path looks like this:
//
// C:\...\Swift\Toolchains\6.0.0+Asserts\usr\lib\swift
//
// The runtimes are in
//
// C:\...\Swift\Runtimes\6.0.0\usr\bin
//
llvm::SmallString<128> RuntimePath(LibPath);
llvm::sys::path::remove_filename(RuntimePath);
llvm::sys::path::remove_filename(RuntimePath);
llvm::sys::path::remove_filename(RuntimePath);
llvm::SmallString<128> VersionWithAttrs(llvm::sys::path::filename(RuntimePath));
size_t MaybePlus = VersionWithAttrs.find_first_of('+');
StringRef Version = VersionWithAttrs.substr(0, MaybePlus);
llvm::sys::path::remove_filename(RuntimePath);
llvm::sys::path::remove_filename(RuntimePath);
llvm::sys::path::append(RuntimePath, "Runtimes", Version, "usr", "bin");
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(RuntimePath.str()));
#endif
llvm::sys::path::append(LibPath, LibSubDir);
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(LibPath.str()));
if (Triple.isOSDarwin())
SearchPathOpts.RuntimeLibraryPaths.push_back(DARWIN_OS_LIBRARY_PATH);