From 77caef1d81ff92866dd7c866b9bce5848bba26af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sun, 9 Nov 2025 16:01:59 +0100 Subject: [PATCH] Build gnullvm toolchains on Windows natively --- src/bootstrap/src/core/build_steps/dist.rs | 14 +----- .../dist-aarch64-windows-gnullvm/Dockerfile | 35 --------------- .../dist-x86_64-windows-gnullvm/Dockerfile | 37 ---------------- .../install-llvm-mingw.sh | 13 ------ src/ci/github-actions/jobs.yml | 28 +++++++++--- src/ci/scripts/install-mingw.sh | 43 +++++++++++++++---- 6 files changed, 58 insertions(+), 112 deletions(-) delete mode 100644 src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile delete mode 100644 src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile delete mode 100755 src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 411d42962644d..f63dc879dadd8 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -300,7 +300,7 @@ fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder return; } - let (bin_path, libs_path) = get_cc_search_dirs(target, builder); + let (bin_path, _) = get_cc_search_dirs(target, builder); let mut rustc_dlls = vec![]; // windows-gnu and windows-gnullvm require different runtime libs @@ -316,15 +316,6 @@ fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder } else { panic!("Vendoring of runtime DLLs for `{target}` is not supported`"); } - // FIXME(#144656): Remove this whole `let ...` - let bin_path = if target.ends_with("windows-gnullvm") && builder.host_target != target { - bin_path - .into_iter() - .chain(libs_path.iter().map(|path| path.with_file_name("bin"))) - .collect() - } else { - bin_path - }; let rustc_dlls = find_files(&rustc_dlls, &bin_path); // Copy runtime dlls next to rustc.exe @@ -1824,8 +1815,7 @@ impl Step for Extended { cmd.run(builder); } - // FIXME(mati865): `gnullvm` here is temporary, remove it once it can host itself - if target.is_windows() && !target.contains("gnullvm") { + if target.is_windows() { let exe = tmp.join("exe"); let _ = fs::remove_dir_all(&exe); diff --git a/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile b/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile deleted file mode 100644 index 0bb51af817ab2..0000000000000 --- a/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /build - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - g++ \ - git \ - make \ - ninja-build \ - python3 \ - xz-utils - -ENV ARCH=aarch64 -COPY host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh /build -RUN ./install-llvm-mingw.sh - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -ENV CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \ - CXX_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang++ - -ENV HOST=aarch64-pc-windows-gnullvm - -ENV RUST_CONFIGURE_ARGS \ - --enable-full-tools \ - --enable-profiler \ - --enable-sanitizers \ - --disable-docs - -ENV SCRIPT python3 ../x.py dist --host $HOST --target $HOST diff --git a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile deleted file mode 100644 index da0c065c8547e..0000000000000 --- a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /build - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - g++ \ - git \ - make \ - ninja-build \ - python3 \ - xz-utils - -ENV ARCH='i686 x86_64' -COPY host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh /build -RUN ./install-llvm-mingw.sh - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -ENV CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \ - CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang \ - CXX_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang++ - -ENV HOST=x86_64-pc-windows-gnullvm -ENV TARGETS=i686-pc-windows-gnullvm,x86_64-pc-windows-gnullvm - -ENV RUST_CONFIGURE_ARGS \ - --enable-full-tools \ - --enable-profiler \ - --enable-sanitizers \ - --disable-docs - -ENV SCRIPT python3 ../x.py dist --host $HOST --target $TARGETS diff --git a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh b/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh deleted file mode 100755 index 0ea5dae3ffbd9..0000000000000 --- a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -release_date=20250613 -archive=llvm-mingw-${release_date}-ucrt-ubuntu-22.04-x86_64.tar.xz -curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/${release_date}/${archive} | \ -tar --extract --xz --strip 1 --directory /usr/local - -# https://github.com/mstorsjo/llvm-mingw/issues/493 -for arch in $ARCH; do - ln -s $arch-w64-windows-gnu.cfg /usr/local/bin/$arch-pc-windows-gnu.cfg -done diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 33de0b09d94d1..5856a70c4803a 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -247,12 +247,6 @@ auto: - name: dist-s390x-linux <<: *job-linux-4c - - name: dist-aarch64-windows-gnullvm - <<: *job-linux-4c - - - name: dist-x86_64-windows-gnullvm - <<: *job-linux-4c - - name: dist-various-1 <<: *job-linux-4c @@ -689,6 +683,28 @@ auto: CODEGEN_BACKENDS: llvm,cranelift <<: *job-windows + - name: dist-aarch64-llvm-mingw + env: + SCRIPT: python x.py dist bootstrap --include-default-paths + RUST_CONFIGURE_ARGS: >- + --build=aarch64-pc-windows-gnullvm + --enable-full-tools + --enable-profiler + DIST_REQUIRE_ALL_TOOLS: 1 + CODEGEN_BACKENDS: llvm,cranelift + <<: *job-windows + + - name: dist-x86_64-llvm-mingw + env: + SCRIPT: python x.py dist bootstrap --include-default-paths + RUST_CONFIGURE_ARGS: >- + --build=x86_64-pc-windows-gnullvm + --enable-full-tools + --enable-profiler + DIST_REQUIRE_ALL_TOOLS: 1 + CODEGEN_BACKENDS: llvm,cranelift + <<: *job-windows + - name: dist-x86_64-msvc-alt env: RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index ed87628659b41..f49ec8e6a9108 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -8,22 +8,36 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" MINGW_ARCHIVE_32="i686-14.1.0-release-posix-dwarf-msvcrt-rt_v12-rev0.7z" MINGW_ARCHIVE_64="x86_64-14.1.0-release-posix-seh-msvcrt-rt_v12-rev0.7z" +LLVM_MINGW_ARCHIVE_AARCH64="llvm-mingw-20251104-ucrt-aarch64.zip" +LLVM_MINGW_ARCHIVE_X86_64="llvm-mingw-20251104-ucrt-x86_64.zip" if isWindows && isKnownToBeMingwBuild; then case "${CI_JOB_NAME}" in + *aarch64-llvm*) + mingw_dir="clangarm64" + mingw_archive="${LLVM_MINGW_ARCHIVE_AARCH64}" + # Temporary workaround: https://github.com/mstorsjo/llvm-mingw/issues/493 + mkdir -p $mingw_dir/bin + ln -s aarch64-w64-windows-gnu.cfg $mingw_dir/bin/aarch64-pc-windows-gnu.cfg + ;; + *x86_64-llvm*) + mingw_dir="clang64" + mingw_archive="${LLVM_MINGW_ARCHIVE_X86_64}" + # Temporary workaround: https://github.com/mstorsjo/llvm-mingw/issues/493 + mkdir -p $mingw_dir/bin + ln -s x86_64-w64-windows-gnu.cfg $mingw_dir/bin/x86_64-pc-windows-gnu.cfg + ;; *i686*) - bits=32 + mingw_dir="mingw32" mingw_archive="${MINGW_ARCHIVE_32}" ;; *x86_64*) - bits=64 + mingw_dir="mingw64" mingw_archive="${MINGW_ARCHIVE_64}" ;; *aarch64*) - # aarch64 is a cross-compiled target. Use the x86_64 - # mingw, since that's the host architecture. - bits=64 - mingw_archive="${MINGW_ARCHIVE_64}" + echo "AArch64 Windows is not supported by GNU tools" + exit 1 ;; *) echo "src/ci/scripts/install-mingw.sh can't detect the builder's architecture" @@ -38,10 +52,21 @@ if isWindows && isKnownToBeMingwBuild; then msys2Path="c:/msys64" ciCommandAddPath "${msys2Path}/usr/bin" - mingw_dir="mingw${bits}" + case "${mingw_archive}" in + *.7z) + curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}" + 7z x -y mingw.7z > /dev/null + ;; + *.zip) + curl -o mingw.zip "${MIRRORS_BASE}/${mingw_archive}" + 7z -d $mingw_dir mingw.zip > /dev/null + ;; + *) + echo "Unrecognized archive type" + exit 1 + ;; + esac - curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}" - 7z x -y mingw.7z > /dev/null ciCommandAddPath "$(cygpath -m "$(pwd)/${mingw_dir}/bin")" # Initialize mingw for the user.