Skip to content

Commit 745543a

Browse files
authored
Several minor fixes to Windows build instructions
- Fix minor typos - Add missing `git clone` for LLDB - Fix inconsistent/missing quotes in code blocks - A few other consistency fixups - `SWIFT_PATH_TO_LIBDISPATCH_SOURCE` is only used on Linux - Use `-A` and `-T` with modern CMake instead of `-DCMAKE_GENERATOR_PLATFORM` - Add missing info on `libcurl` and `libxml2` requirements for `swift-corelibs-foundation`
1 parent 5aebae0 commit 745543a

File tree

1 file changed

+43
-30
lines changed

1 file changed

+43
-30
lines changed

docs/WindowsBuild.md

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes how to build Swift for Windows natively. See [the
44
Windows doc](./Windows.md) for more about what is possible with Swift on
55
Windows.
66

7-
There are two supported ways to build Swift on Windows, they are
7+
There are two supported ways to build Swift on Windows:
88

99
1. Using [`clang-cl`](https://clang.llvm.org/docs/UsersManual.html#clang-cl)
1010
1. Using the Microsoft Visual C++ compiler (MSVC)
@@ -38,12 +38,13 @@ it provides some of the needed headers and libraries.
3838
1. Clone `apple/swift-compiler-rt` into a folder named `compiler-rt`
3939
1. Clone `apple/swift` into a folder named `swift`
4040
1. Clone `apple/swift-corelibs-libdispatch` into a folder named `swift-corelibs-libdispatch`
41-
1. Clone `apple/swift-corelibs-foundation` into a folder name `swift-corelibs-foundation`
41+
1. Clone `apple/swift-corelibs-foundation` into a folder named `swift-corelibs-foundation`
42+
1. Clone `apple/swift-lldb` into a folder named `lldb`
4243

4344
- Currently, other repositories in the Swift project have not been tested and
4445
may not be supported.
4546

46-
If your sources live else where, you can create a substitution for this:
47+
This guide assumes your sources live at the root of `S:`. If your sources live elsewhere, you can create a substitution for this:
4748

4849
```cmd
4950
subst S: <path to sources>
@@ -59,12 +60,17 @@ git clone https://github.com/apple/swift-compiler-rt compiler-rt
5960
git clone https://github.com/apple/swift
6061
git clone https://github.com/apple/swift-corelibs-libdispatch
6162
git clone https://github.com/apple/swift-corelibs-foundation
63+
git clone https://github.com/apple/swift-lldb lldb
6264
```
6365

6466
### 3. Acquire ICU
6567
1. Download ICU from [ICU Project](http://site.icu-project.org) for Windows x64 and extract the binaries.
6668
1. Add the `bin64` folder to your `Path` environment variable.
6769

70+
```cmd
71+
PATH S:\icu\bin64;%PATH%
72+
```
73+
6874
### 4. Get ready
6975
- From within a **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.
7076

@@ -89,22 +95,24 @@ VsDevCmd -arch=x86
8995

9096
```cmd
9197
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\swift\stdlib\public\Platform\ucrt.modulemap
98+
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\swift\stdlib\public\Platform\winsdk.modulemap
9299
mklink "%VCToolsInstallDir%\include\module.modulemap" S:\swift\stdlib\public\Platform\visualc.modulemap
93100
mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Platform\visualc.apinotes
94-
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\swift\stdlib\public\Platform\winsdk.modulemap
95101
```
96102

103+
Warning: Creating the above links usually requires adminstrator 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.
104+
97105
### 5. Build CMark
98106
- This must be done from within a developer command prompt. CMark is a fairly
99107
small project and should only take a few minutes to build.
100108
```cmd
101-
mkdir S:\build\Ninja-DebugAssert\cmark-windows-amd64"
102-
pushd S:\build\Ninja-DebugAssert\cmark-windows-amd64" "S:\cmark"
109+
mkdir "S:\build\Ninja-DebugAssert\cmark-windows-amd64"
110+
pushd "S:\build\Ninja-DebugAssert\cmark-windows-amd64"
103111
cmake -G Ninja^
104112
-DCMAKE_BUILD_TYPE=Debug^
105113
-DCMAKE_C_COMPILER=cl^
106114
-DCMAKE_CXX_COMPILER=cl^
107-
S:\cmark
115+
S:/cmark
108116
popd
109117
cmake --build "S:\build\Ninja-DebugAssert\cmark-windows-amd64"
110118
```
@@ -117,23 +125,23 @@ cmake --build "S:\build\Ninja-DebugAssert\cmark-windows-amd64"
117125
```cmd
118126
mkdir "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
119127
pushd "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
120-
cmake -G "Ninja"^
128+
cmake -G Ninja^
121129
-DCMAKE_BUILD_TYPE=Debug^
122130
-DCMAKE_C_COMPILER=cl^
123131
-DCMAKE_CXX_COMPILER=cl^
124132
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
125-
-DLLVM_ENABLE_ASSERTIONS=TRUE^
133+
-DLLVM_ENABLE_ASSERTIONS=ON^
126134
-DLLVM_ENABLE_PROJECTS=clang^
127135
-DLLVM_TARGETS_TO_BUILD=X86^
128-
"S:\llvm"
136+
S:/llvm
129137
popd
130138
cmake --build "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
131139
```
132140

133141
- Update your path to include the LLVM tools.
134142

135143
```cmd
136-
set PATH=S:\build\Ninja-DebugAssert\llvm-windows-amd64\bin;%PATH%
144+
PATH S:\build\Ninja-DebugAssert\llvm-windows-amd64\bin;%PATH%
137145
```
138146

139147
### 7. Build Swift
@@ -144,27 +152,26 @@ set PATH=S:\build\Ninja-DebugAssert\llvm-windows-amd64\bin;%PATH%
144152
```cmd
145153
mkdir "S:\build\Ninja-DebugAssert\swift-windows-amd64"
146154
pushd "S:\build\inja-DebugAssert\swift-windows-amd64"
147-
cmake -G "Ninja"^
155+
cmake -G Ninja^
148156
-DCMAKE_BUILD_TYPE=Debug^
149157
-DCMAKE_C_COMPILER=clang-cl^
150158
-DCMAKE_CXX_COMPILER=clang-cl^
151-
-DSWIFT_PATH_TO_CMARK_SOURCE="S:\cmark"^
152-
-DCMAKE_CXX_FLAGS="-Wno-c++98-compat -Wno-c++98-compat-pedantic"^
159+
-DCMAKE_CXX_FLAGS:STRING="-Wno-c++98-compat -Wno-c++98-compat-pedantic"^
153160
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
154-
-DCMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO"^
155-
-DSWIFT_INCLUDE_DOCS=NO^
161+
-DCMAKE_SHARED_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
162+
-DSWIFT_INCLUDE_DOCS=OFF^
163+
-DSWIFT_PATH_TO_CMARK_SOURCE="S:\cmark"^
164+
-DSWIFT_PATH_TO_CMARK_BUILD="S:\build\Ninja-DebugAssert\cmark-windows-amd64"^
156165
-DSWIFT_PATH_TO_LLVM_SOURCE="S:\llvm"^
157-
-DSWIFT_PATH_TO_CLANG_SOURCE="S:\clang"^
158-
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="S:\swift-corelibs-libdispatch"^
159166
-DSWIFT_PATH_TO_LLVM_BUILD="S:\build\Ninja-DebugAssert\llvm-windows-amd64"^
167+
-DSWIFT_PATH_TO_CLANG_SOURCE="S:\clang"^
160168
-DSWIFT_PATH_TO_CLANG_BUILD="S:\build\Ninja-DebugAssert\llvm-windows-amd64"^
161-
-DSWIFT_PATH_TO_CMARK_BUILD="S:\build\Ninja-DebugAssert\cmark-windows-amd64"^
162169
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:\icu\include"^
163170
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:\icu\lib64\icuuc.lib"^
164171
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:\icu\include"^
165172
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:\icu\lib64\icuin.lib"^
166173
-DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr"^
167-
"S:\swift"
174+
S:/swift
168175
popd
169176
cmake --build "S:\build\Ninja-DebugAssert\swift-windows-amd64"
170177
```
@@ -177,7 +184,7 @@ cmake --build "S:\build\Ninja-DebugAssert\swift-windows-amd64"
177184
a file.
178185

179186
```cmd
180-
cmake -G "Visual Studio 2017" -DCMAKE_GENERATOR_PLATFORM="x64"^ ...
187+
cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
181188
```
182189

183190
### 8. Build lldb
@@ -186,7 +193,7 @@ cmake -G "Visual Studio 2017" -DCMAKE_GENERATOR_PLATFORM="x64"^ ...
186193
```cmd
187194
mkdir "S:/build/Ninja-DebugAssert/lldb-windows-amd64"
188195
pushd "S:/build/Ninja-DebugAssert/lldb-windows-amd64"
189-
cmake -G "Ninja" "S:/lldb"^
196+
cmake -G Ninja
190197
-DCMAKE_BUILD_TYPE=Debug^
191198
-DLLDB_PATH_TO_CMARK_SOURCE="S:/cmark"^
192199
-DLLDB_PATH_TO_LLVM_SOURCE="S:/llvm"^
@@ -196,7 +203,8 @@ cmake -G "Ninja" "S:/lldb"^
196203
-DLLDB_PATH_TO_CLANG_BUILD="S:/build/Ninja-DebugAssert/llvm-windows-amd64"^
197204
-DLLDB_PATH_TO_LLVM_BUILD="S:/build/Ninja-DebugAssert/llvm-windows-amd64"^
198205
-DLLDB_PATH_TO_SWIFT_BUILD="S:/build/Ninja-DebugAssert/swift-windows-amd64"^
199-
-DLLVM_ENABLE_ASSERTIONS=YES
206+
-DLLVM_ENABLE_ASSERTIONS=ON^
207+
S:/lldb
200208
popd
201209
cmake --build "S:/build/Ninja-DebugAssert/lldb-windows-amd64"
202210
```
@@ -221,36 +229,41 @@ ninja -C "S:/build/Ninja-DebugAssert/swift-windows-amd64" check-swift
221229
```cmd
222230
mkdir "S:/build/Ninja-DebugAssert/swift-corelibs-libdispatch-windows-amd64"
223231
pushd "S:/build/Ninja-DebugAssert/swift-corelibs-libdispatch-windows-amd64"
224-
cmake -G "Ninja"^
232+
cmake -G Ninja^
225233
-DCMAKE_BUILD_TYPE=Debug^
226234
-DCMAKE_C_COMPILER="S:/build/Ninja-DebugAssert/llvm-windows-amd64/bin/clang-cl.exe"^
227235
-DCMAKE_CXX_COMPILER="S:/build/Ninja-DebugAssert/llvm-windows-amd64/bin/clang-cl.exe"^
228236
-DCMAKE_SWIFT_COMPILER="S:/build/Ninja-DebugAssert/swift-windows-amd64/bin/swiftc.exe"^
229237
-DSwift_DIR="S:/build/Ninja-DebugAssert/swift-windows-amd64/lib/cmake/swift"^
230-
-DENABLE_SWIFT=YES^
231-
-DENABLE_TESTING=NO^
238+
-DENABLE_SWIFT=ON^
239+
-DENABLE_TESTING=OFF^
232240
S:/swift-corelibs-libdispatch
233241
popd
234242
cmake --build
235243
```
236244

237245
### 11. Build swift-corelibs-foundation
238246

247+
To build Foundation you will need builds of:
248+
249+
- `libxml2` (http://xmlsoft.org, download and unzip the Windows prebuilt or build your own)
250+
- `libcurl` (https://curl.haxx.se, download the source, `cd` into `winbuild`, and run `nmake /f Makefile.vc mode=static VC=15 MACHINE=x64`)
251+
239252
```cmd
240253
mkdir "S:/build/Ninja-DebugAssert/swift-corelibs-foundation-windows-amd64"
241254
pushd "S:/build/Ninja-DebugAssert/swift-corelibs-foundation-windows-amd64"
242-
cmake -G "Ninja"^
255+
cmake -G Ninja^
243256
-DCMAKE_BUILD_TYPE=Debug^
244257
-DCMAKE_C_COMPILER="S:/build/Ninja-DebugAssert/llvm-windows-amd64/bin/clang-cl.exe"^
245258
-DCMAKE_SWIFT_COMPILER="S:/build/Ninja-DebugAssert/swift-windows-amd64/bin/swiftc.exe"^
246-
-DCURL_LIBRARY="S:/curl/builds/libcurl-VS15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
247-
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-VS15-x64-release-static-ipv6-sspi-winssl/include"^
259+
-DCURL_LIBRARY="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
260+
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/include"^
248261
-DICU_ROOT="S:/thirdparty/icu4c-63_1-Win64-MSVC2017"^
249262
-DLIBXML2_LIBRARY="S:/libxml2/win32/bin.msvc/libxml2_a.lib"^
250263
-DLIBXML2_INCLUDE_DIR="S:/libxml2/include"^
251264
-DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE="S:/swift-corelibs-libdispatch"^
252265
-DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD="S:/build/Ninja-DebugAssert/swift-corelibs-libdispatch-windows-amd64"^
253-
"S:/swift-corelibs-foundation"
266+
S:/swift-corelibs-foundation
254267
cmake --build "S:/build/Ninja-DebugAssert/swift-corelibs-foundation-windows-amd64"
255268
256269
```

0 commit comments

Comments
 (0)