Skip to content

Commit be47c97

Browse files
authored
Merge pull request swiftlang#27869 from apple/compnerd-monorepo-windows
Update WindowsBuild.md
2 parents 3ced358 + 1b31094 commit be47c97

File tree

1 file changed

+51
-146
lines changed

1 file changed

+51
-146
lines changed

docs/WindowsBuild.md

Lines changed: 51 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@ Visual Studio 2017 or newer is needed to build swift on Windows.
88
Development|Universal Windows App Development|Windows SDK" in your
99
installation.
1010

11-
## 2. Clone the repositories
12-
1. Configure git to work with Unix file endings (ie `git config --global core.autocrlf false`)
13-
1. Create a folder to contain all the Swift repositories
14-
1. Clone `apple/swift-cmark` into a folder named `cmark`
15-
1. Clone `apple/swift-clang` into a folder named `clang`
16-
1. Clone `apple/swift-llvm` into a folder named `llvm`
17-
1. Clone `apple/swift-compiler-rt` into a folder named `compiler-rt`
18-
1. Clone `apple/swift` into a folder named `swift`
19-
1. Clone `apple/swift-corelibs-libdispatch` into a folder named `swift-corelibs-libdispatch`
20-
1. Clone `apple/swift-corelibs-foundation` into a folder named `swift-corelibs-foundation`
21-
1. Clone `apple/swift-corelibs-xctest` into a folder name `swift-corelibs-xctest`
22-
1. Clone `apple/swift-lldb` into a folder named `lldb`
23-
1. Clone `apple/swift-llbuild` into a folder named `llbuild`
24-
1. Clone `apple/swift-package-manager` info a folder named `swift-package-manager`
11+
## 1. Clone the repositories
12+
1. Clone `apple/llvm-project` into a directory for the toolchain
13+
1. Clone `apple/swift-cmark`, `apple/swift`, `apple/swift-corelibs-libdispatch`, `apple/swift-corelibs-foundation`, `apple/swift-corelibs-xctest`, `apple/swift-llbuild`, `apple/swift-package-manager` into the toolchain directory
14+
1. Clone `compnerd/windows-swift` as a peer of the toolchain directory
2515

2616
- Currently, other repositories in the Swift project have not been tested and may not be supported.
2717

@@ -33,20 +23,18 @@ subst S: <path to sources>
3323

