Skip to content

Commit 14b18e9

Browse files
committed
Provide prebuilt std for gnullvm targets
1 parent 1e4f9e3 commit 14b18e9

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

+10-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ RUN ./install-riscv64-none-elf.sh
5555
COPY host-x86_64/dist-various-1/install-riscv32-none-elf.sh /build
5656
RUN ./install-riscv32-none-elf.sh
5757

58+
COPY host-x86_64/dist-various-1/install-llvm-mingw.sh /build
59+
RUN ./install-llvm-mingw.sh
60+
5861
# Suppress some warnings in the openwrt toolchains we downloaded
5962
ENV STAGING_DIR=/tmp
6063

@@ -110,6 +113,9 @@ ENV TARGETS=$TARGETS,armv7r-none-eabi
110113
ENV TARGETS=$TARGETS,armv7r-none-eabihf
111114
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
112115
ENV TARGETS=$TARGETS,armv7a-none-eabi
116+
ENV TARGETS=$TARGETS,aarch64-pc-windows-gnullvm
117+
ENV TARGETS=$TARGETS,i686-pc-windows-gnullvm
118+
ENV TARGETS=$TARGETS,x86_64-pc-windows-gnullvm
113119

114120
ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" \
115121
CFLAGS_arm_unknown_linux_musleabi="-march=armv6 -marm" \
@@ -139,7 +145,10 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft
139145
CC_riscv64imac_unknown_none_elf=riscv64-unknown-elf-gcc \
140146
CFLAGS_riscv64imac_unknown_none_elf=-march=rv64imac -mabi=lp64 \
141147
CC_riscv64gc_unknown_none_elf=riscv64-unknown-elf-gcc \
142-
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64
148+
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64 \
149+
CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \
150+
CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \
151+
CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang
143152

144153
ENV RUST_CONFIGURE_ARGS \
145154
--musl-root-armv5te=/musl-armv5te \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
archive=llvm-mingw-20231128-ucrt-ubuntu-20.04-x86_64.tar.xz
6+
curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/${archive} | \
7+
tar --extract --lzma --strip 1 --directory /usr/local
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \*-pc-windows-gnullvm
22

3-
**Tier: 3**
3+
**Tier: 2 (without host tools)**
44

55
Windows targets similar to `*-pc-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of GCC/Binutils.
66

@@ -12,38 +12,52 @@ Target triples available so far:
1212
## Target maintainers
1313

1414
- [@mati865](https://github.com/mati865)
15+
- [@thomcc](https://github.com/thomcc)
1516

1617
## Requirements
1718

18-
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.
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.
1920
Std support is expected to be on pair with `*-pc-windows-gnu`.
2021

2122
Binaries for this target should be at least on pair with `*-pc-windows-gnu` in terms of requirements and functionality.
2223

2324
Those targets follow Windows calling convention for `extern "C"`.
2425

25-
Like with any other Windows target created binaries are in PE format.
26+
Like with any other Windows target, created binaries are in PE format.
2627

2728
## Building the target
2829

29-
For cross-compilation I recommend using [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) toolchain, one change that seems necessary beside configuring cross compilers is disabling experimental `m86k` target. Otherwise LLVM build fails with `multiple definition ...` errors.
30-
Native bootstrapping builds require rather fragile hacks until host artifacts are available so I won't describe them here.
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 `config.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.
3142

3243
## Building Rust programs
3344

34-
Rust does not yet ship pre-compiled artifacts for this target. To compile for
35-
this target, you will either need to build Rust with the target enabled (see
36-
"Building the target" above), or build your own copy of `core` by using
37-
`build-std` or similar.
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.
47+
48+
Alternatively full toolchain can be built as described in the previous section.
3849

3950
## Testing
4051

4152
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.
42-
Once these targets bootstrap themselves on native hardware they should pass Rust testsuite.
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.
4357

4458
## Cross-compilation toolchains and C code
4559

46-
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.
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.
4761
Those include:
4862
- [llvm-mingw](https://github.com/mstorsjo/llvm-mingw)
4963
- [MSYS2 with CLANG* environment](https://www.msys2.org/docs/environments)

tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//@ only-gnu
44
//@ only-windows
55
//@ needs-dlltool
6+
//@ ignore-llvm
67
//@ compile-flags: --crate-type lib --emit link
78
//@ normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
89
//@ normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"

tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
//@ only-gnu
44
//@ only-windows
5+
//@ ignore-llvm
56
//@ compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe
67
#[link(name = "foo", kind = "raw-dylib")]
78
extern "C" {

0 commit comments

Comments
 (0)