Skip to content

Commit b1dcf73

Browse files
authored
Update Windows.md
Update the cmake configuration to actually reflect the current state of the world. This now builds against the MSVC built LLVM/clang and builds with clang-cl. This also enables building the test suite since that is starting to work on Windows. The MSVC commands are still out of date, but this is an overall improvement to the instructions. Since the primary work shifted towards Windows x86_64, we can use the prebuilt binaries for ICU from the ICU project as they provide Windows x86_64 builds.
1 parent 3376f9f commit b1dcf73

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

docs/WindowsBuild.md

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ There are two supported ways to build Swift on Windows, they are
1010
1. Using the Microsoft Visual C++ compiler (MSVC)
1111

1212
`clang-cl` is recommended over MSVC for building Swift on Windows.
13+
1314
Although it is possible to build the compiler and the standard library with
1415
MSVC and to use those built products to compile a Swift program, it won't be
1516
possible to run the binary without separately obtaining the Swift runtime. On
@@ -39,17 +40,9 @@ it provides some of the needed headers and libraries.
3940
- Currently, other repositories in the Swift project have not been tested and
4041
may not be supported.
4142

42-
### 3. Build ICU
43-
1. Download and extract the [ICU source
44-
code](http://site.icu-project.org/download) to a folder named `icu` in the same
45-
directory as the other Swift project repositories (tested with ICU versions 55.1 and 59.1).
46-
1. Open `src/win32/allinone.sln` in Visual Studio.
47-
1. Make sure to select the correct architecture from the drop-down in Visual
48-
Studio.
49-
1. Right click on the solution in the Solution Explorer window and select
50-
"Build Solution".
51-
1. When this is done, add the `<icu-source>/bin` folder to your `Path`
52-
environment variable.
43+
### 3. Acquire ICU
44+
1. Download ICU from [ICU Project](http://site.icu-project.org) for Windows x64 and extract the binaries.
45+
1. Add the `bin64` folder to your `Path` environment variable.
5346

5447
### 4. Get ready
5548
- From within a **developer** command prompt (not PowerShell nor cmd, but [the
@@ -103,10 +96,7 @@ pushd "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
10396
cmake -G "Ninja"^
10497
-DLLVM_ENABLE_ASSERTIONS=TRUE^
10598
-DCMAKE_BUILD_TYPE=Debug^
106-
-DLLVM_TOOL_SWIFT_BUILD=NO^
107-
-DLLVM_INCLUDE_DOCS=TRUE^
10899
-DLLVM_ENABLE_PROJECTS=clang^
109-
-DLLVM_LIT_ARGS=-sv^
110100
-DLLVM_TARGETS_TO_BUILD=X86^
111101
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
112102
"%swift_source_dir%/llvm"
@@ -131,29 +121,25 @@ mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
131121
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
132122
cmake -G "Ninja"^
133123
-DCMAKE_BUILD_TYPE=Debug^
134-
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
135-
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
136-
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64/src"^
137-
-DSWIFT_PATH_TO_LLVM_SOURCE="%swift_source_dir%/llvm"^
138-
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
139-
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
140-
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
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"^
145-
-DSWIFT_INCLUDE_DOCS=FALSE^
146-
-DSWIFT_INCLUDE_TESTS=FALSE^
147124
-DCMAKE_C_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
148125
-DCMAKE_CXX_COMPILER="%llvm_bin_dir%/clang-cl.exe"^
149-
-DCMAKE_C_FLAGS="/Z7"^
150-
-DCMAKE_CXX_FLAGS="/Z7 -Wno-c++98-compat -Wno-c++98-compat-pedantic"^
126+
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
127+
-DCMAKE_CXX_FLAGS="-Wno-c++98-compat -Wno-c++98-compat-pedantic"^
151128
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
152-
-DCMAKE_MODULE_LINKER_FLAGS="/INCREMENTAL:NO"^
153129
-DCMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO"^
154-
-DCMAKE_STATIC_LINKER_FLAGS="/INCREMENTAL:NO"^
130+
-DSWIFT_INCLUDE_DOCS=NO^
131+
-DSWIFT_PATH_TO_LLVM_SOURCE="%swift_source_dir%/llvm"^
132+
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/clang"^
133+
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="%swift_source_dir%/swift-corelibs-libdispatch"^
134+
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
135+
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
136+
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
137+
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="%swift_source_dir%/icu/include"^
138+
-DSWIFT_WINDOWS_x86_64_ICU_UC="%swift_source_dir%/icu/lib64/icuuc.lib"^
139+
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="%swift_source_dir%/icu/include"^
140+
-DSWIFT_WINDOWS_x86_64_ICU_I18N="%swift_source_dir%/icu/lib64/icuin.lib"^
155141
-DCMAKE_INSTALL_PREFIX="C:/Program Files (x86)/Swift"^
156-
"%swift_source_dir%/swift"
142+
"%swift_source_dir%/swift"
157143
popd
158144
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
159145
```

0 commit comments

Comments
 (0)