3424
```cmd
3525
S:
36-
git clone https://github.com/apple/swift-cmark cmark
37-
git clone https://github.com/apple/swift-clang clang
38-
git clone https://github.com/apple/swift-llvm llvm
39-
git clone https://github.com/apple/swift-compiler-rt compiler-rt
40-
git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift
41-
git clone https://github.com/apple/swift-corelibs-libdispatch
42-
git clone https://github.com/apple/swift-corelibs-foundation
43-
git clone https://github.com/apple/swift-corelibs-xctest
44-
git clone https://github.com/apple/swift-lldb lldb
45-
git clone https://github.com/apple/swift-llbuild llbuild
46-
git clone -c core.autocrlf=input https://github.com/apple/swift-package-manager
47-
```
48-
49-
## 3. Acquire ICU, SQLite3, curl, libxml2
26+
git clone https://github.com/apple/llvm-project --branch swift/master toolchain
27+
git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift toolchain/swift
28+
git clone https://github.com/apple/swift-cmark toolchain/cmark
29+
git clone https://github.com/apple/swift-corelibs-libdispatch toolchain/swift-corelibs-libdispatch
30+
git clone https://github.com/apple/swift-corelibs-foundation toolchain/swift-corelibs-foundation
31+
git clone https://github.com/apple/swift-corelibs-xctest toolchain/swift-corelibs-xctest
32+
git clone https://github.com/apple/swift-llbuild toolchain/llbuild
33+
git clone -c core.autocrlf=input https://github.com/apple/swift-package-manager toolchain/swift-package-manager
34+
git clone https://github.com/compnerd/windows-swift windows-swift
35+
```
36+
37+
## 1. Acquire ICU, SQLite3, curl, libxml2
5038
1. Go to https://dev.azure.com/compnerd/windows-swift and scroll down to "Dependencies" where you'll see bots (hopefully green) for icu, SQLite, curl, and libxml2. Download each of the zip files and copy their contents into S:/Library. The directory structure should resemble:
5139

5240
```
@@ -58,7 +46,7 @@ S:/Library/
5846
/zlib-1.2.11/usr
5947
```
6048

61-
## 4. Get ready
49+
## 1. Get ready
6250
- 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").
6351

6452
Run this as administrator the first time, for setting up the symlinks below.
@@ -87,114 +75,31 @@ mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Pla
8775

8876
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.
8977

90-
## 5. Build LLVM/Clang
91-
- This must be done from within a developer command prompt. Make sure that the build
92-
type for LLVM/Clang is compatible with the build type for Swift. That is,
93-
either build everything `Debug` or some variant of `Release` (e.g. `Release`,
94-
`RelWithDebInfo`).
95-
```cmd
96-
md "S:\b\llvm"
97-
cd "S:\b\llvm"
98-
cmake -G Ninja^
99-
-DCMAKE_BUILD_TYPE=Release^
100-
-DCMAKE_C_COMPILER=cl^
101-
-DCMAKE_CXX_COMPILER=cl^
102-
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
103-
-DLLVM_ENABLE_ASSERTIONS=ON^
104-
-DLLVM_ENABLE_PDB=YES^
105-
-DLLVM_ENABLE_PROJECTS=clang^
106-
-DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86"^
107-
S:/llvm
108-
ninja
109-
```
110-
111-
- Update your path to include the LLVM tools.
112-
113-
```cmd
114-
path S:\b\llvm\bin;%PATH%
115-
```
116-
## 6. Build CMark
117-
- This must be done from within a developer command prompt.
118-
119-
```cmd
120-
md "S:\b\cmark"
121-
cd "S:\b\cmark"
122-
cmake -G Ninja^
123-
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
124-
-DCMAKE_C_COMPILER=cl^
125-
-DCMAKE_CXX_COMPILER=cl^
126-
S:\cmark
127-
ninja
128-
```
129-
130-
## 7. Build Swift
131-
- This must be done from within a developer command prompt
132-
- Note that Visual Studio vends a 32-bit python 2.7 installation in `C:\Python27` and a 64-bit python in `C:\Python27amd64`. You may use either one based on your installation.
133-
134-
```cmd
135-
md "S:\b\swift"
136-
cd "S:\b\swift"
137-
cmake -G Ninja^
138-
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
139-
-DCMAKE_C_COMPILER=cl^
140-
-DCMAKE_CXX_COMPILER=cl^
141-
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
142-
-DCMAKE_SHARED_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
143-
-DSWIFT_INCLUDE_DOCS=OFF^
144-
-DSWIFT_PATH_TO_CMARK_SOURCE="S:\cmark"^
145-
-DSWIFT_PATH_TO_CMARK_BUILD="S:\b\cmark"^
146-
-DLLVM_DIR=S:\b\llvm\lib\cmake\llvm^
147-
-DClang_DIR=S:\b\llvm\lib\cmake\clang^
148-
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="S:\swift-corelibs-libdispatch"^
149-
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/Library/icu-64/usr/include"^
150-
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:/Library/icu-64/usr/lib/icuuc64.lib"^
151-
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/Library/icu-64/usr/include"^
152-
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/Library/icu-64/usr/lib/icuin64.lib"^
153-
-DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr"^
154-
-DPYTHON_EXECUTABLE=C:\Python27\python.exe^
155-
S:\swift
156-
ninja
157-
```
158-
159-
- To create a Visual Studio project, you'll need to change the generator and,
160-
if you have a 64 bit processor, specify the generator platform. Note that you
161-
may get multiple build errors compiling the `swift` project due to an MSBuild
162-
limitation that file paths cannot exceed 260 characters. These can be
163-
ignored, as they occur after the build when writing the last build status to
164-
a file.
78+
## 1. Build toolchain
79+
- 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`).
16580

16681
```cmd
167-
cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
82+
md "S:\b\toolchain"
83+
cmake -B "S:\b\toolchain" -G Ninja -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" -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
84+
ninja -C S:\b\toolchain
16885
```
16986

