Skip to content

Commit 70bb9fe

Browse files
authored
Merge pull request #20864 from apple/windows-requirements-update
2 parents c9cf8fc + a9c68c1 commit 70bb9fe

File tree

1 file changed

+25
-42
lines changed

1 file changed

+25
-42
lines changed

docs/WindowsBuild.md

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,16 @@ the other hand, `clang-cl` is able to build the runtime, which makes it
1717
possible to build and run all the components required for Swift natively on
1818
Windows.
1919

20+
clang should be 7.0 or newer. Visual Studio 2017 is needed in all cases as
21+
it provides some of the needed headers and libraries.
22+
2023
## `clang-cl`
21-
- Windows doesn't currently have a build script. You'll need to run commands
22-
manually to build Swift on Windows.
23-
- Windows support for Swift is a work in progress and may not work on your
24-
system, but it has been tested.
25-
- Using the latest Visual Studio version is recommended (tested with Visual
26-
Studio 2017 - Version 15.5.5). Swift may fail to build with older C++
27-
compilers.
28-
- Note that the release version of Swift on Windows may crash when you try to compile a
29-
Swift program. See bug report [SR-7867](https://bugs.swift.org/browse/SR-7867).
3024

3125
### 1. Install dependencies
32-
1. Latest version (2.7.12 tested) of [Python
33-
2](https://www.python.org/downloads/)
34-
1. Latest version (3.7.0-rc3 tested) of [CMake](https://cmake.org/download/)
35-
1. Latest version (1.7.1 tested) of
36-
[Ninja](https://github.com/ninja-build/ninja/releases/latest)
37-
1. Latest version (2015 Update 3 tested) of [Visual
38-
Studio](https://www.visualstudio.com/downloads/)
26+
1. Latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
3927
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web
4028
Development|Universal Windows App Development|Windows SDK" in your
4129
installation.
42-
- Make sure to add Python, CMake and Ninja to your `Path` environment variable
4330

4431
### 2. Clone the repositories
4532
1. Create a folder to contain all the Swift repositories
@@ -48,6 +35,7 @@ Windows.
4835
1. Clone `apple/swift-llvm` into a folder named `llvm`
4936
1. Clone `apple/swift-compiler-rt` into a folder named `compiler-rt`
5037
1. Clone `apple/swift` into a folder named `swift`
38+
1. Clone `apple/swift-corelibs-libdispatch` into a folder named `swift-corelibs-libdispatch`
5139
- Currently, other repositories in the Swift project have not been tested and
5240
may not be supported.
5341

@@ -89,11 +77,9 @@ set swift_source_dir=path-to-directory-containing-all-cloned-repositories
8977
(`Debug`, `RelWithDebInfoAssert` or `Release`) to avoid conflicts between the debug and
9078
non-debug version of the MSCRT library.
9179

92-
- Set up the `visualc` and `ucrt` modules by copying `ucrt.modulemap` located at
80+
- Set up the `ucrt`, `visualc`, and `WinSDK` modules by copying `ucrt.modulemap` located at
9381
`swift/stdlib/public/Platform/ucrt.modulemap` into
94-
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap` and copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`
95-
96-
82+
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`, copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`, and copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/10.0.107663/um`
9783

9884
### 5. Build CMark
9985
- This must be done from within a developer command prompt. CMark is a fairly
@@ -143,7 +129,7 @@ set llvm_bin_dir="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64/
143129
```cmd
144130
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
145131
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
146-
cmake -G "Ninja" "%swift_source_dir%/swift"^
132+
cmake -G "Ninja"^
147133
-DCMAKE_BUILD_TYPE=Debug^
148134
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
149135
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
@@ -152,24 +138,22 @@ cmake -G "Ninja" "%swift_source_dir%/swift"^
152138
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
153139
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
154140
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
155-
-DICU_UC_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
156-
-DICU_UC_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
157-
-DICU_I18N_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
158-
-DICU_I18N_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
159-
-DICU_UC_LIB_NAME="icuuc"^
160-
-DICU_I18N_LIB_NAME="icuin"^
141+
-DICU_WINDOWS_x86_64_UC_INCLUDE="%swift_source_dir%/icu/include"^
142+
-DICU_WINDOWS_x86_64_UC_LIBRARY="%swift_source_dir%/icu/lib64/icuuc.lib"^
143+
-DICU_WINDOWS_x86_64_I18N_INCLUDE="%swift_source_dir%/icu/include"^
144+
-DICU_WINDOWS_x86_64_I18N_LIBRARY="%swift_source_dir%/icu/lib64/icuin.lib"^
161145
-DSWIFT_INCLUDE_DOCS=FALSE^
162146
-DSWIFT_INCLUDE_TESTS=FALSE^
163147
-DCMAKE_C_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
164148
-DCMAKE_CXX_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
165-
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
166-
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7"^
149+
-DCMAKE_C_FLAGS="/Z7"^
150+
-DCMAKE_CXX_FLAGS="/Z7 -Wno-c++98-compat -Wno-c++98-compat-pedantic"^
167151
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
168152
-DCMAKE_MODULE_LINKER_FLAGS="/INCREMENTAL:NO"^
169153
-DCMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO"^
170154
-DCMAKE_STATIC_LINKER_FLAGS="/INCREMENTAL:NO"^
171155
-DCMAKE_INSTALL_PREFIX="C:/Program Files (x86)/Swift"^
172-
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
156+
"%swift_source_dir%/swift"
173157
popd
174158
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
175159
```
@@ -182,7 +166,7 @@ cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
182166
a file.
183167

184168
```cmd
185-
cmake -G "Visual Studio 15" "%swift_source_dir%/swift"^
169+
cmake -G "Visual Studio 2017" "%swift_source_dir%/swift"^
186170
-DCMAKE_GENERATOR_PLATFORM="x64"^
187171
...
188172
```
@@ -205,8 +189,8 @@ cmake -G "Ninja" "%swift_source_dir%/lldb"^
205189
-DLLDB_PATH_TO_SWIFT_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"^
206190
-DCMAKE_C_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
207191
-DCMAKE_CXX_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
208-
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
209-
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7 -Wno-c++98-compat"^
192+
-DCMAKE_C_FLAGS="/Z7"^
193+
-DCMAKE_CXX_FLAGS="/Z7 -Wno-c++98-compat"^
210194
-DLLVM_ENABLE_ASSERTIONS=YES
211195
popd
212196
cmake --build "%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/lldb-windows-amd64"
@@ -232,7 +216,7 @@ Follow instructions 1-6 for `clang-cl`, but run the following instead to build S
232216
```cmd
233217
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
234218
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
235-
cmake -G "Ninja" "%swift_source_dir%/swift"^
219+
cmake -G "Ninja"^
236220
-DCMAKE_BUILD_TYPE=Debug^
237221
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
238222
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
@@ -241,16 +225,15 @@ cmake -G "Ninja" "%swift_source_dir%/swift"^
241225
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
242226
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
243227
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
244-
-DICU_UC_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
245-
-DICU_UC_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
246-
-DICU_I18N_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
247-
-DICU_I18N_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
248-
-DICU_UC_LIB_NAME="icuuc"^
249-
-DICU_I18N_LIB_NAME="icuin"^
228+
-DICU_WINDOWS_x86_64_UC_INCLUDE="%swift_source_dir%/icu/include"^
229+
-DICU_WINDOWS_x86_64_UC_LIBRARY="%swift_source_dir%/icu/lib64/icuuc.lib"^
230+
-DICU_WINDOWS_x86_64_I18N_INCLUDE="%swift_source_dir%/icu/include"^
231+
-DICU_WINDOWS_x86_64_I18N_LIBRARY="%swift_source_dir%/icu/lib64/icuin.lib"^
250232
-DSWIFT_INCLUDE_DOCS=FALSE^
251233
-DSWIFT_INCLUDE_TESTS=FALSE^
252234
-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE^
253-
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
235+
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE^
236+
"%swift_source_dir%/swift"
254237
popd
255238
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
256239
```

0 commit comments

Comments
 (0)