The goal of this project is to create a root directory for both the CRT and Windows SDK that each contain all of the necessary includes and libraries needed for an application to compile and link from a non-Windows platform, using a native cross compiling toolchain like clang/LLVM. This includes adding symlinks to correct numerous casing issues in the Windows SDK so that the files generated by this program can function on a case-sensitive file system.
See this blog post for an in depth walkthrough of how xwin can be used.
cargo install xwin --locked
xwin provides two feature toggles used to decide which TLS implementation to use
rustls(default) - Uses
native-tlsfor TLS. Note that on platforms where OpenSSL is used it is always built from source.
You can download a prebuilt binary from the Releases. Note that only
x86_64-unknown-linux-musl builds are provided.
--accept-license- Doesn’t display the prompt to accept the license. You can also set the
--arch <arch>- The architectures to include [default: x86_64] [possible values: x86, x86_64, aarch, aarch64]. Note that I haven’t fully tested aarch/64 nor x86 so there might be issues with them, please file an issue if you encounter problems with them.
--cache-dir <cache-dir>- Specifies the cache directory used to persist downloaded items to disk. Defaults to
./.xwin-cacheif not specified.
-L, --log-level <level>- The log level for messages, only log messages at or above the level will be emitted [default: info] [possible values: off, error, warn, info, debug, trace].
--variant <variant>...- The variants to include [default: desktop] [possible values: desktop, onecore, spectre]. Note that I haven’t fully tested any variant except
desktop, please file an issue if you try to use one of the others and run into issues. Note that there is another
storevariant that hasn’t even been implemented due to it being weird and me not having a real project targeting it.
--channel <channel>- The product channel to use [default: release]
--manifest-version <version>- The version to retrieve, can either be a major version of 15 or 16, or a
<major>.<minor>version [default: 16]. This is the version number of the top level manifest, it’s…not really tied to the underlying content.
--manifest- Specifies a top level manifest to use, rather than downloading it from Microsoft. This can be used to ensure the output is reproducible.
This downloads the top level manifest and any vsix, msi, or cab files that are needed that aren’t already in the download cache.
Decompresses all of the downloaded package contents to disk.
download is run automatically.
--copy- Copies files from the unpack directory to the splat directory instead of moving them, which preserves the original unpack directories but increases overall execution time and disk usage.
--disable-symlinks- By default, symlinks are added to both the CRT and WindowsSDK to address casing issues in general usage. For example, if you are compiling C/C++ code that does
#include <windows.h>, it will break on a case-sensitive file system, as the actual path in the WindowsSDK is
Windows.h. This also applies even if the C/C++ you are compiling uses correct casing for all CRT/SDK includes, as the internal headers also use incorrect casing in most cases
--include-debug-libs- The MSVCRT includes (non-redistributable) debug versions of the various libs that are generally uninteresting to keep for most usage
--include-debug-symbols- The MSVCRT includes PDB (debug symbols) files for several of the libraries that are generally uninteresting to keep for most usage
--preserve-ms-arch-notation- By default, we convert the MS specific
arm64target architectures to the more canonical
aarch64of LLVM etc when creating directories/names. Passing this flag will preserve the MS names for those targets
This moves all of the unpacked files which aren’t pruned to their canonical locations under a root directory, for example here is what an
Desktop splat looks like.
unpack is run automatically as needed.
.xwin-cache/splat ├── crt │ ├── include │ │ ├── cliext │ │ ├── CodeAnalysis │ │ ├── cvt │ │ ├── experimental │ │ ├── Manifest │ │ └── msclr │ │ └── com │ └── lib │ └── x86_64 └── sdk ├── include │ ├── cppwinrt │ │ └── winrt │ │ └── impl │ ├── shared │ │ ├── ndis │ │ └── netcx │ │ └── shared │ │ └── net │ │ └── wifi │ ├── ucrt │ │ └── sys │ ├── um │ │ ├── alljoyn_c │ │ ├── gl │ │ ├── qcc │ │ │ └── windows │ │ └── winsqlite │ └── winrt │ └── wrl │ └── wrappers └── lib ├── ucrt │ └── x86_64 └── um └── x86_64
xwin.dockerfile is an example Dockerfile that can be used a container image capable of building and testing Rust crates targeting
This contribution is dual licensed under EITHER OF
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Returns the list of packages that are actually needed for cross compilation