Skip to content

Commit fc070c6

Browse files
committed
platform: restructure visualc module
Restructure the `visualc` module into `vcruntime` in order to help expose the various components (SAL, vcruntime, ucrt, corecrt, STL) for C++ modularization. Include the `stdint.h` textually to deal with redefinition of types in clang resources and MSVC.
1 parent 15c333b commit fc070c6

File tree

7 files changed

+26
-21
lines changed

7 files changed

+26
-21
lines changed

docs/WindowsBuild.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ Set up the `ucrt`, `visualc`, and `WinSDK` modules by:
102102

103103
- copying `ucrt.modulemap` located at `swift/stdlib/public/Platform/ucrt.modulemap` into
104104
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`
105-
- copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`
105+
- copying `vcruntime.modulemap` located at `swift/stdlib/public/Platform/vcruntime.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`
106106
- copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/${UCRTVersion}/um`
107-
- and setup the `visualc.apinotes` located at `swift/stdlib/public/Platform/visualc.apinotes` into `${VCToolsInstallDir}/include` as `visualc.apinotes`
107+
- and setup the `vcruntime.apinotes` located at `swift/stdlib/public/Platform/vcruntime.apinotes` into `${VCToolsInstallDir}/include` as `vcruntime.apinotes`
108108

109109
```cmd
110110
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\swift\stdlib\public\Platform\ucrt.modulemap
111111
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\swift\stdlib\public\Platform\winsdk.modulemap
112-
mklink "%VCToolsInstallDir%\include\module.modulemap" S:\swift\stdlib\public\Platform\visualc.modulemap
113-
mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Platform\visualc.apinotes
112+
mklink "%VCToolsInstallDir%\include\module.modulemap" S:\swift\stdlib\public\Platform\vcruntime.modulemap
113+
mklink "%VCToolsInstallDir%\include\vcruntime.apinotes" S:\swift\stdlib\public\Platform\vcruntime.apinotes
114114
```
115115

116116
Warning: Creating the above links usually requires administrator privileges. The quick and easy way to do this is to open a second developer prompt by right clicking whatever shortcut you used to open the first one, choosing Run As Administrator, and pasting the above commands into the resulting window. You can then close the privileged prompt; this is the only step which requires elevation.

stdlib/public/Platform/visualc.apinotes renamed to stdlib/public/Platform/vcruntime.apinotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Name: VisualC
2+
Name: vcruntime
33
Functions:
44
- Name: _setjmp
55
Availability: nonswift

stdlib/public/Platform/visualc.modulemap renamed to stdlib/public/Platform/vcruntime.modulemap

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- visualc.modulemap ------------------------------------------------===//
1+
//===--- vcruntime.modulemap ----------------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -84,23 +84,28 @@ module _visualc_intrinsics [system] [extern_c] {
8484
}
8585
}
8686

87-
module visualc [system] {
88-
module SAL {
89-
header "sal.h"
90-
export *
91-
}
87+
module SAL [system] {
88+
header "sal.h"
89+
export *
9290

93-
module vcruntime {
94-
header "vcruntime.h"
91+
module Concurrency {
92+
header "concurrencysal.h"
9593
export *
9694
}
95+
}
96+
97+
module vcruntime [system] {
98+
use SAL
99+
export SAL
100+
101+
header "vcruntime.h"
97102

98103
module setjmp {
99104
header "setjmp.h"
100105
export *
101106
}
102107

103-
module stdint {
108+
explicit module stdint {
104109
header "stdint.h"
105110
export *
106111
}

test/ClangImporter/availability_returns_twice-msvc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-typecheck-verify-swift
22
// REQUIRES: OS=windows-msvc
33

4-
import visualc
4+
import vcruntime
55
typealias JumpBuffer = _JBTYPE
66

77
func test_unavailable_returns_twice_function() {

test/Interop/Cxx/class/Inputs/memory-layout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef TEST_INTEROP_CXX_CLASS_INPUTS_MEMORY_LAYOUT_H
22
#define TEST_INTEROP_CXX_CLASS_INPUTS_MEMORY_LAYOUT_H
33

4-
#include <stddef.h>
5-
#include <stdint.h>
4+
#include <cstddef>
5+
#include <cstdint>
66

77
class PrivateMemberLayout {
88
uint32_t a;

utils/build-windows-toolchain.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ cmake --build "%BuildRoot%\curl" --target install || (exit /b)
181181
:: Prepare system modules
182182
copy /y "%SourceRoot%\swift\stdlib\public\Platform\ucrt.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" || (exit /b)
183183
copy /y "%SourceRoot%\swift\stdlib\public\Platform\winsdk.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" || (exit /b)
184-
copy /y "%SourceRoot%\swift\stdlib\public\Platform\visualc.modulemap" "%VCToolsInstallDir%\include\module.modulemap" || (exit /b)
185-
copy /y "%SourceRoot%\swift\stdlib\public\Platform\visualc.apinotes" "%VCToolsInstallDir%\include\visualc.apinotes" || (exit /b)
184+
copy /y "%SourceRoot%\swift\stdlib\public\Platform\vcruntime.modulemap" "%VCToolsInstallDir%\include\module.modulemap" || (exit /b)
185+
copy /y "%SourceRoot%\swift\stdlib\public\Platform\vcruntime.apinotes" "%VCToolsInstallDir%\include\vcruntime.apinotes" || (exit /b)
186186

187187
:: Build Toolchain
188188
cmake ^

utils/build-windows.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ setlocal enableextensions enabledelayedexpansion
170170

171171
copy /y "%source_root%\swift\stdlib\public\Platform\ucrt.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" %exitOnError%
172172
copy /y "%source_root%\swift\stdlib\public\Platform\winsdk.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" %exitOnError%
173-
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.modulemap" "%VCToolsInstallDir%\include\module.modulemap" %exitOnError%
174-
copy /y "%source_root%\swift\stdlib\public\Platform\visualc.apinotes" "%VCToolsInstallDir%\include\visualc.apinotes" %exitOnError%
173+
copy /y "%source_root%\swift\stdlib\public\Platform\vcruntime.modulemap" "%VCToolsInstallDir%\include\module.modulemap" %exitOnError%
174+
copy /y "%source_root%\swift\stdlib\public\Platform\vcruntime.apinotes" "%VCToolsInstallDir%\include\vcruntime.apinotes" %exitOnError%
175175

176176
goto :eof
177177
endlocal

0 commit comments

Comments
 (0)