Skip to content

Commit d81ce19

Browse files
committed
[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
1 parent c7da857 commit d81ce19

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,35 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
198198
if (LangOpts.hasFeature(Feature::Embedded))
199199
LibSubDir = "embedded";
200200

201-
llvm::sys::path::append(LibPath, LibSubDir);
202201
SearchPathOpts.RuntimeLibraryPaths.clear();
202+
203+
#if defined(_WIN32)
204+
// Resource path looks like this:
205+
//
206+
// C:\...\Swift\Toolchains\6.0.0+Asserts\usr\lib\swift
207+
//
208+
// The runtimes are in
209+
//
210+
// C:\...\Swift\Runtimes\6.0.0\usr\bin
211+
//
212+
llvm::SmallString<128> RuntimePath(LibPath);
213+
214+
llvm::sys::path::remove_filename(RuntimePath);
215+
llvm::sys::path::remove_filename(RuntimePath);
216+
llvm::sys::path::remove_filename(RuntimePath);
217+
218+
llvm::SmallString<128> VersionWithAttrs(llvm::sys::path::filename(RuntimePath));
219+
size_t MaybePlus = VersionWithAttrs.find_first_of('+');
220+
StringRef Version = VersionWithAttrs.substr(0, MaybePlus);
221+
222+
llvm::sys::path::remove_filename(RuntimePath);
223+
llvm::sys::path::remove_filename(RuntimePath);
224+
llvm::sys::path::append(RuntimePath, "Runtimes", Version, "usr", "bin");
225+
226+
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(RuntimePath.str()));
227+
#endif
228+
229+
llvm::sys::path::append(LibPath, LibSubDir);
203230
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(LibPath.str()));
204231
if (Triple.isOSDarwin())
205232
SearchPathOpts.RuntimeLibraryPaths.push_back(DARWIN_OS_LIBRARY_PATH);

0 commit comments

Comments
 (0)