diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c2e83a2..76c14b8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,107 +1,107 @@ name: Build and Test on: - push: - pull_request: - types: - - opened - - synchronize - - reopened - - ready_for_review + push: + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review env: - CARGO_TERM_COLOR: always + CARGO_TERM_COLOR: always jobs: - clippy_check: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - env: - RUSTFLAGS: "-Dwarnings" # Make sure CI fails on all warnings, including Clippy lints - steps: - - uses: actions/checkout@v4 - - name: Run Clippy - run: cargo clippy --all-targets --all-features - lint: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 + clippy_check: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + env: + RUSTFLAGS: "-Dwarnings" # Make sure CI fails on all warnings, including Clippy lints + steps: + - uses: actions/checkout@v5 + - name: Run Clippy + run: cargo clippy --all-targets --all-features + lint: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + steps: + - uses: actions/checkout@v5 - - name: Check formatting - run: cargo fmt --all -- --check - build-ios: - runs-on: macos-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - strategy: - matrix: - target: - - aarch64-apple-ios - - aarch64-apple-ios-sim - - x86_64-apple-ios - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: "1.81.0" - targets: ${{ matrix.target }} - - name: Build - run: cargo build --target ${{ matrix.target }} - build-android: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - strategy: - matrix: - target: - - x86_64-linux-android - - aarch64-linux-android - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: "1.81.0" - targets: ${{ matrix.target }} - - name: Install Android NDK - run: cargo install cargo-ndk - - name: Build - run: cargo ndk -t ${{ matrix.target }} build - test-linux: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.81.0" - override: true - - name: Run tests - run: cargo test - test-macOS: - runs-on: macos-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.81.0" - override: true - - name: Run tests - run: cargo test - test-macOS-x86_64: - runs-on: macos-13 - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.81.0" - override: true - - name: Run tests - run: cargo test + - name: Check formatting + run: cargo fmt --all -- --check + build-ios: + runs-on: macos-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + strategy: + matrix: + target: + - aarch64-apple-ios + - aarch64-apple-ios-sim + - x86_64-apple-ios + steps: + - name: Checkout Repository + uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.89.0" + targets: ${{ matrix.target }} + - name: Build + run: cargo build --target ${{ matrix.target }} + build-android: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + strategy: + matrix: + target: + - x86_64-linux-android + - aarch64-linux-android + steps: + - name: Checkout Repository + uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.89.0" + targets: ${{ matrix.target }} + - name: Install Android NDK + run: cargo install cargo-ndk + - name: Build + run: cargo ndk -t ${{ matrix.target }} build + test-linux: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + steps: + - uses: actions/checkout@v5 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: "1.89.0" + override: true + - name: Run tests + run: cargo test + test-macOS: + runs-on: macos-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + steps: + - uses: actions/checkout@v5 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: "1.89.0" + override: true + - name: Run tests + run: cargo test + test-macOS-x86_64: + runs-on: macos-13 + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + steps: + - uses: actions/checkout@v5 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: "1.89.0" + override: true + - name: Run tests + run: cargo test diff --git a/Cargo.lock b/Cargo.lock index 656be4d..b9f1428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,6 +25,15 @@ dependencies = [ "shlex", ] +[[package]] +name = "chkstk_stub" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "047f6ab2f3b9bcaf23b593d1580898e4244d27eadf1a1fae99212ee5735d3d1c" +dependencies = [ + "cc", +] + [[package]] name = "fnv" version = "1.0.7" @@ -86,6 +95,7 @@ version = "0.1.1" dependencies = [ "anyhow", "cc", + "chkstk_stub", "num-bigint", "num-traits", ] diff --git a/README.md b/README.md index 5066102..cc07a2e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This project provides a Rust adapter for compiling and linking [Rapidsnark](http ### Rust toolchain ``` -cargo 1.81.0 (2dbb1af80 2024-08-20) +cargo 1.89.0 (c24e10642 2025-06-23) ``` ## Usage diff --git a/crates/Cargo.toml b/crates/Cargo.toml index 5494ef3..26dc4f2 100644 --- a/crates/Cargo.toml +++ b/crates/Cargo.toml @@ -17,3 +17,4 @@ num-traits = "0.2.19" [build-dependencies] cc = "1.0" +chkstk_stub = "0.1" diff --git a/crates/README.md b/crates/README.md index 5066102..cc07a2e 100644 --- a/crates/README.md +++ b/crates/README.md @@ -9,7 +9,7 @@ This project provides a Rust adapter for compiling and linking [Rapidsnark](http ### Rust toolchain ``` -cargo 1.81.0 (2dbb1af80 2024-08-20) +cargo 1.89.0 (c24e10642 2025-06-23) ``` ## Usage diff --git a/crates/build.rs b/crates/build.rs index 0aef23c..80a5ca9 100644 --- a/crates/build.rs +++ b/crates/build.rs @@ -11,6 +11,9 @@ fn main() { let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set"); let arch = target.split('-').next().unwrap(); + // See: https://github.com/zkmopro/chkstk_stub + chkstk_stub::build(); + // Try to list contents of the target directory let rapidsnark_path = Path::new(&out_dir).join(Path::new("rapidsnark")); // If the rapidsnark repo is not downloaded, download it @@ -22,11 +25,11 @@ fn main() { .arg(rapidsnark_script_path.to_str().unwrap()) .spawn(); if let Err(e) = child_process { - panic!("Failed to spawn rapidsnark download: {}", e); + panic!("Failed to spawn rapidsnark download: {e}"); } let status = child_process.unwrap().wait(); if let Err(e) = status { - panic!("Failed to wait for rapidsnark download: {}", e); + panic!("Failed to wait for rapidsnark download: {e}"); } else if !status.unwrap().success() { panic!("Failed to wait for rapidsnark download"); } @@ -49,7 +52,7 @@ fn main() { ); println!("cargo:rustc-link-lib=static=rapidsnark"); - println!("cargo:rustc-link-lib={}", cpp_stdlib); + println!("cargo:rustc-link-lib={cpp_stdlib}"); if target.contains("android") { // pthread is included in libc in android println!("cargo:rustc-link-lib=c"); @@ -83,11 +86,10 @@ fn android() { let lib_path = sysroot_libs_path.join("libc++_shared.so"); assert!( lib_path.exists(), - "Error: Source file {:?} does not exist", - lib_path + "Error: Source file {lib_path:?} does not exist" ); let dest_dir = Path::new(&output_path).join(env::var("CARGO_NDK_ANDROID_TARGET").unwrap()); - println!("cargo:rerun-if-changed={}", dest_dir.display()); + println!("cargo:rerun-if-changed={dest_dir:?}"); if !dest_dir.exists() { fs::create_dir_all(&dest_dir).unwrap(); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 1de01fa..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "1.81.0"