Skip to content

Commit c234759

Browse files
authored
Merge pull request swiftlang#14764 from AndrewSB/clang-cl-over-msvc
2 parents 5d28e61 + beec93d commit c234759

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

docs/WindowsBuild.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ 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-
## MSVC
20+
## `clang-cl`
2121
- Windows doesn't currently have a build script. You'll need to run commands
2222
manually to build Swift on Windows.
2323
- Windows support for Swift is a work in progress and may not work on your
@@ -143,7 +143,10 @@ cmake -G "Ninja" "%swift_source_dir%/swift"^
143143
-DICU_I18N_LIB_NAME="icuin"^
144144
-DSWIFT_INCLUDE_DOCS=FALSE^
145145
-DSWIFT_INCLUDE_TESTS=FALSE^
146-
-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE^
146+
-DCMAKE_C_COMPILER="<path-to-llvm-bin>/clang-cl.exe"^
147+
-DCMAKE_CXX_COMPILER="<path-to-llvm-bin>/bin/clang-cl.exe"^
148+
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
149+
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7" ^
147150
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
148151
popd
149152
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
@@ -155,23 +158,39 @@ cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ni
155158
limitation that file paths cannot exceed 260 characters. These can be
156159
ignored, as they occur after the build when writing the last build status to
157160
a file.
161+
158162
```cmd
159163
cmake -G "Visual Studio 15" "%swift_source_dir%/swift"^
160164
-DCMAKE_GENERATOR_PLATFORM="x64"^
161165
...
162166
```
163167

164-
## Clang-cl
168+
## MSVC
165169

166-
Follow the instructions for MSVC, but add the following lines to each CMake
167-
configuration command. `clang-cl` 4.0.1 has been tested. You can remove the
168-
`SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE` definition, as overlays are supported
169-
with `clang-cl`, as it supports modules. The `Z7` flag is required to produce
170-
PDB files that MSVC's `link.exe` can read and enables proper stack traces.
170+
Follow instructions 1-6 for `clang-cl`, but run the following instead to build Swift
171171

172172
```cmd
173-
-DCMAKE_C_COMPILER="<path-to-llvm-bin>/clang-cl.exe"^
174-
-DCMAKE_CXX_COMPILER="<path-to-llvm-bin>/bin/clang-cl.exe"^
175-
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
176-
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7" ^
173+
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
174+
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
175+
cmake -G "Ninja" "%swift_source_dir%/swift"^
176+
-DCMAKE_BUILD_TYPE=Debug^
177+
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
178+
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
179+
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64/src"^
180+
-DSWIFT_PATH_TO_LLVM_SOURCE="%swift_source_dir%/llvm"^
181+
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"^
182+
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
183+
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"^
184+
-DICU_UC_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
185+
-DICU_UC_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
186+
-DICU_I18N_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
187+
-DICU_I18N_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
188+
-DICU_UC_LIB_NAME="icuuc"^
189+
-DICU_I18N_LIB_NAME="icuin"^
190+
-DSWIFT_INCLUDE_DOCS=FALSE^
191+
-DSWIFT_INCLUDE_TESTS=FALSE^
192+
-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE^
193+
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE
194+
popd
195+
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
177196
```

0 commit comments

Comments
 (0)