Build instructions

I'm trying to follow the build instructions for Windows (swift/ at main · apple/swift · GitHub), but encountered a few questions:

  1. Regarding the following dependencies:

     --add Component.CPython3.x64 ^
     --add Microsoft.VisualStudio.Component.Git ^

    I've already installed Python and Git using winget. Can I assume these are fine, or do I need to reinstall them using Visual Studio?

  2. What's the difference between these two? Do I need to install exactly version 17763, or can I just use whatever version is most recent?

      --add Microsoft.VisualStudio.Component.Windows10SDK ^
      --add Microsoft.VisualStudio.Component.Windows10SDK.17763
  3. Regarding Python: The VS installer says version 3.7.x is no longer supported and recommends installating 3.9.x. Will that work?

  4. The apple/llvm-project repo no longer has a swift/main branch. Which branch should I clone instead?

  5. (Looking ahead a bit as I stopped after the previous issue). Where should I get the dependencies ICU, SQLite3, curl, libxml2 and zlib?


  1. Those should be fine but will not match what the official builds use. That means that you may need to adjust things accordingly for Python.

  2. You can install any version of the SDK that you like, you will need to adjust the copy-paste instructions accordingly (if there are cases that have values hardcoded).

  3. 3.9.x is fine, the newer Visual Studio package that I believe.

  4. stable/20211026

  5. You can build them from source from the respective project's upstream.

I believe the update-checkout script is fully functional on Windows. Shall we update the guide to make use of it?

I've found that it doesn't always work for me. Additionally, it really doesn't help with the windows build in my experience due to the lack of the dependencies.

I would look into utilizing vcpkg to install all the dependencies. Fortunately it should solve that problem and make Windows build a lot easier.

Note that this will diverge from the official builds - they build all the dependencies from source but have a different way to check out and build the dependencies. I don't mind if there are secondary directions, but the build everything from source should be the recommended way.

CI will remain building everything from source IMO. It doesn’t mind if we change because the guide for Linux has been suggesting apt for years.

Sure, but because build-script-impl is bash, it cannot support Windows, so making the documentation match the builds is important to make it easier for others to reproduce the builds locally.

I also tried to build Swift on Windows some months ago and took some notes there. Some details of my notes might be helpful in addition to the mentioned build instructions, but please keep in mind that some details might be outdated or even wrong as I do not consider myself an expert for some of the involved topics. (I hope I will have time to return to the topic of building Swift soon.)

A quick update on this thread: I’ve started the work to revise to keep it up-to-date and as developer-friendly as possible. The progress is collected at this WIP PR where you’re welcome to leave any opinion.

So far I have validated the build process up to all the core libraries, and the next goal is SwiftPM. Hopefully we should have a guide for anyone to try out every piece of Swift on Windows.

I really recommend that you take a look at swift-build/ at master · compnerd/swift-build ( which really is a far simpler, easier, and more actively maintained approach. It is far more comprehensive, and more closely replicates the official builds.

1 Like

We’ve got plenty of build scripts for Windows as of now, but none of these is flexible enough to be a substitute of build-script. These scripts maintain different approaches, regarding different purposes, and even have different requirements on host environment.

Documentation is sometimes more important than codes. I believe this is exactly the case when we’re talking about “building a toolchain”. We need a single source of truth for guiding a developer to build, debug and test any part of the toolchain they want, and is the closest to this goal.

Not every developer is willing to build the whole toolchain for debugging a single piece of it. Not every developer is familiar with CMake as senior developers like you. Before we have an equivalent of the easy-to-use build-script for Windows, documenting the existing building process will always be meaningful.

Sure, maintaining documentation is reasonable. I'm just recommending that rather than having the documentation be a duplicate of the script, make it entirely prose, leaving the developer to reconstruct the command line from scratch. The build path that I pointed out should be considered the canonical way to build on Windows - in fact, the build-windows-toolchain.bat is just an extension of that path, adding in the packaging step which I don't think is valuable for day-to-day development (and thus is split into two separate scripts).

Ultimately, the "planty" of scripts amount to one path - the same thing which that document covers.

After ~2 weeks of work, the refreshed is finally ready for review. For anyone who’s interested, feel free to take a look and review the PR.