Hello Swift Windows Users,
The Windows toolchain layout has always been designed to have multiple parallel toolchains installed. However, for the ease of use, the toolchain currently has a few environment settings that are setup by the installer. This global state makes it difficult to work with multiple parallel toolchains.
As a first step towards easing some of this complexity, I'd like to introduce tcrun. This tool scours the registry to identify Swift toolchain installations and enumerates the toolchains and SDKs that are present on the host. You can then select one through the -toolchain
or -sdk
parameter (through identifiers rather than absolute paths).
In order to actually use the tool, you would need a rather recent toolchain release (something within the last few days) as the last piece for this was introduced into the toolchain distribution rather recently.
As a sample of some of the functionality of the tool:
> tcrun -toolchains
SwiftInstallation {
System: false
Vendor: swift.org
Version: 0.0.0
Toolchains:
- C:\Users\abdulras\AppData\Local\Programs\Swift\Toolchains\0.0.0+Asserts [org.compnerd.dt.toolchain.20250123.0-asserts]
Platforms:
- Windows.platform
SDKs:
- Windows.sdk [C:\Users\abdulras\AppData\Local\Programs\Swift\Platforms\0.0.0\Windows.platform\Developer\SDKs\Windows.sdk]
- Android.platform
SDKs:
- Android.sdk [C:\Users\abdulras\AppData\Local\Programs\Swift\Platforms\0.0.0\Android.platform\Developer\SDKs\Android.sdk]
}
> tcrun -toolchain org.compnerd.dt.toolchain.20250123.0-asserts -sdk Android.sdk swift -- build --triple aarch64-unknown-linux-android
error: 'tcrun': Invalid manifest (compiled with: ["C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin\\swiftc.exe", "-vfsoverlay", "C:\\Users\\abdulras\\AppData\\Local\\Temp\\TemporaryDirectory.1Imihi\\vfs.yaml", "-L", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-lPackageDescription", "-sdk", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Android.platform\\Developer\\SDKs\\Android.sdk", "-libc", "MD", "-I", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Android.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows", "-I", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Android.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\aarch64", "-L", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Android.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\aarch64", "-use-ld=lld", "-swift-version", "6", "-I", "C:\\Users\\abdulras\\AppData\\Local\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-package-description-version", "6.0.0", "C:\\Users\\abdulras\\SourceCache\\compnerd\\tcrun\\Package.swift", "-o", "C:\\Users\\abdulras\\AppData\\Local\\Temp\\TemporaryDirectory.DYUaUk\\tcrun-manifest.exe"])
<unknown>:0: error: unable to load standard library for target 'aarch64-unknown-windows-msvc'
Hopefully this tool will make it easier to switch between different installations and someday be able to avoid having to globally adjust the Path
and SDKROOT
environment variables. The second example shows how the SDKROOT has been swapped out under the invocation preventing the build of the manifest for the package.
As always, PRs are welcome!
Saleem