Skip to content

Commit ace3889

Browse files
authored
Merge pull request swiftlang#21610 from apple/windows-docs
Update WindowsBuild.md
2 parents 5355f31 + 24c031a commit ace3889

File tree

1 file changed

+52
-46
lines changed

1 file changed

+52
-46
lines changed

docs/WindowsBuild.md

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ it provides some of the needed headers and libraries.
4343
- Currently, other repositories in the Swift project have not been tested and
4444
may not be supported.
4545

46+
If your sources live else where, you can create a substitution for this:
47+
48+
```cmd
49+
subst S: <path to sources>
50+
```
51+
4652
```cmd
4753
git config --global core.autocrlf input
4854
S:
@@ -60,21 +66,18 @@ git clone https://github.com/apple/swift-corelibs-foundation
6066
1. Add the `bin64` folder to your `Path` environment variable.
6167

6268
### 4. Get ready
63-
- From within a **developer** command prompt (not PowerShell nor cmd, but [the
64-
Visual Studio Developer Command
65-
Prompt](https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx)), execute the
66-
following command if you have an x64 PC.
69+
- 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.
70+
6771
```cmd
6872
VsDevCmd -arch=amd64
6973
```
70-
If instead you're compiling for a 32-bit Windows target, adapt the `arch`
71-
argument to `x86` and run
74+
75+
If instead you're compiling for a 32-bit Windows target, adapt the `arch` argument to `x86` and run
76+
7277
```cmd
7378
VsDevCmd -arch=x86
7479
```
7580

76-
- We will use the assumption that the sources are on the `S` drive. Replace it with the path to the checkout. Make sure to use forward slashes (`/`) instead of backslashes (`\`) as the path separators. `clang` breaks with backslashed paths.
77-
7881
- Decide whether you want to build a release or debug version of Swift on Windows and
7982
replace the `CMAKE_BUILD_TYPE` parameter in the build steps below with the correct value
8083
(`Debug`, `RelWithDebInfoAssert` or `Release`) to avoid conflicts between the debug and
@@ -85,23 +88,25 @@ VsDevCmd -arch=x86
8588
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`, copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`, and copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/${UCRTVersion}/um` and setup the `visualc.apinotes` located at `swift/stdlib/public/Platform/visualc.apinotes` into `${VCToolsInstallDir}/include` as `visualc.apinotes`
8689

8790
```cmd
88-
cd %UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt
89-
mklink module.modulemap S:\swift\stdlib\public\Platform\ucrt.modulemap
90-
cd %VCToolsInstallDir%\include
91-
mklink module.modulemap S:\swift\stdlib\public\Platform\visualc.modulemap
92-
mklink visualc.apinotes S:\swift\stdlib\public\Platform\visualc.apinotes
93-
cd %UniversalCRTSdkDir\Include\%UCRTVersion%\um
94-
mklink module.modulemap S:\swift\stdlib\public\Platform\winsdk.modulemap
91+
mklink %UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap S:\swift\stdlib\public\Platform\ucrt.modulemap
92+
mklink %VCToolsInstallDir%\include\module.modulemap S:\swift\stdlib\public\Platform\visualc.modulemap
93+
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
9595
```
9696

9797
### 5. Build CMark
9898
- This must be done from within a developer command prompt. CMark is a fairly
9999
small project and should only take a few minutes to build.
100100
```cmd
101-
mkdir S:/build/Ninja-DebugAssert/cmark-windows-amd64"
102-
pushd S:/build/Ninja-DebugAssert/cmark-windows-amd64" "S:/%swift_source_dir%/cmark"
101+
mkdir S:\build\Ninja-DebugAssert\cmark-windows-amd64"
102+
pushd S:\build\Ninja-DebugAssert\cmark-windows-amd64" "S:\cmark"
103+
cmake -G Ninja^
104+
-DCMAKE_BUILD_TYPE=Debug^
105+
-DCMAKE_C_COMPILER=cl^
106+
-DCMAKE_CXX_COMPIELR=cl^
107+
S:\cmark
103108
popd
104-
cmake --build "S:/build/Ninja-DebugAssert/cmark-windows-amd64/"
109+
cmake --build "S:\build\Ninja-DebugAssert\cmark-windows-amd64"
105110
```
106111

