From 4c96512634b3d957c84114aa4d0324a6e91b2e30 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 03:33:59 -0500 Subject: [PATCH 01/13] ci: Rename main workflow and use .yaml extension We no longer have two separate workflows, so rename `full_ci` to just `ci`. Additionally, `.yaml` is the preferred extension [1], so rename the other `.yml` file to `.yaml`. [1]: https://yaml.org/faq.html --- .github/{dependabot.yml => dependabot.yaml} | 0 .github/workflows/{full_ci.yml => ci.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{dependabot.yml => dependabot.yaml} (100%) rename .github/workflows/{full_ci.yml => ci.yaml} (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yaml diff --git a/.github/workflows/full_ci.yml b/.github/workflows/ci.yaml similarity index 100% rename from .github/workflows/full_ci.yml rename to .github/workflows/ci.yaml From 4707c5db583477e83961eef1b40df2fe5e016fe4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 03:46:47 -0500 Subject: [PATCH 02/13] ci: Use `./` with shebangs rather than `sh` or `bash` The scripts say how they should execute, there isn't any reason to duplicate this wherever they are called. --- .github/workflows/ci.yaml | 38 ++++++++++--------- CONTRIBUTING.md | 2 +- ci/android-install-ndk.sh | 0 ci/android-install-sdk.sh | 0 ci/android-sysimage.sh | 0 ci/build.sh | 2 +- ci/docker/aarch64-linux-android/Dockerfile | 4 +- .../aarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 4 +- .../arm-unknown-linux-musleabihf/Dockerfile | 2 +- ci/docker/asmjs-unknown-emscripten/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 4 +- ci/docker/i686-unknown-linux-musl/Dockerfile | 2 +- .../loongarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-musl/Dockerfile | 2 +- .../sparc64-unknown-linux-gnu/Dockerfile | 2 +- .../wasm32-unknown-emscripten/Dockerfile | 2 +- ci/docker/wasm32-wasip1/Dockerfile | 2 +- ci/docker/wasm32-wasip2/Dockerfile | 2 +- ci/docker/x86_64-linux-android/Dockerfile | 4 +- .../x86_64-unknown-linux-musl/Dockerfile | 2 +- ci/emscripten.sh | 0 ci/install-musl-cross.sh | 0 ci/install-musl.sh | 0 ci/install-rust.sh | 0 ci/linux-s390x.sh | 0 ci/linux-sparc64.sh | 0 ci/wasi.sh | 0 29 files changed, 43 insertions(+), 39 deletions(-) mode change 100644 => 100755 ci/android-install-ndk.sh mode change 100644 => 100755 ci/android-install-sdk.sh mode change 100644 => 100755 ci/android-sysimage.sh mode change 100644 => 100755 ci/build.sh mode change 100644 => 100755 ci/emscripten.sh mode change 100644 => 100755 ci/install-musl-cross.sh mode change 100644 => 100755 ci/install-musl.sh mode change 100644 => 100755 ci/install-rust.sh mode change 100644 => 100755 ci/linux-s390x.sh mode change 100644 => 100755 ci/linux-sparc64.sh mode change 100644 => 100755 ci/wasi.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3d60b36c61a55..1f8ed0ee33de8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,10 @@ env: CARGO_TERM_VERBOSE: true LIBC_CI: 1 +defaults: + run: + shell: bash + jobs: style_check: name: Style check @@ -16,9 +20,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: sh ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Check style - run: sh ci/style.sh + run: ./ci/style.sh build_channels_linux: name: Build Channels Linux @@ -37,9 +41,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/install-rust.sh + run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/install-rust.sh - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh + run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/build.sh build_channels_macos: name: Build Channels macOS @@ -59,9 +63,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/install-rust.sh + run: TOOLCHAIN=${{ matrix.target.toolchain }} ./ci/install-rust.sh - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/build.sh + run: TOOLCHAIN=${{ matrix.target.toolchain }} ./ci/build.sh build_channels_windows: name: Build Channels Windows @@ -80,7 +84,7 @@ jobs: run: rustup self update shell: bash - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh + run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/build.sh shell: bash macos: @@ -94,9 +98,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + run: TARGET=${{ matrix.target }} ./ci/install-rust.sh - name: Execute run.sh - run: sh ./ci/run.sh ${{ matrix.target }} + run: ./ci/run.sh ${{ matrix.target }} windows: name: Windows @@ -124,10 +128,10 @@ jobs: run: rustup self update shell: bash - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + run: TARGET=${{ matrix.target }} ./ci/install-rust.sh shell: bash - name: Execute run.sh - run: sh ./ci/run.sh ${{ matrix.target }} + run: ./ci/run.sh ${{ matrix.target }} shell: bash @@ -143,9 +147,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + run: TARGET=${{ matrix.target }} ./ci/install-rust.sh - name: Execute run-docker.sh - run: sh ./ci/run-docker.sh ${{ matrix.target }} + run: ./ci/run-docker.sh ${{ matrix.target }} docker_linux_tier2: name: Docker Linux Tier2 @@ -185,9 +189,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + run: TARGET=${{ matrix.target }} ./ci/install-rust.sh - name: Execute run-docker.sh - run: sh ./ci/run-docker.sh ${{ matrix.target }} + run: ./ci/run-docker.sh ${{ matrix.target }} solaris: name: Solaris @@ -214,7 +218,7 @@ jobs: uname -a run: | export PATH=$HOME/.rust_solaris/bin:$PATH - bash ./ci/run.sh ${{ matrix.target }} + ./ci/run.sh ${{ matrix.target }} check_cfg: name: "Check #[cfg]s" @@ -222,7 +226,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=nightly sh ./ci/install-rust.sh + run: TOOLCHAIN=nightly ./ci/install-rust.sh - name: Build with check-cfg run: LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2090a0aaa689e..74f49f3e7bb04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,7 +93,7 @@ We have two automated tests running on - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker - - [`sh ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) + - [`./ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) ## Breaking change policy diff --git a/ci/android-install-ndk.sh b/ci/android-install-ndk.sh old mode 100644 new mode 100755 diff --git a/ci/android-install-sdk.sh b/ci/android-install-sdk.sh old mode 100644 new mode 100755 diff --git a/ci/android-sysimage.sh b/ci/android-sysimage.sh old mode 100644 new mode 100755 diff --git a/ci/build.sh b/ci/build.sh old mode 100644 new mode 100755 index f9c81beb19672..13b71c6735297 --- a/ci/build.sh +++ b/ci/build.sh @@ -199,7 +199,7 @@ esac for target in $targets; do if echo "$target" | grep -q "$filter"; then if [ "${OS}" = "windows" ]; then - TARGET="$target" sh ./ci/install-rust.sh + TARGET="$target" ./ci/install-rust.sh test_target build "$target" else test_target build "$target" diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index d6927e5cc80ec..dfd63718a9d0d 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=aarch64 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index fd4c1e28f2525..65932bd48cfac 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-aarch64-linux-gnu qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh aarch64 +RUN /install-musl.sh aarch64 # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 9d6a5c9649832..82f89f48e915c 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=arm ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index f8a5d27df3b5f..7ed23611c351e 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -8,7 +8,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ gcc-arm-linux-gnueabihf qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh arm +RUN /install-musl.sh arm ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ CC_arm_unknown_linux_musleabihf=musl-gcc \ diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index 6f2d5ddfc78e1..085e45ff35ee6 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get install -y --no-install-recommends \ bzip2 COPY emscripten.sh / -RUN bash /emscripten.sh +RUN /emscripten.sh ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index 0fb48aca342d4..8a159cd0502b5 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=i686 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index 4f36d2075485c..ea5e2e963910b 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -9,7 +9,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 COPY install-musl.sh / -RUN sh /install-musl.sh i686 +RUN /install-musl.sh i686 ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ CC_i686_unknown_linux_musl=musl-gcc \ diff --git a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile index 2efd095b0fddd..f4a23a6666c8a 100644 --- a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl gcc git libc6-dev make qemu-user xz-utils COPY install-musl-cross.sh / -RUN sh /install-musl-cross.sh loongarch64-unknown-linux-musl +RUN /install-musl-cross.sh loongarch64-unknown-linux-musl ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER=loongarch64-unknown-linux-musl-gcc \ CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-loongarch64" \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 306d773a61165..dde2ef24254fc 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cpio COPY linux-s390x.sh / -RUN bash /linux-s390x.sh +RUN /linux-s390x.sh COPY test-runner-linux / diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index d103a1d7488e0..4e202d1905902 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh s390x +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 \ diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index 4aff82ee46631..16b930f95a834 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ p7zip-full cpio linux-libc-dev-sparc64-cross COPY linux-sparc64.sh / -RUN bash /linux-sparc64.sh +RUN /linux-sparc64.sh COPY test-runner-linux / diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 5af38ca5258db..0f9cb85dc30e8 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -26,7 +26,7 @@ RUN apt-get install -y --no-install-recommends \ RUN ln -s /usr/bin/python3 /usr/bin/python & \ ln -s /usr/bin/pip3 /usr/bin/pip COPY emscripten.sh / -RUN bash /emscripten.sh +RUN /emscripten.sh ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh diff --git a/ci/docker/wasm32-wasip1/Dockerfile b/ci/docker/wasm32-wasip1/Dockerfile index 68940f4615a7e..e85b27ff82099 100644 --- a/ci/docker/wasm32-wasip1/Dockerfile +++ b/ci/docker/wasm32-wasip1/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:24.10 COPY wasi.sh / -RUN bash /wasi.sh +RUN /wasi.sh # Note that `-D_WASI_EMULATED_PROCESS_CLOCKS` is used to enable access to # clock-related defines even though they're emulated. Also note that the usage diff --git a/ci/docker/wasm32-wasip2/Dockerfile b/ci/docker/wasm32-wasip2/Dockerfile index 7abaaf54da02d..be6bff3a843c5 100644 --- a/ci/docker/wasm32-wasip2/Dockerfile +++ b/ci/docker/wasm32-wasip2/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:24.10 COPY wasi.sh / -RUN bash /wasi.sh +RUN /wasi.sh # Note that most of these are copied from `wasm32-wasip1/Dockerfile` # diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index f6331f10f3897..3bf350820019f 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -12,12 +12,12 @@ RUN apt-get update && \ WORKDIR /android/ ENV ANDROID_ARCH=x86_64 COPY android-install-ndk.sh /android/ -RUN sh /android/android-install-ndk.sh +RUN /android/android-install-ndk.sh # We do not run x86_64-linux-android tests on an android emulator. # See ci/android-sysimage.sh for information about how tests are run. COPY android-sysimage.sh /android/ -RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip +RUN /android/android-sysimage.sh x86_64 x86_64-24_r07.zip ENV PATH=$PATH:/rust/bin:/android/linux-x86_64/bin \ CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android28-clang \ diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 11fbd6e1be46a..d03df5b4f54ce 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates COPY install-musl.sh / -RUN sh /install-musl.sh x86_64 +RUN /install-musl.sh x86_64 ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin \ RUSTFLAGS="-L /musl-x86_64/lib" diff --git a/ci/emscripten.sh b/ci/emscripten.sh old mode 100644 new mode 100755 diff --git a/ci/install-musl-cross.sh b/ci/install-musl-cross.sh old mode 100644 new mode 100755 diff --git a/ci/install-musl.sh b/ci/install-musl.sh old mode 100644 new mode 100755 diff --git a/ci/install-rust.sh b/ci/install-rust.sh old mode 100644 new mode 100755 diff --git a/ci/linux-s390x.sh b/ci/linux-s390x.sh old mode 100644 new mode 100755 diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh old mode 100644 new mode 100755 diff --git a/ci/wasi.sh b/ci/wasi.sh old mode 100644 new mode 100755 From 58265b9e5cc7c23e5eae309a5c514beab41acf09 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 03:51:53 -0500 Subject: [PATCH 03/13] ci: use `env` rather than passing environment inline --- .github/workflows/ci.yaml | 48 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1f8ed0ee33de8..c73442d4c19ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,8 +27,6 @@ jobs: build_channels_linux: name: Build Channels Linux runs-on: ubuntu-22.04 - env: - OS: linux strategy: fail-fast: true max-parallel: 5 @@ -38,18 +36,19 @@ jobs: - beta - nightly - 1.63.0 + env: + OS: linux + TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/build.sh + run: ./ci/build.sh build_channels_macos: name: Build Channels macOS needs: macos - env: - OS: macos strategy: fail-fast: true max-parallel: 4 @@ -60,31 +59,35 @@ jobs: - { toolchain: nightly, os: macos-14 } - { toolchain: 1.63.0, os: macos-14 } runs-on: ${{ matrix.target.os }} + env: + OS: macos + TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.target.toolchain }} ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.target.toolchain }} ./ci/build.sh + run: ./ci/build.sh build_channels_windows: name: Build Channels Windows runs-on: windows-2022 - env: - OS: windows strategy: fail-fast: true matrix: toolchain: - 1.63.0 - stable + env: + OS: windows + TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - name: Self-update rustup run: rustup self update shell: bash - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} ./ci/build.sh + run: ./ci/build.sh shell: bash macos: @@ -95,18 +98,18 @@ jobs: matrix: target: - aarch64-apple-darwin + env: + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute run.sh run: ./ci/run.sh ${{ matrix.target }} windows: name: Windows runs-on: windows-2022 - env: - OS: windows strategy: fail-fast: true matrix: @@ -122,13 +125,16 @@ jobs: # ARCH_BITS: 32 # ARCH: i686 - target: i686-pc-windows-msvc + env: + OS: windows + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Self-update rustup run: rustup self update shell: bash - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} ./ci/install-rust.sh + run: ./ci/install-rust.sh shell: bash - name: Execute run.sh run: ./ci/run.sh ${{ matrix.target }} @@ -144,10 +150,12 @@ jobs: target: - i686-unknown-linux-gnu - x86_64-unknown-linux-gnu + env: + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute run-docker.sh run: ./ci/run-docker.sh ${{ matrix.target }} @@ -186,10 +194,12 @@ jobs: # FIXME: It seems some items in `src/unix/mod.rs` # aren't defined on redox actually. # - x86_64-unknown-redox + env: + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute run-docker.sh run: ./ci/run-docker.sh ${{ matrix.target }} @@ -223,10 +233,12 @@ jobs: check_cfg: name: "Check #[cfg]s" runs-on: ubuntu-22.04 + env: + TOOLCHAIN: nightly steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=nightly ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Build with check-cfg run: LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg From 67988b7f537903fd4ba8aa48d9be6502bcc041a0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 04:01:06 -0500 Subject: [PATCH 04/13] ci: combine and export RUSTFLAGS rather than passing inline This cleans things up and allows us to pass more flags externally. --- ci/build.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 13b71c6735297..b487a5aed4bf2 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -24,6 +24,8 @@ test_target() { target="${2}" no_std="${3:-}" + RUSTFLAGS="${RUSTFLAGS:-}" + # If there is a std component, fetch it: if [ "${no_std}" != "1" ]; then # FIXME: rustup often fails to download some artifacts due to network @@ -37,15 +39,17 @@ test_target() { n=$((n+1)) sleep 1 done + + # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. + RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" + export RUSTFLAGS fi # Test that libc builds without any default features (no std) if [ "$no_std" != "1" ]; then cargo "+$rust" "$build_cmd" --no-default-features --target "$target" else - # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ + cargo "+$rust" "$build_cmd" \ -Z build-std=core,alloc \ --no-default-features \ --target "$target" @@ -56,8 +60,7 @@ test_target() { if [ "$no_std" != "1" ]; then cargo "+$rust" "$build_cmd" --target "$target" else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "${build_cmd}" \ + cargo "+$rust" "${build_cmd}" \ -Z build-std=core,alloc \ --target "$target" fi @@ -69,8 +72,7 @@ test_target() { --features extra_traits \ --target "$target" else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ + cargo "+$rust" "$build_cmd" \ -Z build-std=core,alloc \ --no-default-features \ --features extra_traits \ @@ -85,8 +87,7 @@ test_target() { --features const-extern-fn \ --target "$target" else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ + cargo "+$rust" "$build_cmd" \ -Z build-std=core,alloc \ --no-default-features \ --features const-extern-fn \ @@ -100,8 +101,7 @@ test_target() { --target "$target" \ --features extra_traits else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ + cargo "+$rust" "$build_cmd" \ -Z build-std=core,alloc \ --target "$target" \ --features extra_traits From bbf941b090ae34cee155bad87f875ceeee0eab0c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 04:19:48 -0500 Subject: [PATCH 05/13] ci: Reduce redundant commands in build.sh --- ci/build.sh | 201 ++++++++++++++++++++-------------------------------- 1 file changed, 77 insertions(+), 124 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index b487a5aed4bf2..7415a96452809 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -20,14 +20,24 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then fi test_target() { - build_cmd="${1}" - target="${2}" - no_std="${3:-}" + target="${1}" + no_dist="${2:-0}" RUSTFLAGS="${RUSTFLAGS:-}" - # If there is a std component, fetch it: - if [ "${no_std}" != "1" ]; then + # The basic command that is run each time + cmd="cargo +$rust build --target $target" + + if [ "${no_dist}" != "0" ]; then + # If we can't download a `core`, we need to build it + cmd="$cmd -Zbuild-std=core,alloc" + + # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. + RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" + export RUSTFLAGS + else + # Otherwise it is available for download; fetch it: + # FIXME: rustup often fails to download some artifacts due to network # issues, so we retry this N times. N=5 @@ -39,73 +49,16 @@ test_target() { n=$((n+1)) sleep 1 done - - # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. - RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" - export RUSTFLAGS - fi - - # Test that libc builds without any default features (no std) - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" --no-default-features --target "$target" - else - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --target "$target" fi - # Test that libc builds with default features (e.g. std) - # if the target supports std - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" --target "$target" - else - cargo "+$rust" "${build_cmd}" \ - -Z build-std=core,alloc \ - --target "$target" - fi - - # Test that libc builds with the `extra_traits` feature - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --no-default-features \ - --features extra_traits \ - --target "$target" - else - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --features extra_traits \ - --target "$target" - fi - - # Test the 'const-extern-fn' feature on nightly - if [ "${rust}" = "nightly" ]; then - if [ "${no_std}" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --no-default-features \ - --features const-extern-fn \ - --target "$target" - else - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --features const-extern-fn \ - --target "$target" - fi - fi + # Test with expected combinations of features + $cmd + $cmd --features const-extern-fn + $cmd --features extra_traits - # Also test that it builds with `extra_traits` and default features: - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --target "$target" \ - --features extra_traits - else - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --target "$target" \ - --features extra_traits - fi + # Test again without default features, i.e. without "std" + $cmd --no-default-features + $cmd --no-default-features --features extra_traits } rust_linux_targets="\ @@ -171,48 +124,10 @@ x86_64-pc-windows-gnu \ i686-pc-windows-msvc \ " -# The targets are listed here alphabetically -targets="" -case "${OS}" in - linux*) - targets="$rust_linux_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_linux_targets" - fi - - ;; - macos*) - targets="$rust_apple_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_apple_targets" - fi - - ;; - windows*) - targets=${rust_nightly_windows_targets} - ;; - *) ;; -esac - -for target in $targets; do - if echo "$target" | grep -q "$filter"; then - if [ "${OS}" = "windows" ]; then - TARGET="$target" ./ci/install-rust.sh - test_target build "$target" - else - test_target build "$target" - fi - - test_run=1 - fi -done - # Targets which are not available via rustup and must be built with -Zbuild-std # FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has # duplicate symbol errors from `compiler_builtins`. -rust_linux_no_core_targets="\ +rust_linux_no_dist_targets="\ aarch64-pc-windows-msvc \ aarch64-unknown-freebsd \ aarch64-unknown-hermit \ @@ -276,31 +191,69 @@ x86_64-unknown-openbsd \ x86_64-wrs-vxworks \ " -if [ "${rust}" = "nightly" ] && [ "${OS}" = "linux" ]; then - for target in $rust_linux_no_core_targets; do - if echo "$target" | grep -q "$FILTER"; then - test_target "$target" 1 - fi - - test_run=1 - done -fi - -rust_apple_no_core_targets="\ +rust_apple_no_dist_targets="\ armv7s-apple-ios \ i686-apple-darwin \ i386-apple-ios \ " -if [ "${rust}" = "nightly" ] && [ "${OS}" = "macos" ]; then - for target in $rust_apple_no_core_targets; do - if echo "$target" | grep -q "$FILTER"; then +# The targets are listed here alphabetically +targets="" +no_dist_targets="" + +case "${OS}" in + linux*) + targets="$rust_linux_targets" + + if [ "$rust" = "nightly" ]; then + targets="$targets $rust_nightly_linux_targets" + no_dist_targets="$rust_linux_no_dist_targets" + fi + + ;; + macos*) + targets="$rust_apple_targets" + + if [ "$rust" = "nightly" ]; then + targets="$targets $rust_nightly_apple_targets" + no_dist_targets="$rust_apple_no_dist_targets" + fi + + ;; + windows*) + targets=${rust_nightly_windows_targets} + ;; + *) + echo "Unrecognized OS $OS" + exit 1 + ;; +esac + +for target in $targets; do + if echo "$target" | grep -q "$filter"; then + if [ "${OS}" = "windows" ]; then + TARGET="$target" ./ci/install-rust.sh + test_target "$target" + else + test_target "$target" + fi + + test_run=1 + fi +done + +for target in $no_dist_targets; do + if echo "$target" | grep -q "$filter"; then + if [ "${OS}" = "windows" ]; then + TARGET="$target" ./ci/install-rust.sh + test_target "$target" 1 + else test_target "$target" 1 fi test_run=1 - done -fi + fi +done # Make sure we didn't accidentally filter everything if [ "${test_run:-}" != 1 ]; then From c90236b5289b6ec48d926a23204cc01b14a749e1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 06:59:34 -0500 Subject: [PATCH 06/13] ci: Reduce redundant commands in run.sh --- ci/run.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index f4fef82fcdc2d..22b356a6425b1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -21,25 +21,21 @@ if [ -n "${QEMU:-}" ]; then if [ -z "${QEMU#*.gz}" ]; then # image is .gz : download and uncompress it - qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" | - gunzip -d > "${tmpdir}/${qemufile}" - fi + base_file="${QEMU%.gz}" + pipe_cmd="gunzip -d" elif [ -z "${QEMU#*.xz}" ]; then # image is .xz : download and uncompress it - qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" | - unxz > "${tmpdir}/${qemufile}" - fi + base_file="${QEMU%.xz}" + pipe_cmd="unxz" else # plain qcow2 image: just download it - qemufile="$(echo "${QEMU}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" \ - > "${tmpdir}/${qemufile}" - fi + base_file="$QEMU" + pipe_cmd="cat" # nop to forward the result + fi + + qemufile="$(echo "$base_file" | sed 's/\//__/g')" + if [ ! -f "${tmpdir}/${qemufile}" ]; then + curl --retry 5 "${mirrors_url}/${QEMU}" | $pipe_cmd > "${tmpdir}/${qemufile}" fi # Create a mount a fresh new filesystem image that we'll later pass to QEMU. From 3faaf4d64bf42d57ccb366089b4d5c6f484d4052 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 07:06:15 -0500 Subject: [PATCH 07/13] ci: Replace `$1` with a binding in run-docker.sh --- ci/run-docker.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 4cef3d45c504d..fcd9e1a9d2e03 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -8,6 +8,8 @@ set -eux +target="$1" + # Default to assuming the CARGO_HOME is one directory up (to account for a `bin` # subdir) from where the `cargo` binary in `$PATH` lives. default_cargo_home="$(dirname "$(dirname "$(command -v cargo)")")" @@ -18,17 +20,17 @@ export CARGO_HOME="${CARGO_HOME:-$default_cargo_home}" echo "${HOME}" pwd -# Avoid "no space left on device" failure. -if [ "${1}" = "aarch64-linux-android" ] ; then +# Avoid "no space left on device" failure if running in CI +if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ] ; then docker system prune -af docker system df fi run() { - echo "Building docker container for target ${1}" + echo "Building docker container for target $target" # use -f so we can use ci/ as build context - docker build -t "libc-${1}" -f "ci/docker/${1}/Dockerfile" ci/ + docker build -t "libc-$target" -f "ci/docker/$target/Dockerfile" ci/ mkdir -p target if [ -w /dev/kvm ]; then kvm="--volume /dev/kvm:/dev/kvm" @@ -50,8 +52,8 @@ run() { $kvm \ --init \ --workdir /checkout \ - "libc-${1}" \ - sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}" + "libc-$target" \ + sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh $target" } build_switch() { @@ -88,13 +90,13 @@ build_switch() { && cargo build -Z build-std=core,alloc --target ci/switch.json" } -if [ -z "${1}" ]; then +if [ -z "$target" ]; then for d in ci/docker/*; do run "${d}" done else - if [ "${1}" != "switch" ]; then - run "${1}" + if [ "$target" != "switch" ]; then + run "$target" else build_switch fi From c4e3ff835013791778a352466b827626ecfec32f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 05:21:35 -0500 Subject: [PATCH 08/13] ci: Switch to a single matrix for build channels (`verify_build`) The Mac, Windows, and Linux jobs for build channels are pretty redundant. Turn this into a single `verify_build` job that has both OS and version in its matrix. For consistency, rename the script to `verify-build`. To simplify variables, allow the build and toolchain scripts to detect the OS rather than passing it from CI. --- .github/workflows/ci.yaml | 72 ++++++-------------------------- ci/install-rust.sh | 27 +++++++----- ci/{build.sh => verify-build.sh} | 67 +++++++++++++++-------------- 3 files changed, 61 insertions(+), 105 deletions(-) rename ci/{build.sh => verify-build.sh} (86%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c73442d4c19ca..e0b4f0e451635 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: full CI +name: CI on: merge_group: @@ -24,71 +24,25 @@ jobs: - name: Check style run: ./ci/style.sh - build_channels_linux: - name: Build Channels Linux - runs-on: ubuntu-22.04 + # This runs `cargo build --target ...` for all T1 and T2 targets` + verify_build: + name: Verify build strategy: - fail-fast: true - max-parallel: 5 matrix: - toolchain: - - stable - - beta - - nightly - - 1.63.0 - env: - OS: linux - TOOLCHAIN: ${{ matrix.toolchain }} - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: ./ci/install-rust.sh - - name: Execute build.sh - run: ./ci/build.sh - - build_channels_macos: - name: Build Channels macOS - needs: macos - strategy: - fail-fast: true - max-parallel: 4 - matrix: - target: - - { toolchain: stable, os: macos-14 } - - { toolchain: beta, os: macos-14 } - - { toolchain: nightly, os: macos-14 } - - { toolchain: 1.63.0, os: macos-14 } - runs-on: ${{ matrix.target.os }} + toolchain: [stable, nightly, 1.63.0] + os: [ubuntu-22.04, macos-14, windows-2022] + include: + - toolchain: beta + os: ubuntu-22.04 + runs-on: ${{ matrix.os }} env: - OS: macos TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain run: ./ci/install-rust.sh - name: Execute build.sh - run: ./ci/build.sh - - build_channels_windows: - name: Build Channels Windows - runs-on: windows-2022 - strategy: - fail-fast: true - matrix: - toolchain: - - 1.63.0 - - stable - env: - OS: windows - TOOLCHAIN: ${{ matrix.toolchain }} - steps: - - uses: actions/checkout@v4 - - name: Self-update rustup - run: rustup self update - shell: bash - - name: Execute build.sh - run: ./ci/build.sh - shell: bash + run: ./ci/verify-build.sh macos: name: macOS @@ -254,9 +208,7 @@ jobs: - windows - solaris - style_check - - build_channels_linux - - build_channels_macos - - build_channels_windows + - verify_build # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. diff --git a/ci/install-rust.sh b/ci/install-rust.sh index becb532d1469d..16fd0b4e8a577 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -8,17 +8,25 @@ echo "Setup toolchain" toolchain="${TOOLCHAIN:-nightly}" os="${OS:-}" -if [ "$os" = "windows" ]; then - : "${TARGET?The TARGET environment variable must be set.}" - rustup set profile minimal - rustup update --force "$toolchain-$TARGET" - rustup default "$toolchain-$TARGET" -else +case "$(uname -s)" in + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; + *) + echo "Unknown system $(uname -s)" + exit 1 + ;; +esac + +if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then + toolchain="$toolchain-$TARGET" rustup set profile minimal - rustup update --force "$toolchain" - rustup default "$toolchain" fi +rustup set profile minimal +rustup update --force "$toolchain" +rustup default "$toolchain" + if [ -n "${TARGET:-}" ]; then echo "Install target" rustup target add "$TARGET" @@ -50,9 +58,6 @@ if [ "$os" = "windows" ]; then fi echo "Query rust and cargo versions" -command -v rustc -command -v cargo -command -v rustup rustc -Vv cargo -V rustup -Vv diff --git a/ci/build.sh b/ci/verify-build.sh similarity index 86% rename from ci/build.sh rename to ci/verify-build.sh index 7415a96452809..b88e214fb34d1 100755 --- a/ci/build.sh +++ b/ci/verify-build.sh @@ -8,12 +8,21 @@ set -eux : "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}" -: "${OS?The OS environment variable must be set.}" rust="$TOOLCHAIN" filter="${FILTER:-}" -echo "Testing Rust $rust on $OS" +case "$(uname -s)" in + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; + *) + echo "Unknown system $(uname -s)" + exit 1 + ;; +esac + +echo "Testing Rust $rust on $os" if [ "$TOOLCHAIN" = "nightly" ] ; then rustup component add rust-src @@ -198,40 +207,30 @@ i386-apple-ios \ " # The targets are listed here alphabetically -targets="" -no_dist_targets="" - -case "${OS}" in - linux*) - targets="$rust_linux_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_linux_targets" - no_dist_targets="$rust_linux_no_dist_targets" - fi - - ;; - macos*) - targets="$rust_apple_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_apple_targets" - no_dist_targets="$rust_apple_no_dist_targets" - fi +if [ "$os" = "linux" ]; then + targets="$rust_linux_targets" + nightly_targets="$rust_nightly_linux_targets" + no_dist_targets="$rust_linux_no_dist_targets" +elif [ "$os" = "macos" ]; then + targets="$rust_apple_targets" + nightly_targets="$rust_nightly_apple_targets" + no_dist_targets="$rust_apple_no_dist_targets" +elif [ "$os" = "windows" ]; then + targets=${rust_nightly_windows_targets} +else + exit 1 +fi - ;; - windows*) - targets=${rust_nightly_windows_targets} - ;; - *) - echo "Unrecognized OS $OS" - exit 1 - ;; -esac +if [ "$rust" = "nightly" ]; then + targets="$targets ${nightly_targets:-}" +else + # build-std requires nightly + no_dist_targets="" +fi for target in $targets; do if echo "$target" | grep -q "$filter"; then - if [ "${OS}" = "windows" ]; then + if [ "$os" = "windows" ]; then TARGET="$target" ./ci/install-rust.sh test_target "$target" else @@ -242,9 +241,9 @@ for target in $targets; do fi done -for target in $no_dist_targets; do +for target in ${no_dist_targets:-}; do if echo "$target" | grep -q "$filter"; then - if [ "${OS}" = "windows" ]; then + if [ "$os" = "windows" ]; then TARGET="$target" ./ci/install-rust.sh test_target "$target" 1 else From 01244c576e2d164a4092ade9040566185e1d17c5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 06:32:09 -0500 Subject: [PATCH 09/13] ci: Switch to a single matrix for tier1 testing The Mac, Windows, and Linux jobs for testing are pretty redundant. Turn this into a single `test_tier1` job that runs all expected combinations. --- .github/workflows/ci.yaml | 76 ++++++++++++--------------------------- 1 file changed, 23 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e0b4f0e451635..2f858186d0153 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -44,78 +44,50 @@ jobs: - name: Execute build.sh run: ./ci/verify-build.sh - macos: - name: macOS - runs-on: macos-14 + test_tier1: + name: Test tier1 strategy: - fail-fast: true - matrix: - target: - - aarch64-apple-darwin - env: - TARGET: ${{ matrix.target }} - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: ./ci/install-rust.sh - - name: Execute run.sh - run: ./ci/run.sh ${{ matrix.target }} - - windows: - name: Windows - runs-on: windows-2022 - strategy: - fail-fast: true matrix: include: + - target: i686-unknown-linux-gnu + docker: true + os: ubuntu-22.04 + - target: x86_64-unknown-linux-gnu + docker: true + os: ubuntu-22.04 + - target: aarch64-apple-darwin + os: macos-14 - target: x86_64-pc-windows-gnu + os: windows-2022 env: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc + os: windows-2022 # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: # ARCH_BITS: 32 # ARCH: i686 - target: i686-pc-windows-msvc + os: windows-2022 + runs-on: ${{ matrix.os }} env: - OS: windows TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - - name: Self-update rustup - run: rustup self update - shell: bash - name: Setup Rust toolchain run: ./ci/install-rust.sh - shell: bash - - name: Execute run.sh + - name: Run natively + if: "!matrix.docker" run: ./ci/run.sh ${{ matrix.target }} - shell: bash - - - docker_linux_tier1: - name: Docker Linux Tier1 - runs-on: ubuntu-22.04 - strategy: - fail-fast: true - matrix: - target: - - i686-unknown-linux-gnu - - x86_64-unknown-linux-gnu - env: - TARGET: ${{ matrix.target }} - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: ./ci/install-rust.sh - - name: Execute run-docker.sh + - name: Run in Docker + if: "matrix.docker" run: ./ci/run-docker.sh ${{ matrix.target }} - docker_linux_tier2: - name: Docker Linux Tier2 - needs: [docker_linux_tier1, style_check] + test_tier2: + name: Test tier2 + needs: [test_tier1, style_check] runs-on: ubuntu-22.04 strategy: fail-fast: true @@ -202,10 +174,8 @@ jobs: name: success runs-on: ubuntu-22.04 needs: - - docker_linux_tier1 - - docker_linux_tier2 - - macos - - windows + - test_tier1 + - test_tier2 - solaris - style_check - verify_build From 33582fccda6ac9dbfe3e998442272ade8b5c94fe Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 07:17:14 -0500 Subject: [PATCH 10/13] ci: Make sure `sparc` is the first job run then sort the others --- .github/workflows/ci.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2f858186d0153..42405035b7413 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -94,6 +94,9 @@ jobs: max-parallel: 12 matrix: target: + # FIXME(sparc): this takes much longer to run than any other job, put + # it first to make sure it gets a head start. + - sparc64-unknown-linux-gnu - aarch64-linux-android - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl @@ -107,12 +110,11 @@ jobs: - powerpc-unknown-linux-gnu - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu - - s390x-unknown-linux-gnu - riscv64gc-unknown-linux-gnu + - s390x-unknown-linux-gnu + - wasm32-unknown-emscripten - wasm32-wasip1 - wasm32-wasip2 - - sparc64-unknown-linux-gnu - - wasm32-unknown-emscripten - x86_64-linux-android # FIXME: Exec format error (os error 8) # - x86_64-unknown-linux-gnux32 From 549eb77fb1b59cb8e5e094761a5c47988348bbb7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 07:19:12 -0500 Subject: [PATCH 11/13] ci: defer the Solaris job until after tier 1 Solaris is a Tier 2 target so defer it until after tier1 completes. We currently do this for the other T2 targets. In preparation of adding other VM tests to the matrix, adjust naming. Additionally, just `set -x` rather than priting the commands before running them. --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42405035b7413..cbc05c454580f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -131,8 +131,9 @@ jobs: - name: Execute run-docker.sh run: ./ci/run-docker.sh ${{ matrix.target }} - solaris: - name: Solaris + test_tier2_vm: + name: Test tier2 VM + needs: [test_tier1, style_check] runs-on: ubuntu-latest strategy: fail-fast: true @@ -149,10 +150,9 @@ jobs: mem: 4096 copyback: false prepare: | + set -x source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) - echo "~~~~ rustc --version ~~~~" rustc --version - echo "~~~~ Solaris-version ~~~~" uname -a run: | export PATH=$HOME/.rust_solaris/bin:$PATH @@ -176,10 +176,10 @@ jobs: name: success runs-on: ubuntu-22.04 needs: + - style_check - test_tier1 - test_tier2 - - solaris - - style_check + - test_tier2_vm - verify_build # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its From 09a2bcf714ca5b5cf53340c20148a116a5c6b0ed Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 07:24:35 -0500 Subject: [PATCH 12/13] ci: Update all jobs to the latest ubuntu-24.04 --- .github/workflows/ci.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbc05c454580f..8fbbed08a1eca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ defaults: jobs: style_check: name: Style check - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain @@ -30,10 +30,10 @@ jobs: strategy: matrix: toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-22.04, macos-14, windows-2022] + os: [ubuntu-24.04, macos-14, windows-2022] include: - toolchain: beta - os: ubuntu-22.04 + os: ubuntu-24.04 runs-on: ${{ matrix.os }} env: TOOLCHAIN: ${{ matrix.toolchain }} @@ -51,10 +51,10 @@ jobs: include: - target: i686-unknown-linux-gnu docker: true - os: ubuntu-22.04 + os: ubuntu-24.04 - target: x86_64-unknown-linux-gnu docker: true - os: ubuntu-22.04 + os: ubuntu-24.04 - target: aarch64-apple-darwin os: macos-14 - target: x86_64-pc-windows-gnu @@ -88,7 +88,7 @@ jobs: test_tier2: name: Test tier2 needs: [test_tier1, style_check] - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: true max-parallel: 12 @@ -160,7 +160,7 @@ jobs: check_cfg: name: "Check #[cfg]s" - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: TOOLCHAIN: nightly steps: @@ -174,7 +174,7 @@ jobs: # protection, rather than having to add each job separately. success: name: success - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: - style_check - test_tier1 From 0892b447b021973e4285da6d4c6074b2bcc8dae8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 08:11:03 -0500 Subject: [PATCH 13/13] ci: Remove some trailing whitespace --- ci/style.rs | 2 +- ci/style.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/style.rs b/ci/style.rs index dbc8c633cffab..c4e0fb0db8058 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -100,7 +100,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { // FIXME: see below // let mut s_macros = 0; - + let mut f_macros = 0; let mut in_impl = false; diff --git a/ci/style.sh b/ci/style.sh index 17a47d037360a..c758712012e16 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -75,7 +75,7 @@ fi export LC_ALL=C for file in libc-test/semver/*.txt; do - case "$file" in + case "$file" in *TODO*) continue ;; esac