170-
## 8. Build lldb
171-
- This must be done from within a developer command prompt.
87+
- Update your path to include the toolchain.
17288

17389
```cmd
174-
md "S:\b\lldb"
175-
cd "S:\b\lldb"
176-
cmake -G Ninja^
177-
-DLLVM_DIR="S:/b/llvm/lib/cmake/llvm"^
178-
-DClang_DIR="S:/b/llvm/lib/cmake/clang"^
179-
-DSwift_DIR="S:/b/swift/lib/cmake/swift"^
180-
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
181-
-DLLDB_USE_STATIC_BINDINGS=YES^
182-
-DLLVM_ENABLE_ASSERTIONS=ON^
183-
-DPYTHON_HOME="%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64"^
184-
S:\lldb
185-
ninja
90+
path S:\b\toolchain\bin;%PATH%
18691
```
18792

188-
## 9. Running tests on Windows
93+
## 1. Running tests on Windows
18994

19095
Running the testsuite on Windows has additional external dependencies.
19196

19297
```cmd
193-
path S:\Library\icu-64\usr\bin;S:\b\swift\bin;S:\b\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
194-
ninja -C S:\b\swift check-swift
98+
path S:\Library\icu-64\usr\bin;S:\b\toolchain\bin;S:\b\toolchain\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
99+
ninja -C S:\b\toolchain check-swift
195100
```
196101

197-
## 10. Build swift-corelibs-libdispatch
102+
## 1. Build swift-corelibs-libdispatch
198103

199104
```cmd
200105
md "S:\b\libdispatch"
@@ -203,10 +108,10 @@ cmake -G Ninja^
203108
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
204109
-DCMAKE_C_COMPILER=clang-cl^
205110
-DCMAKE_CXX_COMPILER=clang-cl^
206-
-DCMAKE_SWIFT_COMPILER=S:\b\swift\bin\swiftc.exe^
111+
-DCMAKE_SWIFT_COMPILER=S:\b\toolchain\bin\swiftc.exe^
207112
-DENABLE_SWIFT=ON^
208113
-DENABLE_TESTING=OFF^
209-
S:\swift-corelibs-libdispatch
114+
S:\toolchain\swift-corelibs-libdispatch
210115
ninja
211116
```
212117

