Skip to content

Commit a00f127

Browse files
authored
Unrolled build for #149713
Rollup merge of #149713 - mati865:gnullvm-doc, r=petrochenkov Update windows-gnullvm platform support doc
2 parents ba86c04 + a2910ce commit a00f127

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/doc/rustc/src/platform-support/windows-gnullvm.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
**Tier: 2 (with host tools)**
44

5-
Windows targets similar to `*-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of GCC/Binutils.
5+
Windows targets similar to `*-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of
6+
GCC/Binutils.
67

78
Target triples available so far:
9+
810
- `aarch64-pc-windows-gnullvm`
911
- `i686-pc-windows-gnullvm`
1012
- `x86_64-pc-windows-gnullvm`
@@ -16,48 +18,44 @@ Target triples available so far:
1618

1719
## Requirements
1820

19-
The easiest way to obtain these targets is cross-compilation, but native build from `x86_64-pc-windows-gnu` is possible with few hacks which I don't recommend.
20-
Std support is expected to be on par with `*-windows-gnu`.
21+
Building those targets requires an LLVM-based C toolchain, for example, [llvm-mingw][1] or [MSYS2][2] with CLANG*
22+
environment.
2123

22-
Binaries for this target should be at least on par with `*-windows-gnu` in terms of requirements and functionality.
24+
Binaries for this target should be at least on par with `*-windows-gnu` in terms of requirements and functionality,
25+
except for implicit self-contained mode (explained in [the section below](#building-rust-programs)).
2326

2427
Those targets follow Windows calling convention for `extern "C"`.
2528

2629
Like with any other Windows target, created binaries are in PE format.
2730

2831
## Building the target
2932

30-
These targets can be easily cross-compiled
31-
using [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) toolchain or [MSYS2 CLANG*](https://www.msys2.org/docs/environments/) environments.
32-
Just fill `[target.*]` sections for both build and resulting compiler and set installation prefix in `bootstrap.toml`.
33-
Then run `./x.py install`.
34-
In my case I had ran `./x.py install --host x86_64-pc-windows-gnullvm --target x86_64-pc-windows-gnullvm` inside MSYS2 MINGW64 shell
35-
so `x86_64-pc-windows-gnu` was my build toolchain.
36-
37-
Native bootstrapping is doable in two ways:
38-
- cross-compile gnullvm host toolchain and use it as build toolchain for the next build,
39-
- copy libunwind libraries and rename them to mimic libgcc like here: https://github.com/msys2/MINGW-packages/blob/68e640756df2df6df6afa60f025e3f936e7b977c/mingw-w64-rust/PKGBUILD#L108-L109, stage0 compiler will be mostly broken but good enough to build the next stage.
40-
41-
The second option might stop working anytime, so it's not recommended.
33+
Both native and cross-compilation builds are supported and function similarly to other Rust targets.
4234

4335
## Building Rust programs
4436

45-
Rust does ship a pre-compiled std library for those targets.
46-
That means one can easily cross-compile for those targets from other hosts if C proper toolchain is installed.
37+
Rust ships both std and host tools for those targets. That allows using them as both the host and the target.
4738

48-
Alternatively full toolchain can be built as described in the previous section.
39+
When used as the host and building pure Rust programs, no additional C toolchain is required.
40+
The only requirements are to install `rust-mingw` component and to set `rust-lld` as the linker.
41+
Otherwise, you will need to install the C toolchain mentioned previously.
42+
There is no automatic fallback to `rust-lld` when the C toolchain is missing yet, but it may be added in the future.
4943

5044
## Testing
5145

52-
Created binaries work fine on Windows or Wine using native hardware. Testing AArch64 on x86_64 is problematic though and requires spending some time with QEMU.
53-
Most of x86_64 testsuite does pass when cross-compiling,
54-
with exception for `rustdoc` and `ui-fulldeps` that fail with and error regarding a missing library,
55-
they do pass in native builds though.
56-
The only failing test is std's `process::tests::test_proc_thread_attributes` for unknown reason.
46+
Created binaries work fine on Windows and Linux with Wine using native hardware.
47+
Testing AArch64 on x86_64 is problematic, though, and requires launching a whole AArch64 system with QEMU.
48+
49+
Most of the x86_64 testsuite does pass, but because it isn't run on CI, different failures are expected over time.
5750

5851
## Cross-compilation toolchains and C code
5952

60-
Compatible C code can be built with Clang's `aarch64-pc-windows-gnu`, `i686-pc-windows-gnullvm` and `x86_64-pc-windows-gnu` targets as long as LLVM-based C toolchains are used.
61-
Those include:
62-
- [llvm-mingw](https://github.com/mstorsjo/llvm-mingw)
63-
- [MSYS2 with CLANG* environment](https://www.msys2.org/docs/environments)
53+
Compatible C code can be built with Clang's `aarch64-pc-windows-gnu`, `i686-pc-windows-gnullvm` and
54+
`x86_64-pc-windows-gnu` targets as long as LLVM-based C toolchains are used. Those include:
55+
56+
- [llvm-mingw][1]
57+
- [MSYS2][2] with CLANG* environment
58+
59+
[1]: https://github.com/mstorsjo/llvm-mingw
60+
61+
[2]: https://www.msys2.org/docs/environments

0 commit comments

Comments
 (0)