Skip to content

Commit 0404200

Browse files
committed
Propagate vfs overlays and sdk to subinvocations
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 0404200

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
185185
swiftArgs.push_back("-vfsoverlay");
186186
swiftArgs.push_back(remapPath(overlay));
187187
}
188+
189+
// Pass along the SDK path
190+
StringRef SDKPath = ctx.SearchPathOpts.getSDKPath();
191+
if (!SDKPath.empty()) {
192+
swiftArgs.push_back("-sdk");
193+
swiftArgs.push_back(SDKPath.str());
194+
}
188195
}
189196

190197
// Add args reported by the scanner.

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)