Skip to content

Commit 24dd1cf

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 24dd1cf

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,18 @@ importer::addCommonInvocationArguments(
957957
}
958958
}
959959
}
960+
961+
for (auto &overlay : searchPathOpts.VFSOverlayFiles) {
962+
invocationArgStrs.push_back("-ivfsoverlay");
963+
invocationArgStrs.push_back(overlay);
964+
}
965+
966+
ClangInvocationFileMapping fileMapping =
967+
getClangInvocationFileMapping(ctx, nullptr, /*supressDiagnostic*/true);
968+
if (fileMapping.requiresBuiltinHeadersInSystemModules) {
969+
invocationArgStrs.push_back("-Xclang");
970+
invocationArgStrs.push_back("-fbuiltin-headers-in-system-modules");
971+
}
960972
}
961973

962974
bool ClangImporter::canReadPCH(StringRef PCHFilename) {

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)