Skip to content

Commit d51e1bc

Browse files
committed
Runtimes: inject Windows SDK clang modules
When building the standard library, the SDK is not fully staged and so the compiler would not be able to inject the VFS overlay for the modularisation of the Windows SDK. Manually construct the mappings and apply them.
1 parent 433ff59 commit d51e1bc

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

Runtimes/Overlay/Windows/CRT/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target_compile_definitions(swiftCRT PRIVATE
1414
target_compile_options(swiftCRT PRIVATE
1515
"SHELL:-Xcc -D_USE_MATH_DEFINES")
1616
target_link_libraries(swiftCRT PRIVATE
17+
ClangModules
1718
swiftCore)
1819

1920
install(TARGETS swiftCRT

Runtimes/Overlay/Windows/WinSDK/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set_target_properties(swiftWinSDK PROPERTIES
66
target_compile_definitions(swiftCRT PRIVATE
77
$<$<BOOL:${SwiftOverlay_ENABLE_REFLECTION}>:SWIFT_ENABLE_REFLECTION>)
88
target_link_libraries(swiftWinSDK PRIVATE
9+
ClangModules
910
swiftCore)
1011

1112
install(TARGETS swiftWinSDK

Runtimes/Overlay/Windows/clang/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
11

2+
file(TO_CMAKE_PATH "$ENV{WindowsSdkDir}" WindowsSdkDir)
3+
file(TO_CMAKE_PATH "$ENV{WindowsSDKVersion}" WindowsSDKVersion)
4+
file(TO_CMAKE_PATH "$ENV{UniversalCRTSdkDir}" UniversalCRTSdkDir)
5+
file(TO_CMAKE_PATH "$ENV{UCRTVersion}" UCRTVersion)
6+
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" VCToolsInstallDir)
7+
8+
file(CONFIGURE
9+
OUTPUT windows-sdk-overlay.yaml
10+
CONTENT [[
11+
---
12+
version: 0
13+
case-sensitive: false
14+
use-external-names: false
15+
roots:
16+
- name: "@WindowsSdkDir@/Include/@WindowsSDKVersion@/um"
17+
type: directory
18+
contents:
19+
- name: module.modulemap
20+
type: file
21+
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/winsdk.modulemap"
22+
- name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/ucrt"
23+
type: directory
24+
contents:
25+
- name: module.modulemap
26+
type: file
27+
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/ucrt.modulemap"
28+
- name: "@VCToolsInstallDir@include"
29+
type: directory
30+
contents:
31+
- name: module.modulemap
32+
type: file
33+
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/vcruntime.modulemap"
34+
- name: vcruntime.apinotes
35+
type: file
36+
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/vcruntime.apinotes"
37+
]]
38+
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
39+
40+
add_library(ClangModules INTERFACE)
41+
target_compile_options(ClangModules INTERFACE
42+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-vfsoverlay ${CMAKE_CURRENT_BINARY_DIR}/windows-sdk-overlay.yaml>")
43+
244
install(FILES
345
ucrt.modulemap
446
vcruntime.apinotes

Runtimes/Overlay/clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set_target_properties(swift_Builtin_float PROPERTIES
99
target_compile_options(swift_Builtin_float PRIVATE
1010
"$<$<PLATFORM_ID:Darwin>:SHELL:-Xfrontend -module-abi-name -Xfrontend Darwin>")
1111
target_link_libraries(swift_Builtin_float PRIVATE
12+
$<$<PLATFORM_ID:Windows>:ClangModules>
1213
swiftCore)
1314

1415
install(TARGETS swift_Builtin_float

0 commit comments

Comments
 (0)