Skip to content

Commit 34c404a

Browse files
committed
Auto merge of rust-lang#140772 - mati865:gnullvm-host, r=<try>
{aarch64,x86_64}-*-windows-gnullvm: build host tools This will require MCP, but I suppose we need to know how long it takes to build first. I opted for bootstrapping from Linux because that's the easiest host system to work with, but once this hits beta, having dedicated Windows runners would be sensible and probably preferable. `--enable-full-tools` for whatever reason doesn't seem to work when cross-compiling, because LLVM tools for the new hosts are not copied into the expected directory. And WiX that bootstrap relies upon to create .msi installers only supports Windows. I haven't tried, but it might be usable via Wine. Almost every commit is self-contained, so let me know if I should split them into separate PRs. try-job: dist-windows-gnullvm
2 parents c79bbfa + b256449 commit 34c404a

File tree

9 files changed

+77
-21
lines changed

9 files changed

+77
-21
lines changed

compiler/rustc_llvm/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ fn main() {
228228
let mut cmd = Command::new(&llvm_config);
229229
cmd.arg(llvm_link_arg).arg("--libs");
230230

231-
// Don't link system libs if cross-compiling unless targeting Windows.
231+
// Don't link system libs if cross-compiling unless targeting Windows from Windows host.
232232
// On Windows system DLLs aren't linked directly, instead import libraries are used.
233233
// These import libraries are independent of the host.
234-
if !is_crossed || target.contains("windows") {
234+
if !is_crossed || target.contains("windows") && host.contains("windows") {
235235
cmd.arg("--system-libs");
236236
}
237237

src/bootstrap/src/core/build_steps/compile.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1409,20 +1409,22 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
14091409
cargo.env("LLVM_LINKER_FLAGS", llvm_linker_flags);
14101410
}
14111411

1412-
// Building with a static libstdc++ is only supported on linux right now,
1412+
// Building with a static libstdc++ is only supported on Linux and windows-gnu* right now,
14131413
// not for MSVC or macOS
14141414
if builder.config.llvm_static_stdcpp
14151415
&& !target.contains("freebsd")
14161416
&& !target.is_msvc()
14171417
&& !target.contains("apple")
14181418
&& !target.contains("solaris")
14191419
{
1420+
let libstdcxx_name =
1421+
if target.contains("windows-gnullvm") { "libc++.a" } else { "libstdc++.a" };
14201422
let file = compiler_file(
14211423
builder,
14221424
&builder.cxx(target).unwrap(),
14231425
target,
14241426
CLang::Cxx,
1425-
"libstdc++.a",
1427+
libstdcxx_name,
14261428
);
14271429
cargo.env("LLVM_STATIC_STDCPP", file);
14281430
}

src/bootstrap/src/core/build_steps/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ impl Step for Extended {
16801680
cmd.run(builder);
16811681
}
16821682

1683-
if target.is_windows() {
1683+
if target.is_windows() && self.host.is_windows() {
16841684
let exe = tmp.join("exe");
16851685
let _ = fs::remove_dir_all(&exe);
16861686

src/bootstrap/src/core/build_steps/llvm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ impl Step for Llvm {
285285
LlvmBuildStatus::ShouldBuild(m) => m,
286286
};
287287

288-
if builder.llvm_link_shared() && target.is_windows() {
288+
if builder.llvm_link_shared() && target.is_windows() && !target.ends_with("windows-gnullvm")
289+
{
289290
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
290291
}
291292

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ ENV TARGETS=$TARGETS,armv7r-none-eabi
114114
ENV TARGETS=$TARGETS,armv7r-none-eabihf
115115
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
116116
ENV TARGETS=$TARGETS,armv7a-none-eabi
117-
ENV TARGETS=$TARGETS,aarch64-pc-windows-gnullvm
118-
ENV TARGETS=$TARGETS,i686-pc-windows-gnullvm
119-
ENV TARGETS=$TARGETS,x86_64-pc-windows-gnullvm
120117

121118
ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" \
122119
CFLAGS_arm_unknown_linux_musleabi="-march=armv6 -marm" \
@@ -148,10 +145,7 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft
148145
CC_riscv64imac_unknown_none_elf=riscv64-unknown-elf-gcc \
149146
CFLAGS_riscv64imac_unknown_none_elf=-march=rv64imac -mabi=lp64 \
150147
CC_riscv64gc_unknown_none_elf=riscv64-unknown-elf-gcc \
151-
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64 \
152-
CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \
153-
CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \
154-
CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang
148+
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64
155149

156150
ENV RUST_CONFIGURE_ARGS \
157151
--musl-root-armv5te=/musl-armv5te \

src/ci/docker/host-x86_64/dist-various-1/install-llvm-mingw.sh

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM ubuntu:22.04
2+
3+
WORKDIR /build
4+
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
ca-certificates \
8+
cmake \
9+
curl \
10+
g++ \
11+
git \
12+
make \
13+
ninja-build \
14+
python3 \
15+
xz-utils
16+
17+
COPY host-x86_64/dist-windows-gnullvm/install-llvm-mingw.sh /build
18+
RUN ./install-llvm-mingw.sh
19+
20+
COPY scripts/sccache.sh /scripts/
21+
RUN sh /scripts/sccache.sh
22+
23+
ENV CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \
24+
CXX_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang++ \
25+
CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \
26+
CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang \
27+
CXX_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang++
28+
29+
ENV HOSTS=aarch64-pc-windows-gnullvm,x86_64-pc-windows-gnullvm
30+
ENV TARGETS=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm,x86_64-pc-windows-gnullvm
31+
32+
# We are bootstrapping this target and cannot use previously built artifacts.
33+
# Without this option Clang is given `"-I/checkout/obj/build/aarch64-pc-windows-gnullvm/ci-llvm/include"`
34+
# despite no such directory existing:
35+
# ❯ ls obj/dist-windows-gnullvm/build/aarch64-pc-windows-gnullvm/ -1
36+
#  llvm
37+
#  stage2
38+
ENV NO_DOWNLOAD_CI_LLVM 1
39+
40+
ENV RUST_CONFIGURE_ARGS \
41+
--enable-extended \
42+
--enable-profiler \
43+
--enable-sanitizers \
44+
--disable-docs \
45+
--set llvm.download-ci-llvm=false \
46+
--set rust.llvm-tools=false
47+
# LLVM cross tools are not installed into expected location so copying fails.
48+
# Probably will solve itself when building from Windows.
49+
# --enable-full-tools \
50+
51+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
release_date=20250430
6+
archive=llvm-mingw-${release_date}-ucrt-ubuntu-22.04-x86_64.tar.xz
7+
curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/${release_date}/${archive} | \
8+
tar --extract --xz --strip 1 --directory /usr/local
9+
10+
# https://github.com/mstorsjo/llvm-mingw/issues/493
11+
for arch in aarch64 x86_64; do
12+
ln -s $arch-w64-windows-gnu.cfg /usr/local/bin/$arch-pc-windows-gnu.cfg
13+
done

src/ci/github-actions/jobs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ auto:
206206
- name: dist-s390x-linux
207207
<<: *job-linux-4c
208208

209+
- name: dist-windows-gnullvm
210+
<<: *job-linux-4c
211+
209212
- name: dist-various-1
210213
<<: *job-linux-4c
211214

0 commit comments

Comments
 (0)