Skip to content

{aarch64,x86_64}-*-windows-gnullvm: build host tools #140772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ fn main() {
let mut cmd = Command::new(&llvm_config);
cmd.arg(llvm_link_arg).arg("--libs");

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

Expand Down
6 changes: 4 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,20 +1409,22 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
cargo.env("LLVM_LINKER_FLAGS", llvm_linker_flags);
}

// Building with a static libstdc++ is only supported on linux right now,
// Building with a static libstdc++ is only supported on Linux and windows-gnu* right now,
// not for MSVC or macOS
if builder.config.llvm_static_stdcpp
&& !target.contains("freebsd")
&& !target.is_msvc()
&& !target.contains("apple")
&& !target.contains("solaris")
{
let libstdcxx_name =
if target.contains("windows-gnullvm") { "libc++.a" } else { "libstdc++.a" };
let file = compiler_file(
builder,
&builder.cxx(target).unwrap(),
target,
CLang::Cxx,
"libstdc++.a",
libstdcxx_name,
);
cargo.env("LLVM_STATIC_STDCPP", file);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ impl Step for Extended {
cmd.run(builder);
}

if target.is_windows() {
if target.is_windows() && self.host.is_windows() {
let exe = tmp.join("exe");
let _ = fs::remove_dir_all(&exe);

Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ impl Step for Llvm {
LlvmBuildStatus::ShouldBuild(m) => m,
};

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

Expand Down
8 changes: 1 addition & 7 deletions src/ci/docker/host-x86_64/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ ENV TARGETS=$TARGETS,armv7r-none-eabi
ENV TARGETS=$TARGETS,armv7r-none-eabihf
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
ENV TARGETS=$TARGETS,armv7a-none-eabi
ENV TARGETS=$TARGETS,aarch64-pc-windows-gnullvm
ENV TARGETS=$TARGETS,i686-pc-windows-gnullvm
ENV TARGETS=$TARGETS,x86_64-pc-windows-gnullvm

ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" \
CFLAGS_arm_unknown_linux_musleabi="-march=armv6 -marm" \
Expand Down Expand Up @@ -148,10 +145,7 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft
CC_riscv64imac_unknown_none_elf=riscv64-unknown-elf-gcc \
CFLAGS_riscv64imac_unknown_none_elf=-march=rv64imac -mabi=lp64 \
CC_riscv64gc_unknown_none_elf=riscv64-unknown-elf-gcc \
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64 \
CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \
CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \
CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang
CFLAGS_riscv64gc_unknown_none_elf=-march=rv64gc -mabi=lp64

ENV RUST_CONFIGURE_ARGS \
--musl-root-armv5te=/musl-armv5te \
Expand Down

This file was deleted.

51 changes: 51 additions & 0 deletions src/ci/docker/host-x86_64/dist-windows-gnullvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:22.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

COPY host-x86_64/dist-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++ \
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 HOSTS=aarch64-pc-windows-gnullvm,x86_64-pc-windows-gnullvm
ENV TARGETS=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm,x86_64-pc-windows-gnullvm

# We are bootstrapping this target and cannot use previously built artifacts.
# Without this option Clang is given `"-I/checkout/obj/build/aarch64-pc-windows-gnullvm/ci-llvm/include"`
# despite no such directory existing:
# ❯ ls obj/dist-windows-gnullvm/build/aarch64-pc-windows-gnullvm/ -1
#  llvm
#  stage2
ENV NO_DOWNLOAD_CI_LLVM 1

ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-profiler \
--enable-sanitizers \
--disable-docs \
--set llvm.download-ci-llvm=false \
--set rust.llvm-tools=false
# LLVM cross tools are not installed into expected location so copying fails.
# Probably will solve itself when building from Windows.
# --enable-full-tools \

ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -ex

release_date=20250430
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 aarch64 x86_64; do
ln -s $arch-w64-windows-gnu.cfg /usr/local/bin/$arch-pc-windows-gnu.cfg
done
Loading