From 45d78ba21f6257ca6b0d12fbd33e9c619ebf41fd Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Tue, 23 Sep 2025 15:59:23 +0200 Subject: [PATCH] Test a few tier 3 targets Signed-off-by: Jens Reidel --- .github/workflows/ci.yaml | 60 +++++++++++++++++++ ci/docker/s390x-unknown-linux-musl/Dockerfile | 31 ++++++---- ci/install-rust.sh | 8 +-- ctest/src/macro_expansion.rs | 5 +- 4 files changed, 88 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bd3fe9a262a60..438cd7abded3e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -277,6 +277,66 @@ jobs: path: ${{ env.ARCHIVE_PATH }} retention-days: 5 + test_tier3: + name: Test tier3 + #needs: [test_tier2, style_check] + runs-on: ubuntu-24.04 + strategy: + fail-fast: true + max-parallel: 12 + matrix: + target: + # We test a handful of tier 3 targets that are known to be well-maintained + #- mips64-unknown-linux-muslabi64 + #- powerpc64-unknown-linux-musl + #- riscv64gc-unknown-linux-musl + - s390x-unknown-linux-musl + include: + #- target: mips64-unknown-linux-muslabi64 + # env: + # RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + #- target: powerpc64-unknown-linux-musl + # env: + # RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + #- target: riscv64gc-unknown-linux-musl + # env: + # RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: s390x-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + timeout-minutes: 25 + env: + INSTALL_RUST_SRC: 1 + LIBC_CI_ZBUILD_STD: 1 + TARGET: ${{ matrix.target }} + steps: + - uses: actions/checkout@v5 + - name: Setup Rust toolchain + run: ./ci/install-rust.sh + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + - name: Add matrix env variables to the environment + if: matrix.env + run: | + echo '${{ toJson(matrix.env) }}' | + jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV + shell: bash + + - name: Execute run-docker.sh + run: ./ci/run-docker.sh ${{ matrix.target }} + + - name: Create CI artifacts + id: create_artifacts + if: always() + run: ./ci/create-artifacts.py + - uses: actions/upload-artifact@v4 + if: always() && steps.create_artifacts.outcome == 'success' + with: + name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} + path: ${{ env.ARCHIVE_PATH }} + retention-days: 5 + test_tier2_vm: name: Test tier2 VM needs: [test_tier1, style_check] diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 0dfad20fb7a1d..2e9830f84f290 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -1,18 +1,29 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc \ - gcc-s390x-linux-gnu \ - qemu-user \ - xz-utils patch rsync + gcc make libc6-dev git curl ca-certificates \ + gcc-s390x-linux-gnu qemu-user xz-utils patch rsync + +# Set up an Alpine sysroot for acquiring libgcc and libgcc_s +RUN curl https://repo.chimera-linux.org/apk/3.0.0_rc4-r2/apk-x86_64.static -o /usr/bin/apk && \ + chmod +x /usr/bin/apk && \ + mkdir /alpine-sysroot && \ + apk \ + --arch s390x \ + --root /alpine-sysroot \ + --repository https://dl-cdn.alpinelinux.org/alpine/v3.22/main \ + add \ + --initdb \ + --allow-untrusted \ + --no-scripts \ + alpine-baselayout libgcc COPY install-musl.sh / RUN /install-musl.sh s390x # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? -ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ - CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /musl-s390x" \ - CC_s390x_unknown_linux_gnu=musl-gcc \ - RUSTFLAGS='-Clink-args=-lgcc -L /musl-s390x/lib' \ - PATH=$PATH:/musl-s390x/bin:/rust/bin +ENV PATH=$PATH:/musl-s390x/bin:/rust/bin \ + CC_s390x_unknown_linux_musl=musl-gcc \ + RUSTFLAGS='-Clink-args=-lgcc -L/alpine-sysroot/usr/lib -L /musl-s390x/lib' \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_MUSL_RUNNER="qemu-s390x -L /musl-s390x" diff --git a/ci/install-rust.sh b/ci/install-rust.sh index 69e8ba97a5d3d..def105d2c1c73 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -27,14 +27,12 @@ rustup set profile minimal rustup update --force "$toolchain" --no-self-update rustup default "$toolchain" -if [ -n "${TARGET:-}" ]; then - echo "Install target" - rustup target add "$TARGET" -fi - if [ -n "${INSTALL_RUST_SRC:-}" ]; then echo "Install rust-src" rustup component add rust-src +elif [ -n "${TARGET:-}" ]; then + echo "Install target" + rustup target add "$TARGET" fi if [ "$os" = "windows" ]; then diff --git a/ctest/src/macro_expansion.rs b/ctest/src/macro_expansion.rs index 9c46e047e903e..d0054b9eba815 100644 --- a/ctest/src/macro_expansion.rs +++ b/ctest/src/macro_expansion.rs @@ -3,7 +3,7 @@ use std::fs::canonicalize; use std::path::Path; use std::process::Command; -use crate::{EDITION, Result}; +use crate::{EDITION, GenerationError, Result}; /// Use rustc to expand all macros and pretty print the crate into a single file. pub fn expand>( @@ -12,10 +12,13 @@ pub fn expand>( target: String, ) -> Result { let rustc = env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); + let out_dir = + env::var("OUT_DIR").map_err(|_| GenerationError::EnvVarNotFound("OUT_DIR".to_string()))?; let mut cmd = Command::new(rustc); cmd.env("RUSTC_BOOTSTRAP", "1") .arg("-Zunpretty=expanded") + .arg(format!("-L{out_dir}/../../../deps")) .arg("--edition") .arg(EDITION) // By default, -Zunpretty=expanded uses 2015 edition. .arg(canonicalize(crate_path)?);