Skip to content

Commit 2da65c4

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 632a4d6 + bd97150 commit 2da65c4

File tree

1 file changed

+11
-37
lines changed

1 file changed

+11
-37
lines changed

docs/WindowsBuild.md

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Building Swift on Windows
22

3-
Visual Studio 2017 or newer is needed to build swift on Windows.
3+
Visual Studio 2017 or newer is needed to build swift on Windows. The following must take place in the developer command prompt (provided by Visual Studio). This shows up as "x64 Native Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu.
44

55
## Install dependencies
66
- Install the latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
7-
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation.
7+
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The following components are required:
8+
9+
1. Microsoft.VisualStudio.Component.Windows10SDK
10+
1. Microsoft.VisualStudio.Component.Windows10SDK.17763
11+
1. Microsoft.VisualStudio.Component.VC.Tools.x86.x64
812

913
## Clone the repositories
1014
1. Clone `apple/llvm-project` into a directory for the toolchain
@@ -49,22 +53,6 @@ git clone https://github.com/compnerd/windows-swift windows-swift
4953
┕ usr/...
5054
```
5155

52-
## Get ready
53-
- From within a **NATIVE developer** command prompt (not PowerShell nor cmd, but the [Visual Studio Developer Command Prompt](https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx)), execute the following command if you have an x64 PC (The Native Developer command prompt is situated at "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019.lnk").
54-
55-
Run this as administrator the first time, for setting up the symlinks below.
56-
57-
If instead you're compiling for a 32-bit Windows target, adapt the `arch` argument to `x86` and run
58-
59-
```cmd
60-
VsDevCmd -arch=x86
61-
```
62-
63-
- Decide whether you want to build a release or debug version of Swift on Windows and
64-
replace the `CMAKE_BUILD_TYPE` parameter in the build steps below with the correct value
65-
(`Debug`, `RelWithDebInfoAssert` or `Release`) to avoid conflicts between the debug and
66-
non-debug version of the MSCRT library.
67-
6856
## One-time Setup (re-run on Visual Studio upgrades)
6957
- Set up the `ucrt`, `visualc`, and `WinSDK` modules by copying `ucrt.modulemap` located at
7058
`swift/stdlib/public/Platform/ucrt.modulemap` into
@@ -80,23 +68,14 @@ mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Pla
8068
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.
8169

8270
## Build the toolchain
83-
- This must be done from within a developer command prompt. Make sure that the build type for LLVM/Clang is compatible with the build type for Swift. That is, either build everything `Debug` or some variant of `Release` (e.g. `Release`, `RelWithDebInfo`).
8471

8572
```cmd
8673
md "S:\b\toolchain"
87-
cmake -B "S:\b\toolchain" -G Ninja -S S:\toolchain\llvm -C S:\windows-swift\cmake\caches\Windows-x86_64.cmake -C S:\windows-swift\cmake\caches\org.compnerd.dt.cmake -DLLVM_ENABLE_ASSERTIONS=YES -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;cmark;swift;lldb;lld" -DLLVM_EXTERNAL_PROJECTS="cmark;swift" -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\llvm-project\swift-corelibs-libdispatch -DLLVM_ENABLE_PDB=YES -DLLDB_DISABLE_PYTHON=YES -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_UC="S:/Library/icu-64/usr/lib/icuuc64.lib" -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/Library/icu-64/usr/lib/icuin64.lib" -DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr" -DPYTHON_EXECUTABLE=C:\Python27\python.exe -DSWIFT_BUILD_DYNAMIC_STDLIB=YES -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=YES
74+
cmake -B "S:\b\toolchain" -G Ninja -S S:\toolchain\llvm -C S:\windows-swift\cmake\caches\Windows-x86_64.cmake -C S:\windows-swift\cmake\caches\org.compnerd.dt.cmake -DLLVM_ENABLE_ASSERTIONS=YES -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;cmark;swift;lldb;lld" -DLLVM_EXTERNAL_PROJECTS="cmark;swift" -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\toolchain\swift-corelibs-libdispatch -DLLVM_ENABLE_PDB=YES -DLLDB_DISABLE_PYTHON=YES -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_UC="S:/Library/icu-64/usr/lib/icuuc64.lib" -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/Library/icu-64/usr/lib/icuin64.lib" -DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr" -DPYTHON_EXECUTABLE=C:\Python27\python.exe -DSWIFT_BUILD_DYNAMIC_STDLIB=YES -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=YES
8875
ninja -C S:\b\toolchain
8976
```
9077

91-
- Update your path to include the toolchain.
92-
93-
```cmd
94-
path S:\b\toolchain\bin;%PATH%
95-
```
96-
97-
## Running tests on Windows
98-
99-
Running the testsuite on Windows has additional external dependencies.
78+
## Running Swift tests on Windows
10079

10180
```cmd
10281
path S:\Library\icu-64\usr\bin;S:\b\toolchain\bin;S:\b\toolchain\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
@@ -106,15 +85,10 @@ ninja -C S:\b\toolchain check-swift
10685
## Build swift-corelibs-libdispatch
10786

10887
```cmd
109-
cmake -B S:\b\libdispatch -G Ninja -S S:\toolchain\swift-corelibs-libdispatch -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_Swift_COMPILER=S:\b\toolchain\bin\swiftc.exe -DENABLE_SWIFT=YES
88+
cmake -B S:\b\libdispatch -G Ninja -S S:\toolchain\swift-corelibs-libdispatch -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_Swift_COMPILER=S:/b/toolchain/bin/swiftc.exe -DENABLE_SWIFT=YES
11089
ninja -C S:\b\libdispatch
11190
```
11291

113-
- Add libdispatch to your path:
114-
```cmd
115-
path S:\b\libdispatch;S:\b\libdispatch\src;%PATH%
116-
```
117-
11892
## Test swift-corelibs-libdispatch
11993

12094
```cmd
@@ -237,12 +211,12 @@ cd S:\b\spm
237211
C:\Python27\python.exe S:\swift-package-manager\Utilities\bootstrap --foundation S:\b\foundation --libdispatch-build-dir S:\b\libdispatch --libdispatch-source-dir S:\swift-corelibs-libdispatch --llbuild-build-dir S:\b\llbuild --llbuild-source-dir S:\llbuild --sqlite-build-dir S:\b\sqlite --sqlite-source-dir S:\sqlite-amalgamation-3270200
238212
```
239213

240-
## Install Swift on Windows
214+
## Install the Swift toolchain on Windows
241215

242216
- Run ninja install:
243217

244218
```cmd
245-
ninja -C S:\b\swift install
219+
ninja -C S:\b\toolchain install
246220
```
247221

248222
- Add the Swift on Windows binaries path (`C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin`) to the `PATH` environment variable.

0 commit comments

Comments
 (0)