@@ -215,21 +120,21 @@ ninja
215120
path S:\b\libdispatch;S:\b\libdispatch\src;%PATH%
216121
```
217122

218-
## 11. Build swift-corelibs-foundation
123+
## 1. Build swift-corelibs-foundation
219124

220125
```cmd
221126
md "S:\b\foundation"
222127
cd "S:\b\foundation
223128
cmake -G Ninja^
224129
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
225130
-DCMAKE_C_COMPILER=clang-cl^
226-
-DCMAKE_SWIFT_COMPILER=S:\b\swift\bin\swiftc.exe^
227-
-DCURL_LIBRARY="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
228-
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/include"^
131+
-DCMAKE_SWIFT_COMPILER=S:\b\toolchain\bin\swiftc.exe^
132+
-DCURL_LIBRARY="S:/Library/libcurl-development/usr/lib/libcurl.lib"^
133+
-DCURL_INCLUDE_DIR="S:/Library/libcurl-development/usr/include"^
229134
-DENABLE_TESTING=NO^
230135
-DICU_ROOT="S:/Library/icu-64"^
231-
-DLIBXML2_LIBRARY="S:/libxml2/win32/bin.msvc/libxml2_a.lib"^
232-
-DLIBXML2_INCLUDE_DIR="S:/libxml2/include"^
136+
-DLIBXML2_LIBRARY="S:/Library/libxml2-development/usr/lib/libxml2.lib"^
137+
-DLIBXML2_INCLUDE_DIR="S:/Library/libxml2-development/usr/include"^
233138
-DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch^
234139
-DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=S:\b\libdispatch^
235140
S:\swift-corelibs-foundation
@@ -241,15 +146,15 @@ ninja
241146
path S:\b\foundation;%PATH%
242147
```
243148

244-
## 12. Build swift-corelibs-xctest
149+
## 1. Build swift-corelibs-xctest
245150

246151
```cmd
247152
md "S:\b\xctest"
248153
cd "S:\b\xctest"
249154
cmake -G Ninja^
250155
-DBUILD_SHARED_LIBS=YES^
251156
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
252-
-DCMAKE_SWIFT_COMPILER=S:\b\swift\bin\swiftc.exe^
157+
-DCMAKE_SWIFT_COMPILER=S:\b\toolchain\bin\swiftc.exe^
253158
-DXCTEST_PATH_TO_FOUNDATION_BUILD=S:\b\foundation^
254159
-DXCTEST_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch^
255160
-DXCTEST_PATH_TO_LIBDISPATCH_BUILD=S:\b\libdispatch^
@@ -264,41 +169,41 @@ ninja
264169
path S:\b\xctest;%PATH%
265170
```
266171

267-
## 13. Test XCTest
172+
## 1. Test XCTest
268173

269174
```cmd
270175
ninja -C S:\b\xctest check-xctest
271176
```
272177

273-
## 14. Rebuild Foundation
178+
## 1. Rebuild Foundation
274179

275180
```cmd
276181
cd "S:\b\foundation
277182
cmake -G Ninja^
278183
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
279184
-DCMAKE_C_COMPILER=clang-cl^
280-
-DCMAKE_SWIFT_COMPILER=S:\b\swift\bin\swiftc.exe^
281-
-DCURL_LIBRARY="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
282-
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/include"^
185+
-DCMAKE_SWIFT_COMPILER=S:\b\toolchain\bin\swiftc.exe^
186+
-DCURL_LIBRARY="S:/Library/libcurl-development/usr/lib/libcurl.lib"^
187+
-DCURL_INCLUDE_DIR="S:/Library/libcurl-development/usr/include"^
283188
-DENABLE_TESTING=YES^
284189
-DICU_ROOT="S:/Library/icu-64"^
285-
-DLIBXML2_LIBRARY="S:/libxml2/win32/bin.msvc/libxml2_a.lib"^
286-
-DLIBXML2_INCLUDE_DIR="S:/libxml2/include"^
190+
-DLIBXML2_LIBRARY="S:/Library/libxml2-development/usr/lib/libxml2.lib"^
191+
-DLIBXML2_INCLUDE_DIR="S:/Library/libxml2-development/usr/include"^
287192
-DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch^
288193
-DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=S:\b\libdispatch^
289194
-DFOUNDATION_PATH_TO_XCTEST_BUILD=S:\b\xctest^
290195
S:\swift-corelibs-foundation
291196
ninja
292197
```
293198

294-
## 15. Test Foundation
199+
## 1. Test Foundation
295200

296201
```cmd
297202
cmake --build S:\b\foundation
298203
ninja -C S:\b\foundation test
299204
```
300205

301-
## 16. Build llbuild
206+
## 1. Build llbuild
302207

303208
```cmd
304209
md S:\b\llbuild
@@ -311,8 +216,8 @@ cmake -G Ninja^
311216
-DFOUNDATION_BUILD_DIR=S:\b\foundation^
312217
-DLIBDISPATCH_BUILD_DIR=S:\b\libdispatch^
313218
-DLIBDISPATCH_SOURCE_DIR=S:\swift-corelibs-libdispatch^
314-
-DSQLite3_INCLUDE_DIR=S:\sqlite-amalgamation-3270200^
315-
-DSQLite3_LIBRARY=S:\b\sqlite\sqlite3.lib^
219+
-DSQLite3_INCLUDE_DIR=S:\Library\sqlite-3.28.0\usr\include^
220+
-DSQLite3_LIBRARY=S:\Library\sqlite-3.28.0\usr\lib\sqlite3.lib^
316221
-DLLBUILD_SUPPORT_BINDINGS=Swift^
317222
S:\llbuild
318223
ninja
@@ -323,15 +228,15 @@ ninja
323228
path S:\b\llbuild\bin;%PATH%
324229
```
325230

326-
## 17. Build swift-package-manager
231+
## 1. Build swift-package-manager
327232

328233
```cmd
329234
md S:\b\spm
330235
cd S:\b\spm
331236
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
332237
```
333238

334-
## 18. Install Swift on Windows
239+
## 1. Install Swift on Windows
335240

336241
- Run ninja install:
337242

0 commit comments

Comments
 (0)