diff --git a/docs/WindowsBuild.md b/docs/WindowsBuild.md index 4506701290daf..4b32d7ef77b7b 100644 --- a/docs/WindowsBuild.md +++ b/docs/WindowsBuild.md @@ -1,102 +1,73 @@ # Building Swift on Windows -Visual Studio 2017 or newer is needed to build Swift on Windows. The free Community edition is sufficient to build Swift. +Visual Studio 2019 or newer is needed to build Swift on Windows, while VS2022 is recommended and currently used for CI. The free Community edition is sufficient to build Swift, and we're assuming host and target to be both x64. -The commands below (with the exception of installing Visual Studio) must be entered in the "**x64 Native** Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to select the correct target platform. +The commands below (with the exception of installing Visual Studio) must be entered in the **x64 Native Tools Command Prompt for VS2022** (or VS2019 depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to locate tools and resources for the correct target platform. -## Install dependencies +> **NOTE:** This guide is intended for toolchain developers who wants to develop or build Swift on their own machine. For building and packaging a standard toolchain, please refer to [`build-windows-toolchain.bat`](../utils/build-windows-toolchain.bat). -### Visual Studio +## Enable Developer Mode -An easy way to get most of the tools to build Swift is using the [Visual Studio installer](https://www.visualstudio.com/downloads/). This command installs all needed Visual Studio components as well as Python, Git, CMake and Ninja: +From **Settings** app, go to *Update & Security*. In the *For developers* tab, set *Install apps from any source, including loose files* to On. This is required to enable the creation of symbolic links. -``` -curl.exe -sOL https://aka.ms/vs/16/release/vs_community.exe +## Install build tools and SDK + +An easy way to get the tools to build Swift is using the [Visual Studio installer](https://www.visualstudio.com/downloads/). The following command installs all needed Visual Studio components as well as Python, Git, CMake and Ninja: + +```cmd +curl.exe -sOL https://aka.ms/vs/17/release/vs_community.exe vs_community ^ - --add Component.CPython3.x64 ^ + --add Component.CPython39.x64 ^ --add Microsoft.VisualStudio.Component.Git ^ --add Microsoft.VisualStudio.Component.VC.ATL ^ --add Microsoft.VisualStudio.Component.VC.CMake.Project ^ --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ - --add Microsoft.VisualStudio.Component.Windows10SDK ^ - --add Microsoft.VisualStudio.Component.Windows10SDK.17763 + --add Microsoft.VisualStudio.Component.Windows11SDK.22000 del /q vs_community.exe ``` -If you prefer you can install everything by hand, but make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The components listed above are required. +> **NOTE:** For anyone who wants to use Visual Studio 2019, you can simply replace version number `17` with `16` in the installer URL. -The following [link](https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019) helps in finding the component name given its ID for Visual Studio 2019. +> **NOTE:** The following [link](https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022) helps in finding the component name given its ID for Visual Studio 2022. For anyone using VS installer in GUI, please check it out. -### Python +### Set up `vcpkg` -The command above already installs Python 3. Alternatively, in the Visual Studio installation program, under *Individual Components*, install *Python 3 64 bits (3.7.x)*. - -If you are building a debug version of Swift, you should also install the Python debug binaries. - -1. In the Windows settings, go to *Add and Remove Programs* -2. Select the *Python 3.7.x (64-bit)* entry -3. Click *Modify*, then *Yes*, then *Modify* again and then *Next* -4. Select *Download debug binaries (requires VS 2015 or later)* -5. Click *Install* - -## Enable Developer Mode +This guide uses `vcpkg` for pulling in external dependencies, including ICU, libcurl, libxml2, SQLite 3 and zlib. -From the settings application, go to `Update & Security`. In the `For developers` tab, select `Developer Mode` for `Use Developer Features`. This is required to enable the creation of symbolic links. +All you have to do is to clone and bootstrap `vcpkg`: -## Clone the repositories +```cmd +git clone https://github.com/microsoft/vcpkg S:\vcpkg +S:\vcpkg\bootstrap-vcpkg.bat +``` -1. Clone `swift/main` branch of `apple/llvm-project` into the build workspace -2. Clone `apple/swift-cmark`, `apple/swift`, `apple/swift-corelibs-libdispatch`, `apple/swift-corelibs-foundation`, `apple/swift-corelibs-xctest`, `apple/swift-tools-support-core`, `apple/swift-llbuild`, `apple/swift-argument-parser`, `apple/swift-driver`, `apple/swift-package-manager`, `JPSim/Yams`, `apple/indexstore-db` into the build workspace +> **NOTE:** By default, the dependencies will be downloaded and built on demand. Optionally, you can pre-build the dependencies to speed up configuration: +> +> S:\vcpkg\vcpkg install curl icu libxml2 sqlite3 zlib --triplet=x64-windows -- Currently, other repositories in the Swift project have not been tested and may not be supported. +## Clone the source repositories -This guide assumes your sources live at the root of `S:`. If your sources live elsewhere, you can create a substitution for this: +This guide assumes your sources live at the root of `S:`. As long as drive letter `S:` is not assigned, you can create a substitution to map your source directory: ```cmd -subst S: +subst S: ``` +First, clone `apple/swift` (this repository) with Git: + ```cmd -S: -git clone https://github.com/apple/llvm-project --branch swift/main llvm-project -git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift swift -git clone https://github.com/apple/swift-cmark cmark -git clone https://github.com/apple/swift-corelibs-libdispatch swift-corelibs-libdispatch -git clone https://github.com/apple/swift-corelibs-foundation swift-corelibs-foundation -git clone https://github.com/apple/swift-corelibs-xctest swift-corelibs-xctest -git clone https://github.com/apple/swift-tools-support-core swift-tools-support-core -git clone -c core.symlinks=true https://github.com/apple/swift-llbuild swift-llbuild -git clone https://github.com/JPSim/Yams Yams -git clone https://github.com/apple/swift-driver swift-driver -git clone https://github.com/apple/swift-argument-parser swift-argument-parser -git clone -c core.autocrlf=input https://github.com/apple/swift-package-manager swift-package-manager -git clone https://github.com/apple/indexstore-db indexstore-db +git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift S:\swift ``` -## Dependencies (ICU, SQLite3, curl, libxml2 and zlib) - -The instructions assume that the dependencies are in `S:/Library`. The directory -structure should resemble: +You'll be able to clone and check out the rest of Swift source repositories with `update-checkout` tool: -``` -/Library - ┝ icu-67 - │ ┕ usr/... - ├ libcurl-development - │ ┕ usr/... - ├ libxml2-development - │ ┕ usr/... - ├ sqlite-3.28.0 - │ ┕ usr/... - ┕ zlib-1.2.11 - ┕ usr/... +```cmd +S:\swift\utils\update-checkout.cmd --clone --skip-repository swift ``` -Note that ICU is only required for building Foundation, and SQLite is only -needed for building llbuild and onwards. The ICU project provides binaries, -alternatively, see the ICU project for details on building ICU from source. +> **NOTE:** You can use forked versions of Swift source repositories by manually placing them into `S:\` and appending their names to the `--skip-repository` option of `update-checkout`. Don't forget to clone them with `-c core.autocrlf=input -c core.symlinks=true` and the correct repository name. -## One-time Setup (re-run on Visual Studio upgrades) +## Set up Visual Studio integration (re-run on Visual Studio upgrades) Set up the `ucrt`, `visualc`, and `WinSDK` modules by: @@ -106,6 +77,8 @@ Set up the `ucrt`, `visualc`, and `WinSDK` modules by: - 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` +You're recommended to create symbolic links to avoid manual copying every time you modified these files. + ```cmd mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\swift\stdlib\public\Platform\ucrt.modulemap mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\swift\stdlib\public\Platform\winsdk.modulemap @@ -113,296 +86,675 @@ mklink "%VCToolsInstallDir%\include\module.modulemap" S:\swift\stdlib\public\Pla mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Platform\visualc.apinotes ``` -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. +> **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 "More > 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. + +## Build for development -## Build the toolchain +The following guide will get you through the building process of a complete Swift debug toolchain. + +Before you kick off the process, unset `%SDKROOT%` if you've already installed Swift: + +```cmd +set SDKROOT= +``` + +If you want to use an existing Swift toolchain to build the core libraries and other parts of the toolchain, make sure you have it in `%Path%`, and strip `S:/b/1/bin/` from every `-D CMAKE_{language}_COMPILER=S:/b/1/bin/{compiler}` option. + +Here is a graphical overview of all build steps from this guide. + +``` +┌──────────────────────────────────────┐ ┌────────────────┐ +│ │ │ │ +│ 1. LLVM + Swift compiler │ │ │ +│ │ │ Existing Swift │ +│ ┌────────────────────────────┐ │ or │ toolchain │ +│ │ 2. Swift runtime libraries │ │ │ │ +│ └────────────────────────────┘ │ │ │ +└──────────────────────────────────────┘ └────────────────┘ + │ │ + └───────────┬──────────────────────┘ + │ + ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ + ┌──────────────────────┐ │ + │ │ 3. libdispatch │ + └──────────────────────┘ │ + │ Core ┌──────────────────────┐ + │ 4. Foundation │ │ + │ libraries └──────────────────────┘ + ┌──────────────────────┐ │ + │ │ 5. XCTest │ + └──────────────────────┘ │ + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ + │ + │ + │ + ┌───────────────────────────────────────────────────┐ + │ │ + │ 6. Developer tool dependencies │ + │ │ + ├─────────┬──────┬─────────────┬─────┬──────────────┤ + │ LLBuild │ Yams │ SwiftSystem │ ··· │ IndexStoreDB │ + └─────────┴──────┴─────────────┴─────┴──────────────┘ + │ + │ + ┌────────────────────────────┐ + │ 7. TSC │ + └────────────────────────────┘ + │ + │ + │ + ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ + ┌──────────────────────┐ │ + │ │ 8. Swift Driver │ + └──────────────────────┘ │ + │ Developer ┌──────────────────────┐ + │ 9. SwiftPM │ │ + │ tools └──────────────────────┘ + ┌──────────────────────┐ │ + │ │ 10. SourceKit-LSP │ + └──────────────────────┘ │ + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ +``` + +### 1. Swift compiler ```cmd -cmake -B "S:\b\1" ^ +cmake -B S:\b\1 ^ -C S:\swift\cmake\caches\Windows-x86_64.cmake ^ -D CMAKE_BUILD_TYPE=Release ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ - -D CMAKE_C_COMPILER=cl ^ - -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ - -D CMAKE_CXX_COMPILER=cl ^ - -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^ - -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy /source-charset:utf-8 /execution-charset:utf-8" ^ + -D CMAKE_CXX_COMPILER=cl.exe ^ + -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy /utf-8" ^ -D CMAKE_MT=mt ^ - -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc ^ -D LLVM_ENABLE_PDB=YES ^ + -D LLVM_EXTERNAL_CMARK_SOURCE_DIR=S:\cmark ^ -D LLVM_EXTERNAL_SWIFT_SOURCE_DIR=S:\swift ^ -D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch ^ + + -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^ + + -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^ + -D EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=S:\swift-experimental-string-processing ^ + -G Ninja ^ -S S:\llvm-project\llvm -ninja -C S:\b\1 +cmake --build S:\b\1 ``` -> **NOTE:** Linking with debug information (`-D LLVM_ENABLE_PDB=YES`) is very memory intensive. When building with parallel jobs, it is possible to consume upwards of 32 GiB of RAM. You can append `-D LLVM_PARALLEL_LINK_JOBS=N -D DLLVM_PARALLEL_LINK_JOBS=N` to reduce the number of parallel link operations to `N` which should help reduce the memory pressure. You may need to set this to a low number (e.g. 1) if you see build failures due to memory exhaustion. +> **NOTE:** Flag `-D LLVM_ENABLE_PDB=YES` enables LLVM to emit PDB files, which is useful for debugging on Windows. However, linking with debug information is very memory-intensive and may drastically slow down the linking process. A single link job is possible to consume upwards of 10 GiB of RAM. You can append `-D LLVM_PARALLEL_LINK_JOBS=N` and `-D SWIFT_PARALLEL_LINK_JOBS=N` to reduce the number of parallel link operations to `N` which should help reduce the memory pressure. +> +> For host with less than 32 GiB of RAM, you may need to disable PDB support by stripping this option, to avoid running into OOM. + +> **NOTE:** By default, we enables all the experimental features in Swift by `-D SWIFT_ENABLE_EXPERIMENTAL_{FEATURE}=YES`. Notice that `Concurrency` is an accepted language feature that is supposed be enabled for Swift 5.5+. -## Running Swift tests on Windows +Test Swift: ```cmd -path S:\Library\icu-67\usr\bin;S:\b\1\bin;S:\b\1\tools\swift\libdispatch-windows-x86_64-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin -ninja -C S:\b\1 check-swift +path %PATH%;%ProgramFiles%\Git\usr\bin +cmake --build S:\b\1 --target check-swift ``` -## Build swift-corelibs-libdispatch +### 2. Swift runtime libraries ```cmd cmake -B S:\b\2 ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -C S:\swift\cmake\caches\Runtime-Windows-x86_64.cmake ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\sdk\usr ^ + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_CXX_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D LLVM_DIR=S:\b\1\lib\cmake\llvm ^ + -D SWIFT_NATIVE_SWIFT_TOOLS_PATH=S:\b\1\bin ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + -D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch ^ + + -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^ + + -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^ + -D EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=S:\swift-experimental-string-processing ^ + + -G Ninja ^ + -S S:\swift + +cmake --build S:\b\2 +``` + +> **NOTE:** Swift runtime libraries are also built along with the compiler. This step extracts them into a portable SDK where we will install core libraries alongside. + +### 3. libdispatch + +```cmd +cmake -B S:\b\3 ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\sdk\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ + -D CMAKE_CXX_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^ + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D ENABLE_SWIFT=YES ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + + -D BUILD_TESTING=YES ^ + -G Ninja ^ -S S:\swift-corelibs-libdispatch -ninja -C S:\b\2 +cmake --build S:\b\3 ``` -## Test swift-corelibs-libdispatch +Test libdispatch: ```cmd -ninja -C S:\b\2 check +cmake --build S:\b\3 --target test ``` -## Build swift-corelibs-foundation +### 4. Foundation (without tests) ```cmd -cmake -B S:\b\3 ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ +cmake -B S:\b\4 ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\sdk\usr ^ + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D CURL_LIBRARY="S:/Library/libcurl-development/usr/lib/libcurl.lib" ^ - -D CURL_INCLUDE_DIR="S:/Library/libcurl-development/usr/include" ^ - -D ICU_I18N_LIBRARY_RELEASE=S:\library\icu-67\usr\lib\icuin67.lib ^ - -D ICU_ROOT=S:\Library\icu-67\usr ^ - -D ICU_UC_LIBRARY_RELEASE=S:\Library\icu-67\usr\lib\icuuc67.lib ^ - -D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^ - -D LIBXML2_LIBRARY=S:\Library\libxml2-development\usr\lib\libxml2s.lib ^ - -D LIBXML2_INCLUDE_DIR=S:\Library\libxml2-development\usr\include\libxml2 ^ - -D ENABLE_TESTING=NO ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + + -D CMAKE_TOOLCHAIN_FILE=S:\vcpkg\scripts\buildsystems\vcpkg.cmake ^ + -G Ninja ^ -S S:\swift-corelibs-foundation -ninja -C S:\b\3 +cmake --build S:\b\4 ``` -- Add Foundation to your path: +### 5. XCTest ```cmd -path S:\b\3\bin;%PATH% +cmake -B S:\b\5 ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\sdk\usr ^ + + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + + -D ENABLE_TESTING=YES ^ + -D LLVM_DIR=S:\b\1\lib\cmake\llvm ^ + -D LIT_COMMAND=S:\llvm-project\llvm\utils\lit\lit.py ^ + -D XCTEST_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch ^ + -D XCTEST_PATH_TO_LIBDISPATCH_BUILD=S:\b\3 ^ + -D XCTEST_PATH_TO_FOUNDATION_BUILD=S:\b\4 ^ + + -G Ninja ^ + -S S:\swift-corelibs-xctest + +cmake --build S:\b\5 +``` + +Test XCTest: + +```cmd +path %PATH%;%ProgramFiles%\Git\usr\bin +cmake --build S:\b\5 --target check-xctest ``` -## Build swift-corelibs-xctest +### 4.1 Foundation (with tests) ```cmd cmake -B S:\b\4 ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\sdk\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D LIT_COMMAND=S:\llvm-project\llvm\utils\lit\lit.py ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + + -D CMAKE_TOOLCHAIN_FILE=S:\vcpkg\scripts\buildsystems\vcpkg.cmake ^ + + -D ENABLE_TESTING=YES ^ + -D XCTest_DIR=S:\b\5\cmake\modules ^ + -G Ninja ^ - -S S:\swift-corelibs-xctest + -S S:\swift-corelibs-foundation -ninja -C S:\b\4 +cmake --build S:\b\4 ``` -- Add XCTest to your path: +Test Foundation: ```cmd - -path S:\b\4;%PATH% +cmake --build S:\b\4 --target test ``` -## Test XCTest +### 6. Tool dependencies + +> **NOTE:** We're building the following libraries without tests here because they're independent packages that are directly or indirectly depended by Swift Driver, SwiftPM or SourceKit-LSP. For developing these libraries, use SwiftPM instead. + +#### LLBuild (Used by Swift Driver, SwiftPM and SourceKit-LSP) ```cmd -ninja -C S:\b\4 check-xctest +cmake -B S:\b\6\LLBuild ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_CXX_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy -Xclang -fno-split-cold-code" ^ + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D LLBUILD_SUPPORT_BINDINGS=Swift ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + + -D CMAKE_TOOLCHAIN_FILE=S:\vcpkg\scripts\buildsystems\vcpkg.cmake ^ + + -D LIT_EXECUTABLE=S:\llvm-project\llvm\utils\lit\lit.py ^ + -D FILECHECK_EXECUTABLE=S:\b\1\bin\FileCheck.exe ^ + + -G Ninja ^ + -S S:\llbuild + +cmake --build S:\b\6\LLBuild ``` -## Rebuild Foundation +#### Yams (used by Swift Driver) ```cmd -cmake -B S:\b\3 ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ +cmake -B S:\b\6\Yams ^ + -D BUILD_SHARED_LIBS=YES ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy /DYAML_DECLARE_EXPORT /DWIN32" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D CURL_LIBRARY="S:/Library/libcurl-development/usr/lib/libcurl.lib" ^ - -D CURL_INCLUDE_DIR="S:/Library/libcurl-development/usr/include" ^ - -D ICU_I18N_LIBRARY_RELEASE=S:\library\icu-67\usr\lib\icuin67.lib ^ - -D ICU_ROOT=S:\Library\icu-67\usr ^ - -D ICU_UC_LIBRARY_RELEASE=S:\Library\icu-67\usr\lib\icuuc67.lib ^ - -D LIBXML2_LIBRARY=S:\Library\libxml2-development\usr\lib\libxml2s.lib ^ - -D LIBXML2_INCLUDE_DIR=S:\Library\libxml2-development\usr\include\libxml2 ^ - -D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^ - -D ENABLE_TESTING=YES ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D XCTest_DIR=S:\b\4\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + + -D BUILD_TESTING=NO ^ + -G Ninja ^ - -S S:\swift-corelibs-foundation + -S S:\yams -ninja -C S:\b\3 +cmake --build S:\b\6\Yams ``` -## Test Foundation +#### Argument Parser (used by Swift Driver and SwiftPM) ```cmd -ninja -C S:\b\3 test +cmake -B S:\b\6\ArgumentParser ^ + -D BUILD_SHARED_LIBS=YES ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + + -D BUILD_EXAMPLES=NO ^ + -D BUILD_TESTING=NO ^ + + -G Ninja ^ + -S S:\swift-argument-parser + +cmake --build S:\b\6\ArgumentParser ``` -## Build swift-tools-core-support +#### Swift System (used by Swift Driver and SwiftPM) ```cmd -cmake -B S:\b\5 ^ +cmake -B S:\b\6\SwiftSystem ^ -D BUILD_SHARED_LIBS=YES ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D SQLite3_INCLUDE_DIR=S:\Library\sqlite-3.28.0\usr\include ^ - -D SQLite3_LIBRARY=S:\Library\sqlite-3.28.0\usr\lib\SQLite3.lib ^ + -G Ninja ^ - -S S:\swift-tools-support-core + -S S:\swift-system -ninja -C S:\b\5 +cmake --build S:\b\6\SwiftSystem ``` -## Build swift-llbuild +#### Swift Crypto (used by SwiftPM) ```cmd -cmake -B S:\b\6 ^ +cmake -B S:\b\6\SwiftCrypto ^ -D BUILD_SHARED_LIBS=YES ^ - -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ - -D CMAKE_CXX_COMPILER=S:/b/1/bin/clang-cl.exe ^ - -D CMAKE_CXX_FLAGS="-Xclang -fno-split-cold-code" ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D LLBUILD_SUPPORT_BINDINGS=Swift ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D SQLite3_INCLUDE_DIR=S:\Library\sqlite-3.28.0\usr\include ^ - -D SQLite3_LIBRARY=S:\Library\sqlite-3.28.0\usr\lib\sqlite3.lib ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + -G Ninja ^ - -S S:\swift-llbuild + -S S:\swift-crypto -ninja -C S:\b\6 +cmake --build S:\b\6\SwiftCrypto ``` -- Add llbuild to your path: +#### Swift Collections (used by SwiftPM) ```cmd -path S:\b\6\bin;%PATH% +cmake -B S:\b\6\SwiftCollections ^ + -D BUILD_SHARED_LIBS=YES ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + + -D BUILD_TESTING=NO ^ + + -G Ninja ^ + -S S:\swift-collections + +cmake --build S:\b\6\SwiftCollections ``` -## Build Yams +#### IndexStoreDB (used by SourceKit-LSP) + +```cmd +cmake -B S:\b\6\IndexStoreDB ^ + -D BUILD_SHARED_LIBS=YES ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ + -D CMAKE_CXX_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy -Xclang -fno-split-cold-code" ^ + -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + + -D BUILD_TESTING=NO ^ + + -G Ninja ^ + -S S:\indexstore-db + +cmake --build S:\b\6\IndexStoreDB +``` + +### 7. TSC (without tests) ```cmd cmake -B S:\b\7 ^ -D BUILD_SHARED_LIBS=YES ^ -D CMAKE_BUILD_TYPE=Release ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D XCTest_DIR=S:\b\4\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + -D SwiftSystem_DIR=S:\b\6\SwiftSystem\cmake\modules ^ + + -D CMAKE_TOOLCHAIN_FILE=S:\vcpkg\scripts\buildsystems\vcpkg.cmake ^ + -G Ninja ^ - -S S:\Yams + -S S:\swift-tools-support-core -ninja -C S:\b\7 +cmake --build S:\b\7 ``` -## Build swift-argument-parser +### 8. Swift Driver (without tests) ```cmd cmake -B S:\b\8 ^ -D BUILD_SHARED_LIBS=YES ^ -D CMAKE_BUILD_TYPE=Release ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D XCTest_DIR=S:\b\4\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + -D LLBuild_DIR=S:\b\6\LLBuild\cmake\modules ^ + -D Yams_DIR=S:\b\6\Yams\cmake\modules ^ + -D SwiftSystem_DIR=S:\b\6\SwiftSystem\cmake\modules ^ + -D ArgumentParser_DIR=S:\b\6\ArgumentParser\cmake\modules ^ + -D TSC_DIR=S:\b\7\cmake\modules ^ + -G Ninja ^ - -S S:\swift-argument-parser + -S S:\swift-driver -ninja -C S:\b\8 +cmake --build S:\b\8 ``` -## Build swift-driver +### 9. SwiftPM (without tests) ```cmd cmake -B S:\b\9 ^ -D BUILD_SHARED_LIBS=YES ^ -D CMAKE_BUILD_TYPE=Release ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D TSC_DIR=S:\b\5\cmake\modules ^ - -D LLBuild_DIR=S:\b\6\cmake\modules ^ - -D Yams_DIR=S:\b\7\cmake\modules ^ - -D ArgumentParser_DIR=S:\b\8\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + -D LLBuild_DIR=S:\b\6\LLBuild\cmake\modules ^ + -D SwiftSystem_DIR=S:\b\6\SwiftSystem\cmake\modules ^ + -D ArgumentParser_DIR=S:\b\6\ArgumentParser\cmake\modules ^ + -D SwiftCrypto_DIR=S:\b\6\SwiftCrypto\cmake\modules ^ + -D SwiftCollections_DIR=S:\b\6\SwiftCollections\cmake\modules ^ + -D TSC_DIR=S:\b\7\cmake\modules ^ + -D SwiftDriver_DIR=S:\b\8\cmake\modules ^ + -G Ninja ^ - -S S:\swift-driver + -S S:\swiftpm -ninja -C S:\b\9 +cmake --build S:\b\9 ``` -## Build swift-package-manager +### 10. SourceKit-LSP (without tests) ```cmd cmake -B S:\b\10 ^ -D BUILD_SHARED_LIBS=YES ^ -D CMAKE_BUILD_TYPE=Release ^ + -D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^ + -D CMAKE_C_COMPILER=S:/b/1/bin/clang-cl.exe ^ - -D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^ + -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ -D CMAKE_MT=mt ^ + -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ + -D CMAKE_Swift_COMPILER=S:/b/1/bin/swiftc.exe ^ - -D dispatch_DIR=S:\b\2\cmake\modules ^ - -D Foundation_DIR=S:\b\3\cmake\modules ^ - -D TSC_DIR=S:\b\5\cmake\modules ^ - -D LLBuild_DIR=S:\b\6\cmake\modules ^ - -D Yams_DIR=S:\b\7\cmake\modules ^ - -D ArgumentParser_DIR=S:\b\8\cmake\modules ^ - -D SwiftDriver_DIR=S:\b\9\cmake\modules ^ + -D dispatch_DIR=S:\b\3\cmake\modules ^ + -D Foundation_DIR=S:\b\4\cmake\modules ^ + -D LLBuild_DIR=S:\b\6\LLBuild\cmake\modules ^ + -D SwiftSystem_DIR=S:\b\6\SwiftSystem\cmake\modules ^ + -D ArgumentParser_DIR=S:\b\6\ArgumentParser\cmake\modules ^ + -D SwiftCollections_DIR=S:\b\6\SwiftCollections\cmake\modules ^ + -D IndexStoreDB_DIR=S:\b\6\IndexStoreDB\cmake\modules ^ + -D TSC_DIR=S:\b\7\cmake\modules ^ + -D SwiftPM_DIR=S:\b\9\cmake\modules ^ + -G Ninja ^ - -S S:\swift-package-manager + -S S:\sourcekit-lsp + +cmake --build S:\b\10 +``` + +## Use the toolchain and SDK -ninja -C S:\b\10 +If you want a toolchain for real-world testing, you can use CMake to perform the install step. However, the built toolchain is not expected to be distributed, mainly because there're plenty of unnecessary or local files that need to be stripped. + +### Swift compiler + +```cmd +cmake --build S:\b\1 --target install ``` -Indicate to swift-package-manager where to find the Package Description before installation: +For testing, add the toolchain to path: + ```cmd -set SWIFTPM_PD_LIBS=S:\b\10\pm +path S:\b\toolchain\usr\bin;%PATH% ``` -## Install the Swift toolchain on Windows +> **NOTE**: The built compiler cannot actually compile Swift files without a compatible SDK. You may need to specify `-sdk ` explicitly. + +### Swift Windows SDK (with core libraries) + +```cmd +cmake --build S:\b\2 --target install +cmake --build S:\b\3 --target install +cmake --build S:\b\4 --target install +cmake --build S:\b\5 --target install +``` + +Usually, you also need to bundle external libraries required by `Foundation`: + +```cmd +copy /Y S:\b\4\bin\*.dll S:\b\sdk\usr\bin +``` + +For testing, set `%SDKROOT%` and add runtime libraries to path: + +```cmd +set SDKROOT=S:\b\sdk +path S:\b\sdk\usr\bin;%PATH% +``` + +#### Fix SDK layout + +You may notice that the SDK is not functioning correctly. This is caused by the mismatch of expected SDK layout and the build output. Before these issues get addressed, we may need some extra workaround. + +1. Compiler expects Swift libraries to live in `\usr\lib\swift\windows\x86_64`, but the build output is `\usr\lib\swift\windows`. This is likely to trigger `unable to load standard library for target 'x86_64-unknown-windows-msvc'` error. Fix by: + +```cmd +for /D %m in (S:\b\sdk\usr\lib\swift\windows\*.swiftmodule) do ^ +move /Y %m S:\b\sdk\usr\lib\swift\windows\x86_64 +``` + +> **NOTE(stevapple)**: The compiler convention shall be wrong here — Swift libraries can be bundled with multiple architectures, so there's no need to place them in arch-specific directory. + +2. Compiler expects underlying modules to be imported from `\usr\include`, but the build output is `\usr\lib\swift`. This is likely to trigger `cannot load underlying module for ''` error. Fix by: + +```cmd +move /Y S:\b\sdk\usr\lib\swift\Block S:\b\sdk\usr\include +move /Y S:\b\sdk\usr\lib\swift\dispatch S:\b\sdk\usr\include +move /Y S:\b\sdk\usr\lib\swift\os S:\b\sdk\usr\include +``` + +3. Compiler expects Swift runtime import libraries to live in `\usr\lib\swift\windows\x86_64`, but the build output is `\usr\lib\swift\windows`. This is likely to trigger `fatal error LNK1104: cannot open file '.lib'` error. Fix by: + +```cmd +move /Y S:\b\sdk\usr\lib\swift\windows\*.lib S:\b\sdk\usr\lib\swift\windows\x86_64 +``` + +> **NOTE(stevapple)**: The build script shall be wrong here — Swift shared libraries are closely tied to target architecture, so we should place them in arch-specific directory if Universal binary is not available. + +### Swift developer tools + +```cmd +cmake --build S:\b\6\LLBuild --target install +cmake --build S:\b\6\Yams --target install +cmake --build S:\b\6\ArgumentParser --target install +cmake --build S:\b\6\SwiftSystem --target install +cmake --build S:\b\6\SwiftCrypto --target install +cmake --build S:\b\6\SwiftCollections --target install +cmake --build S:\b\6\IndexStoreDB --target install +cmake --build S:\b\7 --target install +cmake --build S:\b\8 --target install +cmake --build S:\b\9 --target install +cmake --build S:\b\10 --target install +copy /Y S:\b\7\bin\sqlite3.dll S:\b\toolchain\usr\bin +``` -- Run ninja install: +To use Swift Driver in place of the old driver (default since Swift 5.7): ```cmd -ninja -C S:\b\1 install +copy /Y S:\b\toolchain\usr\bin\swift-driver.exe S:\b\toolchain\usr\bin\swift.exe +copy /Y S:\b\toolchain\usr\bin\swift-driver.exe S:\b\toolchain\usr\bin\swiftc.exe ``` -- Add the Swift on Windows binaries path (`C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin`) to the `PATH` environment variable. +You should be able to compile Swift packages without any additional steps. diff --git a/utils/build-windows.bat b/utils/build-windows.bat index fc82212772c33..d9167d53eff84 100644 --- a/utils/build-windows.bat +++ b/utils/build-windows.bat @@ -20,7 +20,7 @@ :: Practically, it is easier to be in the Adminstrators group to run the :: script, but it should be possible to execute as a normal user. :: The user will need permission to write files into the Windows SDK and the -:: VisualC++ folder. +:: Visual C++ folder. :: @echo off