107112
### 6. Build LLVM/Clang
@@ -110,20 +115,23 @@ cmake --build "S:/build/Ninja-DebugAssert/cmark-windows-amd64/"
110115
type (e.g. `Debug`, `Release`, `RelWithDebInfoAssert`) for LLVM/Clang matches the
111116
build type for Swift.
112117
```cmd
113-
mkdir "S:/build/Ninja-DebugAssert/llvm-windows-amd64"
114-
pushd "S:/build/Ninja-DebugAssert/llvm-windows-amd64"
118+
mkdir "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
119+
pushd "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
115120
cmake -G "Ninja"^
116-
-DLLVM_ENABLE_ASSERTIONS=TRUE^
117121
-DCMAKE_BUILD_TYPE=Debug^
122+
-DCMAKE_C_COMPILER=cl^
123+
-DCMAKE_CXX_COMPILER=cl^
124+
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
125+
-DLLVM_ENABLE_ASSERTIONS=TRUE^
118126
-DLLVM_ENABLE_PROJECTS=clang^
119127
-DLLVM_TARGETS_TO_BUILD=X86^
120-
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^
121-
"S:/llvm"
128+
"S:\llvm"
122129
popd
123-
cmake --build "S:/build/Ninja-DebugAssert/llvm-windows-amd64"
130+
cmake --build "S:\build\Ninja-DebugAssert\llvm-windows-amd64"
124131
```
125132

126-
- If you intend to build any libraries, update your path to include the LLVM tools.
133+
- Update your path to include the LLVM tools.
134+
127135
```cmd
128136
set PATH=%PATH%;S:\build\Ninja-DebugAssert\llvm-windows-amd64\bin
129137
```
@@ -134,31 +142,31 @@ set PATH=%PATH%;S:\build\Ninja-DebugAssert\llvm-windows-amd64\bin
134142
- You may need to adjust the `SWIFT_WINDOWS_LIB_DIRECTORY` parameter depending on
135143
your target platform or Windows SDK version.
136144
```cmd
137-
mkdir "S:/build/Ninja-DebugAssert/swift-windows-amd64"
138-
pushd "S:/build/Ninja-DebugAssert/swift-windows-amd64"
145+
mkdir "S:\build\Ninja-DebugAssert\swift-windows-amd64"
146+
pushd "S:\build\inja-DebugAssert\swift-windows-amd64"
139147
cmake -G "Ninja"^
140148
-DCMAKE_BUILD_TYPE=Debug^
141-
-DCMAKE_C_COMPILER="S:/build/Ninja-DebugAssert/llvm-windows-amd64/clang-cl.exe"^
142-
-DCMAKE_CXX_COMPILER="S:/build/Ninja-DebugAssert/llvm-windows-amd64/clang-cl.exe"^
143-
-DSWIFT_PATH_TO_CMARK_SOURCE="S:/cmark"^
149+
-DCMAKE_C_COMPILER=clang-cl^
150+
-DCMAKE_CXX_COMPILER=clang-cl^
151+
-DSWIFT_PATH_TO_CMARK_SOURCE="S:\cmark"^
144152
-DCMAKE_CXX_FLAGS="-Wno-c++98-compat -Wno-c++98-compat-pedantic"^
145153
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
146154
-DCMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO"^
147155
-DSWIFT_INCLUDE_DOCS=NO^
148-
-DSWIFT_PATH_TO_LLVM_SOURCE="S:/llvm"^
149-
-DSWIFT_PATH_TO_CLANG_SOURCE="S:/clang"^
150-
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="S:/swift-corelibs-libdispatch"^
151-
-DSWIFT_PATH_TO_LLVM_BUILD="S:/build/Ninja-DebugAssert/llvm-windows-amd64"^
152-
-DSWIFT_PATH_TO_CLANG_BUILD="S:/build/Ninja-DebugAssert/llvm-windows-amd64"^
153-
-DSWIFT_PATH_TO_CMARK_BUILD="S:/build/Ninja-DebugAssert/cmark-windows-amd64"^
154-
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/icu/include"^
155-
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:/icu/lib64/icuuc.lib"^
156-
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/icu/include"^
157-
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/icu/lib64/icuin.lib"^
158-
-DCMAKE_INSTALL_PREFIX="C:/Program Files (x86)/Swift"^
159-
"S:/swift"
156+
-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"^
159+
-DSWIFT_PATH_TO_LLVM_BUILD="S:\build\Ninja-DebugAssert\llvm-windows-amd64"^
160+
-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"^
162+
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:\icu\include"^
163+
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:\icu\lib64\icuuc.lib"^
164+
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:\icu\include"^
165+
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:\icu\lib64\icuin.lib"^
166+
-DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr"^
167+
"S:\swift"
160168
popd
161-
cmake --build "S:/build/Ninja-DebugAssert/swift-windows-amd64"
169+
cmake --build "S:\build\Ninja-DebugAssert\swift-windows-amd64"
162170
```
163171

164172
- To create a Visual Studio project, you'll need to change the generator and,
@@ -169,9 +177,7 @@ cmake --build "S:/build/Ninja-DebugAssert/swift-windows-amd64"
169177
a file.
170178

171179
```cmd
172-
cmake -G "Visual Studio 2017" "%swift_source_dir%/swift"^
173-
-DCMAKE_GENERATOR_PLATFORM="x64"^
174-
...
180+
cmake -G "Visual Studio 2017" "S:\swift" -DCMAKE_GENERATOR_PLATFORM="x64"^ ...
175181
```
176182

177183
### 8. Build lldb

0 commit comments

Comments
 (0)