From e1a0a3fedcef7ec8ce79a693e0301deffc1a3993 Mon Sep 17 00:00:00 2001 From: Gorka Kobeaga Date: Fri, 9 Feb 2024 22:49:03 +0100 Subject: [PATCH 1/2] Add ARM cross-compilation to CI (#113) --- .github/workflows/cross.yml | 25 +++++++++++++++++++++++++ Cross.toml | 12 ++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/cross.yml create mode 100644 Cross.toml diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml new file mode 100644 index 0000000..fce71ce --- /dev/null +++ b/.github/workflows/cross.yml @@ -0,0 +1,25 @@ +on: [push] + +name: Cross CI + +jobs: + cross: + name: Rust ${{matrix.target}} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: + - aarch64-unknown-linux-gnu + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{matrix.target}} + override: true + - uses: actions-rs/cargo@v1 + with: + use-cross: true + command: test + args: --target ${{matrix.target}} diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..0877cfb --- /dev/null +++ b/Cross.toml @@ -0,0 +1,12 @@ +[target.aarch64-unknown-linux-gnu] +pre-build = [ + "dpkg --add-architecture $CROSS_DEB_ARCH", + "apt-get update && apt-get --assume-yes install gfortran-aarch64-linux-gnu gcc-aarch64-linux-gnu libssl-dev:$CROSS_DEB_ARCH libssl-dev" +] +[target.aarch64-unknown-linux-gnu.env] +passthrough = [ + "OPENBLAS_CC=aarch64-linux-gnu-gcc", + "OPENBLAS_HOSTCC=gcc", + "OPENBLAS_FC=aarch64-linux-gnu-gfortran", + "OPENBLAS_TARGET=NEOVERSEN1" +] From 28575a18cfc4b903ab6c9946420456f912ffa703 Mon Sep 17 00:00:00 2001 From: Dirreke Date: Tue, 26 Nov 2024 00:22:49 +0800 Subject: [PATCH 2/2] rewrite CI --- .github/workflows/cross.yml | 25 ---------- .github/workflows/openblas-build.yml | 12 ++--- .github/workflows/openblas-src.yml | 72 +++++++++++++++------------- .github/workflows/rust.yml | 16 +++---- Cross.toml | 20 +++++++- 5 files changed, 68 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/cross.yml diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml deleted file mode 100644 index fce71ce..0000000 --- a/.github/workflows/cross.yml +++ /dev/null @@ -1,25 +0,0 @@ -on: [push] - -name: Cross CI - -jobs: - cross: - name: Rust ${{matrix.target}} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - target: - - aarch64-unknown-linux-gnu - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: ${{matrix.target}} - override: true - - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: test - args: --target ${{matrix.target}} diff --git a/.github/workflows/openblas-build.yml b/.github/workflows/openblas-build.yml index 1470212..72fc7a6 100644 --- a/.github/workflows/openblas-build.yml +++ b/.github/workflows/openblas-build.yml @@ -22,7 +22,7 @@ jobs: env: RUST_BACKTRACE: 1 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Install gfortran by apt @@ -30,12 +30,6 @@ jobs: apt update apt install -y gfortran - name: Common minor tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=openblas-build/Cargo.toml + run: cargo test --manifest-path=openblas-build/Cargo.toml - name: Build test - uses: actions-rs/cargo@v1 - with: - command: test - args: ${{ matrix.test_target }} --manifest-path=openblas-build/Cargo.toml -- --ignored + run: cargo test ${{ matrix.test_target }} --manifest-path=openblas-build/Cargo.toml -- --ignored diff --git a/.github/workflows/openblas-src.yml b/.github/workflows/openblas-src.yml index 28affb6..2afa612 100644 --- a/.github/workflows/openblas-src.yml +++ b/.github/workflows/openblas-src.yml @@ -18,8 +18,8 @@ jobs: - x64-windows-static - x64-windows-static-md steps: - - uses: actions/checkout@v1 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: ./vcpkg key: vcpkg-openblas @@ -31,30 +31,20 @@ jobs: - name: Install OpenBLAS by vcpkg run: | ./vcpkg/vcpkg.exe install openblas:${{ matrix.triple }} - - - uses: actions-rs/cargo@v1 - name: Test features=system - with: - command: test - args: --features=system --manifest-path=openblas-src/Cargo.toml + - name: Test features=system + run: cargo test --features=system --manifest-path=openblas-src/Cargo.toml env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg if: ${{ matrix.triple == 'x64-windows' }} - - uses: actions-rs/cargo@v1 - name: Test features=system,static - with: - command: test - args: --features=system,static --manifest-path=openblas-src/Cargo.toml + - name: Test features=system,static + run: cargo test --features=system,static --manifest-path=openblas-src/Cargo.toml env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg if: ${{ matrix.triple == 'x64-windows-static-md' }} - - uses: actions-rs/cargo@v1 - name: Test features=system,static with crt-static - with: - command: test - args: --features=system,static --manifest-path=openblas-src/Cargo.toml + - name: Test features=system,static with crt-static + run: cargo test --features=system,static --manifest-path=openblas-src/Cargo.toml env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg RUSTFLAGS: "-C target-feature=+crt-static" @@ -70,21 +60,17 @@ jobs: - static - system steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Install OpenBLAS by homebrew run: | brew install openblas if: ${{ contains(matrix.feature, 'system') }} - - uses: actions-rs/cargo@v1 - with: - command: test - args: > - --features=${{ matrix.feature }} - --manifest-path=openblas-src/Cargo.toml + - name: Test features=${{ matrix.feature }} + run: cargo test --features=${{ matrix.feature }} --manifest-path=openblas-src/Cargo.toml - linux: + x86_64-unknown-linux-gnu: runs-on: ubuntu-22.04 container: image: rust @@ -96,7 +82,7 @@ jobs: - static - system steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Install gfortran by apt @@ -108,9 +94,31 @@ jobs: apt update apt install -y libopenblas-dev if: ${{ contains(matrix.feature, 'system') }} - - uses: actions-rs/cargo@v1 + - name: Test features=${{ matrix.feature }} + run: cargo test --features=${{ matrix.feature }} --manifest-path=openblas-src/Cargo.toml + + cross: + name: ${{matrix.target}} (${{matrix.feature}}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + feature: + - "" + - static + - system + target: + - aarch64-unknown-linux-gnu + - armv7-unknown-linux-gnueabihf + steps: + - uses: actions/checkout@v4 + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable + with: + target: ${{matrix.target}} + - name: Install Cross + uses: taiki-e/install-action@v2 with: - command: test - args: > - --features=${{ matrix.feature }} - --manifest-path=openblas-src/Cargo.toml + tool: cross + - name: Test features=${{ matrix.feature }} + run: cross test --target ${{matrix.target}} --features=${{ matrix.feature }} --manifest-path=openblas-src/Cargo.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5d1a2ef..a5e14fb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,23 +5,21 @@ on: branches: - master pull_request: {} + workflow_dispatch: {} jobs: check-format: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v1 - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + - uses: actions/checkout@v4 + - name: Check format + run: cargo fmt -- --check clippy: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: "true" - - uses: actions-rs/cargo@v1 - with: - command: clippy + - name: Check format + run: cargo clippy diff --git a/Cross.toml b/Cross.toml index 0877cfb..5c9a998 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,12 +1,28 @@ [target.aarch64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main" pre-build = [ "dpkg --add-architecture $CROSS_DEB_ARCH", - "apt-get update && apt-get --assume-yes install gfortran-aarch64-linux-gnu gcc-aarch64-linux-gnu libssl-dev:$CROSS_DEB_ARCH libssl-dev" + "apt-get update && apt-get --assume-yes install libopenblas-dev:$CROSS_DEB_ARCH libssl-dev" ] [target.aarch64-unknown-linux-gnu.env] passthrough = [ "OPENBLAS_CC=aarch64-linux-gnu-gcc", "OPENBLAS_HOSTCC=gcc", "OPENBLAS_FC=aarch64-linux-gnu-gfortran", - "OPENBLAS_TARGET=NEOVERSEN1" + "OPENBLAS_TARGET=ARMV8" ] + +[target.armv7-unknown-linux-gnueabihf] +image = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main" +pre-build = [ + "dpkg --add-architecture $CROSS_DEB_ARCH", + "apt-get update && apt-get --assume-yes install libopenblas-dev:$CROSS_DEB_ARCH libssl-dev" +] +[target.armv7-unknown-linux-gnueabihf.env] +passthrough = [ + "OPENBLAS_CC=arm-linux-gnueabihf-gcc", + "OPENBLAS_HOSTCC=gcc", + "OPENBLAS_FC=arm-linux-gnueabihf-gfortran", + "OPENBLAS_TARGET=ARMV7" +] +