From 244c50861db5d77f495c6ea68beeff029725023a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 20 Apr 2025 08:34:47 +0000 Subject: [PATCH 1/5] ci: Use lowercase for bash locals, fix shellcheck --- ci/miri.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ci/miri.sh b/ci/miri.sh index 79e660bab..7b0ea44c6 100755 --- a/ci/miri.sh +++ b/ci/miri.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -ex +set -eux # We need Tree Borrows as some of our raw pointer patterns are not # compatible with Stacked Borrows. @@ -7,10 +7,12 @@ export MIRIFLAGS="-Zmiri-tree-borrows" # One target that sets `mem-unaligned` and one that does not, # and a big-endian target. -TARGETS=(x86_64-unknown-linux-gnu +targets=( + x86_64-unknown-linux-gnu armv7-unknown-linux-gnueabihf - s390x-unknown-linux-gnu) -for TARGET in "${TARGETS[@]}"; do + s390x-unknown-linux-gnu +) +for target in "${targets[@]}"; do # Only run the `mem` tests to avoid this taking too long. - cargo miri test --manifest-path builtins-test/Cargo.toml --features no-asm --target $TARGET -- mem + cargo miri test --manifest-path builtins-test/Cargo.toml --features no-asm --target "$target" -- mem done From d73a903422563476a4b6b9dce299aa3d0ed9b7a6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 20 Apr 2025 08:42:12 +0000 Subject: [PATCH 2/5] ci: Clean up workflow file and docker script --- .github/workflows/main.yaml | 11 +++++------ ci/run-docker.sh | 13 +++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2b57d7eb3..f7522a53d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -131,6 +131,9 @@ jobs: path: /tmp/.buildx-cache key: ${{ matrix.target }}-buildx-${{ github.sha }} restore-keys: ${{ matrix.target }}-buildx- + # Configure buildx to use Docker layer caching + - uses: docker/setup-buildx-action@v3 + if: matrix.os == 'ubuntu-24.04' - name: Cache compiler-rt id: cache-compiler-rt @@ -155,14 +158,10 @@ jobs: shell: bash run: ./ci/run.sh ${{ matrix.target }} - # Configure buildx to use Docker layer caching - - uses: docker/setup-buildx-action@v3 - if: matrix.os == 'ubuntu-24.04' - # Otherwise we use our docker containers to run builds - name: Run in Docker if: matrix.os == 'ubuntu-24.04' - run: cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }} + run: ./ci/run-docker.sh ${{ matrix.target }} - name: Print test logs if available if: always() @@ -193,7 +192,7 @@ jobs: rustup default nightly rustup component add clippy - uses: Swatinem/rust-cache@v2 - - run: cargo clippy -- -D clippy::all + - run: cargo clippy --workspace --all-targets benchmarks: name: Benchmarks diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 58838fadf..d0122dee5 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -7,6 +7,13 @@ set -euxo pipefail host_arch="$(uname -m | sed 's/arm64/aarch64/')" +# Directories and files that do not yet exist need to be created before +# calling docker, otherwise docker will create them but they will be owned +# by root. +mkdir -p target +cargo generate-lockfile +cargo generate-lockfile --manifest-path builtins-test-intrinsics/Cargo.toml + run() { local target="$1" @@ -19,12 +26,6 @@ run() { echo "target is emulated" fi - # Directories and files that do not yet exist need to be created before - # calling docker, otherwise docker will create them but they will be owned - # by root. - mkdir -p target - cargo generate-lockfile --manifest-path builtins-test-intrinsics/Cargo.toml - run_cmd="HOME=/tmp" if [ "${GITHUB_ACTIONS:-}" = "true" ]; then From f2a0596b880739112aa373661753c0c9858971ba Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 20 Apr 2025 08:22:36 +0000 Subject: [PATCH 3/5] ci: Configure release-plz to run semver checks on `libm` --- .release-plz.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.release-plz.toml b/.release-plz.toml index e32f67610..95d7517fe 100644 --- a/.release-plz.toml +++ b/.release-plz.toml @@ -1,7 +1,10 @@ -[workspace] +[[package]] +name = "compiler_builtins" semver_check = false - # As part of the release process, we delete `libm/Cargo.toml`. Since # this is only run in CI, we shouldn't need to worry about it. allow_dirty = true publish_allow_dirty = true + +[[package]] +name = "libm" From a6ec2456d6333e7868a1d219f02f10b74bf39edb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 20 Apr 2025 08:47:02 +0000 Subject: [PATCH 4/5] ci: Remove the old libm workflow file All jobs are now run as part of `compiler-builtins`. --- etc/libm/.github/workflows/main.yaml | 324 --------------------------- 1 file changed, 324 deletions(-) delete mode 100644 etc/libm/.github/workflows/main.yaml diff --git a/etc/libm/.github/workflows/main.yaml b/etc/libm/.github/workflows/main.yaml deleted file mode 100644 index 5ce0dbc26..000000000 --- a/etc/libm/.github/workflows/main.yaml +++ /dev/null @@ -1,324 +0,0 @@ -name: CI -on: - push: - branches: - - master - pull_request: - -concurrency: - # Make sure that new pushes cancel running jobs - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - RUSTDOCFLAGS: -Dwarnings - RUSTFLAGS: -Dwarnings - RUST_BACKTRACE: full - BENCHMARK_RUSTC: nightly-2025-01-16 # Pin the toolchain for reproducable results - -jobs: - test: - name: Build and test - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - target: aarch64-apple-darwin - os: macos-15 - # FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804 - channel: nightly-2025-02-07 - - target: aarch64-unknown-linux-gnu - os: ubuntu-24.04-arm - # FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804 - channel: nightly-2025-02-07 - - target: aarch64-pc-windows-msvc - os: windows-2025 - build_only: 1 # Can't run on x86 hosts - - target: arm-unknown-linux-gnueabi - os: ubuntu-24.04 - - target: arm-unknown-linux-gnueabihf - os: ubuntu-24.04 - - target: armv7-unknown-linux-gnueabihf - os: ubuntu-24.04 - - target: i586-unknown-linux-gnu - os: ubuntu-24.04 - - target: i686-unknown-linux-gnu - os: ubuntu-24.04 - - target: loongarch64-unknown-linux-gnu - os: ubuntu-24.04 - - target: powerpc-unknown-linux-gnu - os: ubuntu-24.04 - - target: powerpc64-unknown-linux-gnu - os: ubuntu-24.04 - - target: powerpc64le-unknown-linux-gnu - os: ubuntu-24.04 - - target: riscv64gc-unknown-linux-gnu - os: ubuntu-24.04 - - target: thumbv6m-none-eabi - os: ubuntu-24.04 - - target: thumbv7em-none-eabi - os: ubuntu-24.04 - - target: thumbv7em-none-eabihf - os: ubuntu-24.04 - - target: thumbv7m-none-eabi - os: ubuntu-24.04 - - target: x86_64-unknown-linux-gnu - os: ubuntu-24.04 - - target: x86_64-apple-darwin - os: macos-13 - - target: wasm32-unknown-unknown - os: ubuntu-24.04 - build_only: 1 - - target: i686-pc-windows-msvc - os: windows-2025 - - target: x86_64-pc-windows-msvc - os: windows-2025 - - target: i686-pc-windows-gnu - os: windows-2025 - # FIXME: pinned due to https://github.com/rust-lang/rust/issues/136795 - channel: nightly-2025-02-07-i686-gnu - - target: x86_64-pc-windows-gnu - os: windows-2025 - channel: nightly-x86_64-gnu - runs-on: ${{ matrix.os }} - env: - BUILD_ONLY: ${{ matrix.build_only }} - steps: - - name: Print runner information - run: uname -a - - uses: actions/checkout@v4 - with: - submodules: true - - name: Install Rust (rustup) - shell: bash - run: | - channel="nightly" - # Account for channels that have required components (MinGW) - [ -n "${{ matrix.channel }}" ] && channel="${{ matrix.channel }}" - rustup update "$channel" --no-self-update - rustup default "$channel" - rustup target add "${{ matrix.target }}" - rustup component add clippy llvm-tools-preview - - uses: taiki-e/install-action@nextest - - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.target }} - - - name: Verify API list - if: matrix.os == 'ubuntu-24.04' - run: python3 etc/update-api-list.py --check - - # Non-linux tests just use our raw script - - name: Run locally - if: matrix.os != 'ubuntu-24.04' || contains(matrix.target, 'wasm') - shell: bash - run: ./ci/run.sh ${{ matrix.target }} - - # Otherwise we use our docker containers to run builds - - name: Run in Docker - if: matrix.os == 'ubuntu-24.04' && !contains(matrix.target, 'wasm') - run: | - rustup target add x86_64-unknown-linux-musl - cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }} - - - name: Print test logs if available - if: always() - run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi - shell: bash - - clippy: - name: Clippy - runs-on: ubuntu-24.04 - timeout-minutes: 10 - steps: - - uses: actions/checkout@master - with: - submodules: true - - name: Install Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup component add clippy - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --all --all-features --all-targets - - builtins: - name: Check use with compiler-builtins - runs-on: ubuntu-24.04 - timeout-minutes: 10 - steps: - - uses: actions/checkout@master - - name: Install Rust - run: rustup update nightly --no-self-update && rustup default nightly - - uses: Swatinem/rust-cache@v2 - - run: cargo check --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml - - run: cargo test --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml - - benchmarks: - name: Benchmarks - runs-on: ubuntu-24.04 - timeout-minutes: 20 - steps: - - uses: actions/checkout@master - with: - submodules: true - - uses: taiki-e/install-action@cargo-binstall - - - name: Set up dependencies - run: | - sudo apt update - sudo apt install -y valgrind gdb libc6-dbg # Needed for iai-callgrind - rustup update "$BENCHMARK_RUSTC" --no-self-update - rustup default "$BENCHMARK_RUSTC" - # Install the version of iai-callgrind-runner that is specified in Cargo.toml - iai_version="$(cargo metadata --format-version=1 --features icount | - jq -r '.packages[] | select(.name == "iai-callgrind").version')" - cargo binstall -y iai-callgrind-runner --version "$iai_version" - sudo apt-get install valgrind - - - uses: Swatinem/rust-cache@v2 - - - name: Run icount benchmarks - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: ./ci/bench-icount.sh - - - name: Upload the benchmark baseline - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BASELINE_NAME }} - path: ${{ env.BASELINE_NAME }}.tar.xz - - - name: Run wall time benchmarks - run: | - # Always use the same seed for benchmarks. Ideally we should switch to a - # non-random generator. - export LIBM_SEED=benchesbenchesbenchesbencheswoo! - cargo bench --all --features short-benchmarks,build-musl,force-soft-floats - - - name: Print test logs if available - if: always() - run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi - shell: bash - - msrv: - name: Check MSRV - runs-on: ubuntu-24.04 - timeout-minutes: 10 - env: - RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings` - steps: - - uses: actions/checkout@master - - name: Install Rust - run: | - msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' libm/Cargo.toml)" - echo "MSRV: $msrv" - rustup update "$msrv" --no-self-update && rustup default "$msrv" - - uses: Swatinem/rust-cache@v2 - - run: | - # FIXME(msrv): Remove the workspace Cargo.toml so 1.63 cargo doesn't see - # `edition = "2024"` and get spooked. - rm Cargo.toml - cargo build --manifest-path libm/Cargo.toml - - rustfmt: - name: Rustfmt - runs-on: ubuntu-24.04 - timeout-minutes: 10 - steps: - - uses: actions/checkout@master - - name: Install Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup component add rustfmt - - run: cargo fmt -- --check - - # Determine which extensive tests should be run based on changed files. - calculate_extensive_matrix: - name: Calculate job matrix - runs-on: ubuntu-24.04 - timeout-minutes: 10 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - outputs: - matrix: ${{ steps.script.outputs.matrix }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 100 - - name: Fetch pull request ref - run: git fetch origin "$GITHUB_REF:$GITHUB_REF" - if: github.event_name == 'pull_request' - - run: python3 ci/ci-util.py generate-matrix >> "$GITHUB_OUTPUT" - id: script - - extensive: - name: Extensive tests for ${{ matrix.ty }} - needs: - # Wait on `clippy` so we have some confidence that the crate will build - - clippy - - calculate_extensive_matrix - runs-on: ubuntu-24.04 - timeout-minutes: 240 # 4 hours - strategy: - matrix: - # Use the output from `calculate_extensive_matrix` to calculate the matrix - # FIXME: it would be better to run all jobs (i.e. all types) but mark those that - # didn't change as skipped, rather than completely excluding the job. However, - # this is not currently possible https://github.com/actions/runner/issues/1985. - include: ${{ fromJSON(needs.calculate_extensive_matrix.outputs.matrix).matrix }} - env: - TO_TEST: ${{ matrix.to_test }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Install Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - - uses: Swatinem/rust-cache@v2 - - name: Run extensive tests - run: | - echo "Tests to run: '$TO_TEST'" - if [ -z "$TO_TEST" ]; then - echo "No tests to run, exiting." - exit - fi - - set -x - - # Run the non-extensive tests first to catch any easy failures - cargo t --profile release-checked -- "$TO_TEST" - - LIBM_EXTENSIVE_TESTS="$TO_TEST" cargo t \ - --features build-mpfr,unstable,force-soft-floats \ - --profile release-checked \ - -- extensive - - name: Print test logs if available - run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi - shell: bash - - success: - needs: - - test - - builtins - - benchmarks - - msrv - - rustfmt - - extensive - runs-on: ubuntu-24.04 - timeout-minutes: 10 - # 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. - if: always() # make sure this is never "skipped" - steps: - # Manually check the status of all dependencies. `if: failure()` does not work. - - name: check if any dependency failed - run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' From 5865499f385e568103b81e26a633ba14f421369d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 20 Apr 2025 08:54:11 +0000 Subject: [PATCH 5/5] Add panic-handler to the workspace This crate does not interact with features so there isn't any reason it can't become part of the workspace. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index c3737a042..75bb81ec1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "compiler-builtins", "crates/libm-macros", "crates/musl-math-sys", + "crates/panic-handler", "crates/util", "libm", "libm-test",