Skip to content

Commit 3f9160b

Browse files
committed
Propagate vfs overlays and -fbuiltin-headers-in-system-modules
This fixes explicit module builds for a hello world program on Windows as well as the ucrt import build failure as in the included test.
1 parent b852f94 commit 3f9160b

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ importer::addCommonInvocationArguments(
957957
}
958958
}
959959
}
960+
961+
for (auto &overlay : searchPathOpts.VFSOverlayFiles) {
962+
invocationArgStrs.push_back("-ivfsoverlay");
963+
invocationArgStrs.push_back(overlay);
964+
}
960965
}
961966

962967
bool ClangImporter::canReadPCH(StringRef PCHFilename) {

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
138138
clang::tooling::dependencies::DependencyScanningTool &clangScanningTool,
139139
clang::tooling::dependencies::ModuleDepsGraph &clangDependencies,
140140
StringRef moduleOutputPath, RemapPathCallback callback) {
141-
const auto &ctx = Impl.SwiftContext;
141+
auto &ctx = Impl.SwiftContext;
142142
ModuleDependencyVector result;
143143

144144
auto remapPath = [&](StringRef path) {
@@ -201,6 +201,11 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
201201
clangModuleDep.getBuildArguments(),
202202
[&](const std::string &Arg) { clangArgs.push_back(Arg.c_str()); });
203203

204+
ClangInvocationFileMapping fileMapping =
205+
getClangInvocationFileMapping(ctx, nullptr, /*supressDiagnostic*/true);
206+
if (fileMapping.requiresBuiltinHeadersInSystemModules)
207+
clangArgs.push_back("-fbuiltin-headers-in-system-modules");
208+
204209
bool success = clang::CompilerInvocation::CreateFromArgs(
205210
depsInvocation, clangArgs, clangDiags);
206211
(void)success;

test/ScanDependencies/win-crt.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -scan-dependencies -Xcc -v %s -o - | %validate-json | %FileCheck %s
3+
4+
// We want to explicitly import WinSDK's CRT.
5+
// REQUIRES: OS=windows-msvc
6+
7+
import CRT
8+
9+
// CHECK: "modulePath": "{{.*}}\\ucrt-{{.*}}.pcm",
10+
// CHECK-NEXT: "sourceFiles": [
11+
// CHECK-NEXT: "{{.*}}\\ucrt\\module.modulemap"

0 commit comments

Comments
 (0)