mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix direct clang cc1 emit-pcm commands with vfs overlay on Windows (#85325)
Explicit module builds currently fail on Windows because direct-clang-cc1-module-build emit-pcm commands take overlaid system module map files as inputs but miss the clang VFS overlay. This change adds the overlay and fixes explicit module builds on Windows.
This commit is contained in:
@@ -711,6 +711,25 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
|
||||
new llvm::vfs::OverlayFileSystem(MemFS);
|
||||
OverlayVFS->pushOverlay(SourceMgr.getFileSystem());
|
||||
SourceMgr.setFileSystem(std::move(OverlayVFS));
|
||||
} else {
|
||||
// For non-caching -direct-clang-cc1-module-build emit-pcm build,
|
||||
// setup the clang VFS so it can find system modulemap files
|
||||
// (like vcruntime.modulemap) as an input file.
|
||||
if (Invocation.getClangImporterOptions().DirectClangCC1ModuleBuild &&
|
||||
Invocation.getFrontendOptions().RequestedAction ==
|
||||
FrontendOptions::ActionType::EmitPCM) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
|
||||
SourceMgr.getFileSystem();
|
||||
ClangInvocationFileMappingContext Context(
|
||||
Invocation.getLangOptions(), Invocation.getSearchPathOptions(),
|
||||
Invocation.getClangImporterOptions(), Invocation.getCASOptions(),
|
||||
Diagnostics);
|
||||
ClangInvocationFileMapping FileMapping = applyClangInvocationMapping(
|
||||
Context, nullptr, VFS, /*suppressDiagnostic=*/false);
|
||||
if (!FileMapping.redirectedFiles.empty()) {
|
||||
SourceMgr.setFileSystem(std::move(VFS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto ExpectedOverlay =
|
||||
|
||||
Reference in New Issue
Block a user