A utility for downloading and packaging the Microsoft CRT headers and libraries, and Windows SDK headers and libraries needed for compiling and linking programs targeting Windows.
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 walk-through 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) - Usesrustls
for TLSnative-tls
- Usesnative-tls
for TLS. Note that on platforms where OpenSSL is used it is always built from source.
You can download a prebuilt binary from the Releases.
x86_64-unknown-linux-musl
x86_64-apple-darwin
aarch64-apple-darwin
--accept-license
- Doesn't display the prompt to accept the license. You can also set theXWIN_ACCEPT_LICENSE=1
environment variable--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-cache
if 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 exceptdesktop
, please file an issue if you try to use one of the others and run into issues. Note that there is anotherstore
variant 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.https_proxy
- Environment variable that specifies the HTTPS proxy to use.
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 isWindows.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 specificx64
,arm
, andarm64
target architectures to the more canonicalx86_64
,aarch
, andaarch64
of 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 x86_64
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 x86_64-pc-windows-msvc
.
Special thanks to https://github.com/mstorsjo/msvc-wine for the inspiration and @mdsteele for publishing several Rust crates around msi/cab files that were needed in this project
This contribution is dual licensed under EITHER OF
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.