From 37ce2ab1b8c77debb71d35df4d10ca36191ff5bd Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 09:52:28 -0400 Subject: [PATCH 01/31] Run tests on multiple platforms --- .github/workflows/rust.yml | 70 ++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a10e861..e7ebaf2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,16 +32,11 @@ jobs: cd rust_bindings cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=600 || exit 255" - build_crate: - name: Build crate + lint: + name: Lint runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Rust uses: dtolnay/rust-toolchain@stable @@ -54,9 +49,70 @@ jobs: - name: Clippy run: cargo clippy + test: + name: Test (${{ matrix.os.name }} ${{ matrix.arch.name }}) + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + + strategy: + fail-fast: false + matrix: + os: + - name: macOS + matrix: macos + runs-on: + arm: [macos-13-arm64] + intel: [macos-13] + cibw-archs-macos: + arm: arm64 + intel: x86_64 + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + - name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + + arch: + - name: ARM + matrix: arm + - name: Intel + matrix: intel + + exclude: + - os: + name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + arch: + name: ARM + matrix: arm + + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + - name: Tests run: cargo test && cargo test --release + build_crate: + name: Build crate + needs: [lint, test] + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + - name: Build run: cargo build --release From 1f5407d1bdad354178ecc83bf943d2b2808907b7 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 09:55:38 -0400 Subject: [PATCH 02/31] Library path on MacOS --- .github/workflows/rust.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e7ebaf2..489c39f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -94,6 +94,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: MacOS GMP library path + if: matrix.os.name == 'macOS' + run: | + export LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH + - name: Set up Rust uses: dtolnay/rust-toolchain@stable From 3dfdfe12d31e73ed2c15ccf4c2fc66eaf955ddca Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:01:57 -0400 Subject: [PATCH 03/31] Fix --- .github/workflows/rust.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 489c39f..d49ec39 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,8 +96,7 @@ jobs: - name: MacOS GMP library path if: matrix.os.name == 'macOS' - run: | - export LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH + run: echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV - name: Set up Rust uses: dtolnay/rust-toolchain@stable From f80d4fa3e26ef6dd76e2a36fd58a0c7d90097f4e Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:04:36 -0400 Subject: [PATCH 04/31] Add MPIR support to build script --- rust_bindings/build.rs | 56 +++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 6e8d5b1..e996f1d 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -27,18 +27,52 @@ fn main() { .define("BUILD_PYTHON", "OFF") .build(); - println!( - "cargo:rustc-link-search=native={}", - PathBuf::from_str(dst.display().to_string().as_str()) - .unwrap() - .join("build") - .join("lib") - .join("static") - .to_str() - .unwrap() - ); + if cfg!(target_os = "windows") { + let build_type = if cfg!(debug_assertions) { + "Debug" + } else { + "Release" + }; + + println!( + "cargo:rustc-link-search=native={}", + PathBuf::from_str(dst.display().to_string().as_str()) + .unwrap() + .join("build") + .join("lib") + .join("static") + .join(build_type) + .to_str() + .unwrap() + ); + + println!( + "cargo:rustc-link-search=native={}", + src_dir + .parent() + .unwrap() + .join("mpir_gc_x64") + .to_str() + .unwrap() + ); + + println!("cargo:rustc-link-lib=mpir"); + } else { + println!( + "cargo:rustc-link-search=native={}", + PathBuf::from_str(dst.display().to_string().as_str()) + .unwrap() + .join("build") + .join("lib") + .join("static") + .to_str() + .unwrap() + ); + + println!("cargo:rustc-link-lib=gmp"); + } + println!("cargo:rustc-link-lib=static=chiavdfc"); - println!("cargo:rustc-link-lib=gmp"); let bindings = bindgen::Builder::default() .header(manifest_dir.join("wrapper.h").to_str().unwrap()) From 37b5cbcacd937d173670bf5dcbc6252e843992e1 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:05:02 -0400 Subject: [PATCH 05/31] Include MPIR in the crate --- .github/workflows/rust.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d49ec39..6fcaadc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -121,7 +121,10 @@ jobs: run: cargo build --release - name: Prepare for publish - run: cp -r src rust_bindings/cpp + run: | + cd rust_bindings + cp -r ../src cpp + git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Publish to crates.io (dry run) # We use `--allow-dirty` because the `cpp` folder is copied into the working directory. From 8a0e464bc7c59da158d10e82b2b9e37d592dc024 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:06:36 -0400 Subject: [PATCH 06/31] CI support for MPIR --- .github/workflows/rust.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6fcaadc..e08b0f4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -94,10 +94,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: MacOS GMP library path + - name: MacOS - GMP library path if: matrix.os.name == 'macOS' run: echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV + - name: Windows - Download MPIR + if: matrix.os.name == 'Windows' + run: git clone https://github.com/Chia-Network/mpir_gc_x64.git + - name: Set up Rust uses: dtolnay/rust-toolchain@stable From eef4055449f2bff605878c6ffdd8cd46b0c80d66 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:14:17 -0400 Subject: [PATCH 07/31] Reorder --- rust_bindings/build.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index e996f1d..4c92460 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -1,6 +1,5 @@ use std::env; use std::path::PathBuf; -use std::str::FromStr; use cmake::Config; @@ -27,6 +26,8 @@ fn main() { .define("BUILD_PYTHON", "OFF") .build(); + println!("cargo:rustc-link-lib=static=chiavdfc"); + if cfg!(target_os = "windows") { let build_type = if cfg!(debug_assertions) { "Debug" @@ -36,9 +37,7 @@ fn main() { println!( "cargo:rustc-link-search=native={}", - PathBuf::from_str(dst.display().to_string().as_str()) - .unwrap() - .join("build") + dst.join("build") .join("lib") .join("static") .join(build_type) @@ -60,9 +59,7 @@ fn main() { } else { println!( "cargo:rustc-link-search=native={}", - PathBuf::from_str(dst.display().to_string().as_str()) - .unwrap() - .join("build") + dst.join("build") .join("lib") .join("static") .to_str() @@ -72,8 +69,6 @@ fn main() { println!("cargo:rustc-link-lib=gmp"); } - println!("cargo:rustc-link-lib=static=chiavdfc"); - let bindings = bindgen::Builder::default() .header(manifest_dir.join("wrapper.h").to_str().unwrap()) .clang_arg("-x") From 4de90bbe289bcbfe79b13317491ebba04cb8806a Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:18:59 -0400 Subject: [PATCH 08/31] Attempt to add static --- rust_bindings/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 4c92460..e757e44 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -55,7 +55,7 @@ fn main() { .unwrap() ); - println!("cargo:rustc-link-lib=mpir"); + println!("cargo:rustc-link-lib=static=mpir"); } else { println!( "cargo:rustc-link-search=native={}", @@ -66,7 +66,7 @@ fn main() { .unwrap() ); - println!("cargo:rustc-link-lib=gmp"); + println!("cargo:rustc-link-lib=static=gmp"); } let bindings = bindgen::Builder::default() From e3f2d56841c35368905d77f9f35e653432eca9af Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:31:35 -0400 Subject: [PATCH 09/31] Remove build script MPIR linkage --- rust_bindings/build.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index e757e44..d07e612 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -44,18 +44,6 @@ fn main() { .to_str() .unwrap() ); - - println!( - "cargo:rustc-link-search=native={}", - src_dir - .parent() - .unwrap() - .join("mpir_gc_x64") - .to_str() - .unwrap() - ); - - println!("cargo:rustc-link-lib=static=mpir"); } else { println!( "cargo:rustc-link-search=native={}", @@ -66,7 +54,7 @@ fn main() { .unwrap() ); - println!("cargo:rustc-link-lib=static=gmp"); + println!("cargo:rustc-link-lib=gmp"); } let bindings = bindgen::Builder::default() From 2afad11a0772566fcd2633a9c72656d353bfbce0 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 18 Sep 2024 10:36:13 -0400 Subject: [PATCH 10/31] Statically link mpir? --- rust_bindings/build.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index d07e612..4c4643b 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -44,6 +44,18 @@ fn main() { .to_str() .unwrap() ); + + println!( + "cargo:rustc-link-search=native={}", + src_dir + .parent() + .unwrap() + .join("mpir_gc_x64") + .to_str() + .unwrap() + ); + + println!("cargo:rustc-link-lib=static=mpir"); } else { println!( "cargo:rustc-link-search=native={}", From ed9461b52cd3ef3547cb2ad514c44d562b4b057a Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 13:59:30 -0400 Subject: [PATCH 11/31] vcpkg? --- .github/workflows/rust.yml | 6 +++--- rust_bindings/build.rs | 10 ---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e08b0f4..9237a5c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -94,13 +94,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: MacOS - GMP library path + - name: GMP library path on MacOS if: matrix.os.name == 'macOS' run: echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV - - name: Windows - Download MPIR + - name: Install MPIR on Windows if: matrix.os.name == 'Windows' - run: git clone https://github.com/Chia-Network/mpir_gc_x64.git + run: vcpkg install mpir - name: Set up Rust uses: dtolnay/rust-toolchain@stable diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 4c4643b..d23e51d 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -45,16 +45,6 @@ fn main() { .unwrap() ); - println!( - "cargo:rustc-link-search=native={}", - src_dir - .parent() - .unwrap() - .join("mpir_gc_x64") - .to_str() - .unwrap() - ); - println!("cargo:rustc-link-lib=static=mpir"); } else { println!( From 4e50a36680340c84404b58b6e8b774c9ad3e6d40 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 14:06:34 -0400 Subject: [PATCH 12/31] vcpkg and mpir fix --- .github/workflows/rust.yml | 3 +-- Cargo.lock | 7 +++++++ rust_bindings/Cargo.toml | 1 + rust_bindings/build.rs | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9237a5c..4caeba6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,7 +100,7 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' - run: vcpkg install mpir + run: vcpkg install mpir:x64-windows-static - name: Set up Rust uses: dtolnay/rust-toolchain@stable @@ -128,7 +128,6 @@ jobs: run: | cd rust_bindings cp -r ../src cpp - git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Publish to crates.io (dry run) # We use `--allow-dirty` because the `cpp` folder is copied into the working directory. diff --git a/Cargo.lock b/Cargo.lock index 259f793..42f5945 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,6 +81,7 @@ dependencies = [ "hex", "hex-literal", "link-cplusplus", + "vcpkg", ] [[package]] @@ -359,6 +360,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "which" version = "4.4.2" diff --git a/rust_bindings/Cargo.toml b/rust_bindings/Cargo.toml index 88adc02..280b008 100644 --- a/rust_bindings/Cargo.toml +++ b/rust_bindings/Cargo.toml @@ -14,6 +14,7 @@ link-cplusplus = "1.0.9" [build-dependencies] bindgen = "0.69.4" cmake = "0.1.50" +vcpkg = "0.2.15" [dev-dependencies] hex = "0.4.3" diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index d23e51d..2ef14dc 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -45,7 +45,7 @@ fn main() { .unwrap() ); - println!("cargo:rustc-link-lib=static=mpir"); + vcpkg::find_package("mpir").unwrap(); } else { println!( "cargo:rustc-link-search=native={}", From 496189d225474168571994bf83893da2a70a330c Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 14:19:31 -0400 Subject: [PATCH 13/31] Skip MPIR link --- rust_bindings/build.rs | 1 + src/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 2ef14dc..2ec5872 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -24,6 +24,7 @@ fn main() { .define("BUILD_CHIAVDFC", "ON") .env("BUILD_VDF_CLIENT", "N") .define("BUILD_PYTHON", "OFF") + .define("SKIP_MPIR_LINK", "ON") .build(); println!("cargo:rustc-link-lib=static=chiavdfc"); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e7b94e..651e17c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR) option(BUILD_CHIAVDFC "Build the chiavdfc shared library" OFF) option(BUILD_PYTHON "Build the python bindings for chiavdf" ON) +option(SKIP_MPIR_LINK "Skip linking MPIR" OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -33,6 +34,8 @@ if(WIN32) if(MPIR_LIBRARY) message(STATUS "MPIR library found at ${MPIR_LIBRARY}") link_libraries(${MPIR_LIBRARY}) + elseif(SKIP_MPIR_LINK) + message(STATUS "MPIR library not found, skipping linking") else() message(FATAL_ERROR "MPIR library not found") endif() From 0f654d7d18ad5cd8d4998dce48af0a666cf29e2f Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 14:26:49 -0400 Subject: [PATCH 14/31] Test thing --- .github/workflows/rust.yml | 4 +++- src/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4caeba6..3f267b6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,7 +100,9 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' - run: vcpkg install mpir:x64-windows-static + run: | + vcpkg install mpir:x64-windows-static + git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Set up Rust uses: dtolnay/rust-toolchain@stable diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 651e17c..22cb662 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,11 +31,11 @@ if(WIN32) ${MPIR_INCLUDE_DIR} ) find_library(MPIR_LIBRARY NAMES mpir PATHS ${MPIR_LIBRARY_DIR} NO_DEFAULT_PATH) - if(MPIR_LIBRARY) + if(SKIP_MPIR_LINK) + message(STATUS "MPIR library found, skipping linking") + elseif(MPIR_LIBRARY) message(STATUS "MPIR library found at ${MPIR_LIBRARY}") link_libraries(${MPIR_LIBRARY}) - elseif(SKIP_MPIR_LINK) - message(STATUS "MPIR library not found, skipping linking") else() message(FATAL_ERROR "MPIR library not found") endif() From 0db14ee02ae4b72ad0b18997a8060f88dbf52378 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 14:32:25 -0400 Subject: [PATCH 15/31] vcpkg integrate install --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3f267b6..cdb9079 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -102,6 +102,7 @@ jobs: if: matrix.os.name == 'Windows' run: | vcpkg install mpir:x64-windows-static + vcpkg integrate install git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Set up Rust From f05ec00a7230ecc1d8b424c53b31e620cd58ad52 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 14:39:17 -0400 Subject: [PATCH 16/31] md --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cdb9079..888e54c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -101,7 +101,7 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' run: | - vcpkg install mpir:x64-windows-static + vcpkg install mpir:x64-windows-static-md vcpkg integrate install git clone https://github.com/Chia-Network/mpir_gc_x64.git From ebc202fde2aa9f0f5cf256a813982b34e160d58d Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 22 Sep 2024 22:48:30 -0400 Subject: [PATCH 17/31] Add mpir to crate --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 888e54c..6fc872a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -131,6 +131,7 @@ jobs: run: | cd rust_bindings cp -r ../src cpp + git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Publish to crates.io (dry run) # We use `--allow-dirty` because the `cpp` folder is copied into the working directory. From 22c7dfbac3f359bf6345679095a5109e821735bc Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 25 Sep 2024 13:26:15 -0400 Subject: [PATCH 18/31] Shot in the dark --- .github/workflows/rust.yml | 2 +- rust_bindings/build.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6fc872a..e4ed6e7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -101,7 +101,7 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' run: | - vcpkg install mpir:x64-windows-static-md + vcpkg install gmp:x64-windows-static-md vcpkg integrate install git clone https://github.com/Chia-Network/mpir_gc_x64.git diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 2ec5872..0da92aa 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -46,7 +46,7 @@ fn main() { .unwrap() ); - vcpkg::find_package("mpir").unwrap(); + vcpkg::find_package("gmp").unwrap(); } else { println!( "cargo:rustc-link-search=native={}", From e4638e6515399a12e3ce19542c5799cf09e369be Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:26:41 -0400 Subject: [PATCH 19/31] Dynamic linking --- .github/workflows/rust.yml | 5 +---- Cargo.lock | 7 ------- rust_bindings/Cargo.toml | 1 - rust_bindings/build.rs | 2 -- src/CMakeLists.txt | 5 +---- 5 files changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e4ed6e7..695c453 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,10 +100,7 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' - run: | - vcpkg install gmp:x64-windows-static-md - vcpkg integrate install - git clone https://github.com/Chia-Network/mpir_gc_x64.git + run: git clone https://github.com/Chia-Network/mpir_gc_x64.git - name: Set up Rust uses: dtolnay/rust-toolchain@stable diff --git a/Cargo.lock b/Cargo.lock index 42f5945..259f793 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,7 +81,6 @@ dependencies = [ "hex", "hex-literal", "link-cplusplus", - "vcpkg", ] [[package]] @@ -360,12 +359,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "which" version = "4.4.2" diff --git a/rust_bindings/Cargo.toml b/rust_bindings/Cargo.toml index 280b008..88adc02 100644 --- a/rust_bindings/Cargo.toml +++ b/rust_bindings/Cargo.toml @@ -14,7 +14,6 @@ link-cplusplus = "1.0.9" [build-dependencies] bindgen = "0.69.4" cmake = "0.1.50" -vcpkg = "0.2.15" [dev-dependencies] hex = "0.4.3" diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 0da92aa..79ddb2e 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -45,8 +45,6 @@ fn main() { .to_str() .unwrap() ); - - vcpkg::find_package("gmp").unwrap(); } else { println!( "cargo:rustc-link-search=native={}", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22cb662..9e7b94e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR) option(BUILD_CHIAVDFC "Build the chiavdfc shared library" OFF) option(BUILD_PYTHON "Build the python bindings for chiavdf" ON) -option(SKIP_MPIR_LINK "Skip linking MPIR" OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -31,9 +30,7 @@ if(WIN32) ${MPIR_INCLUDE_DIR} ) find_library(MPIR_LIBRARY NAMES mpir PATHS ${MPIR_LIBRARY_DIR} NO_DEFAULT_PATH) - if(SKIP_MPIR_LINK) - message(STATUS "MPIR library found, skipping linking") - elseif(MPIR_LIBRARY) + if(MPIR_LIBRARY) message(STATUS "MPIR library found at ${MPIR_LIBRARY}") link_libraries(${MPIR_LIBRARY}) else() From 07d7ff87847e81c8ed2a5ee2378377e883a8a215 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:29:59 -0400 Subject: [PATCH 20/31] libclang-dev --- .github/workflows/rust.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 695c453..bf0aa59 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -94,7 +94,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: GMP library path on MacOS + - name: Setup library path on MacOS if: matrix.os.name == 'macOS' run: echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV @@ -102,6 +102,10 @@ jobs: if: matrix.os.name == 'Windows' run: git clone https://github.com/Chia-Network/mpir_gc_x64.git + - name: Install libclang-dev on Linux + if: matrix.os.name == 'Ubuntu' + run: sudo apt-get install libclang-dev + - name: Set up Rust uses: dtolnay/rust-toolchain@stable From 4d917a8e22a257a8187729e3756cfb3ddfc6760b Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:34:17 -0400 Subject: [PATCH 21/31] Add link path --- .github/workflows/rust.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf0aa59..c4c0f43 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,7 +100,9 @@ jobs: - name: Install MPIR on Windows if: matrix.os.name == 'Windows' - run: git clone https://github.com/Chia-Network/mpir_gc_x64.git + run: | + git clone https://github.com/Chia-Network/mpir_gc_x64.git + echo "RUSTFLAGS='-C link-args=-Wl,-rpath,${{ github.workspace }}/mpir_gc_x64'" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install libclang-dev on Linux if: matrix.os.name == 'Ubuntu' From 90466ef0a28477d6689a46ee674b377a521c89fb Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:40:24 -0400 Subject: [PATCH 22/31] GITHUB_PATH --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c4c0f43..7737c39 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -102,11 +102,11 @@ jobs: if: matrix.os.name == 'Windows' run: | git clone https://github.com/Chia-Network/mpir_gc_x64.git - echo "RUSTFLAGS='-C link-args=-Wl,-rpath,${{ github.workspace }}/mpir_gc_x64'" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "$(Get-Location)\mpir_gc_x64" >> $GITHUB_PATH - name: Install libclang-dev on Linux if: matrix.os.name == 'Ubuntu' - run: sudo apt-get install libclang-dev + run: sudo apt-get install libclang-dev -y - name: Set up Rust uses: dtolnay/rust-toolchain@stable From 0f6e14623b13ffab40b4f9c16305fcaef041f15f Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:48:27 -0400 Subject: [PATCH 23/31] Link mpir? --- rust_bindings/build.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 79ddb2e..58c531e 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -45,6 +45,17 @@ fn main() { .to_str() .unwrap() ); + + println!("cargo:rustc-link-lib=static=mpir"); + println!( + "cargo:rustc-link-search=native={}", + src_dir + .parent() + .unwrap() + .join("mpir_gc_x64") + .to_str() + .unwrap() + ); } else { println!( "cargo:rustc-link-search=native={}", From 06f8da9ddd955014c7f03a4d9f480060f273a005 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 22:56:12 -0400 Subject: [PATCH 24/31] Add check --- .github/workflows/rust.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7737c39..2865d1e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -152,6 +152,16 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check if MPIR DLL is on the PATH + run: | + $pathList = $Env:PATH -split ";" + foreach ($path in $pathList) { + if (Test-Path "$path\mpir.dll") { + Write-Output "Found mpir.dll in $path" + } + } + shell: powershell + - name: Publish to crates.io if: env.RELEASE == 'true' env: From 407ccc223f9bb6ce2a68ceecba8cf24905f368b6 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 29 Sep 2024 23:25:45 -0400 Subject: [PATCH 25/31] fix --- .github/workflows/rust.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2865d1e..0f4c0ab 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -104,6 +104,16 @@ jobs: git clone https://github.com/Chia-Network/mpir_gc_x64.git echo "$(Get-Location)\mpir_gc_x64" >> $GITHUB_PATH + - name: Check if MPIR DLL is on the PATH + if: matrix.os.name == 'Windows' + run: | + $pathList = $Env:PATH -split ";" + foreach ($path in $pathList) { + if (Test-Path "$path\mpir.dll") { + Write-Output "Found mpir.dll in $path" + } + } + - name: Install libclang-dev on Linux if: matrix.os.name == 'Ubuntu' run: sudo apt-get install libclang-dev -y @@ -152,16 +162,6 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check if MPIR DLL is on the PATH - run: | - $pathList = $Env:PATH -split ";" - foreach ($path in $pathList) { - if (Test-Path "$path\mpir.dll") { - Write-Output "Found mpir.dll in $path" - } - } - shell: powershell - - name: Publish to crates.io if: env.RELEASE == 'true' env: From 13954667285a01cfdada683a107d77ed59a76767 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:10:44 -0400 Subject: [PATCH 26/31] Debug --- .github/workflows/rust.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0f4c0ab..897f422 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -102,7 +102,16 @@ jobs: if: matrix.os.name == 'Windows' run: | git clone https://github.com/Chia-Network/mpir_gc_x64.git + echo 0 echo "$(Get-Location)\mpir_gc_x64" >> $GITHUB_PATH + echo X + echo $GITHUB_PATH + echo Y + echo $Env:PATH + echo Z + echo $Env:GITHUB_PATH + echo A + echo $Env:GITHUB_ENV - name: Check if MPIR DLL is on the PATH if: matrix.os.name == 'Windows' From b28ef6cd134e566e5425ccc92b6a78ba0caab378 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:15:32 -0400 Subject: [PATCH 27/31] Test --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 897f422..b26203f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -103,7 +103,7 @@ jobs: run: | git clone https://github.com/Chia-Network/mpir_gc_x64.git echo 0 - echo "$(Get-Location)\mpir_gc_x64" >> $GITHUB_PATH + "$((Get-Location)\mpir_gc_x64)" | Out-File -Append -FilePath $env:GITHUB_PATH echo X echo $GITHUB_PATH echo Y From f6ec69e185fc156b1d3686099491ba2f319f7f6e Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:22:56 -0400 Subject: [PATCH 28/31] 2 --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b26203f..851a4ba 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -103,7 +103,7 @@ jobs: run: | git clone https://github.com/Chia-Network/mpir_gc_x64.git echo 0 - "$((Get-Location)\mpir_gc_x64)" | Out-File -Append -FilePath $env:GITHUB_PATH + "$(Get-Location)/mpir_gc_x64" | Out-File -Append -FilePath $env:GITHUB_PATH echo X echo $GITHUB_PATH echo Y From 843565a309ff821aed7dad89cbc83e7aa3cea2e6 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:27:02 -0400 Subject: [PATCH 29/31] Cleanup cruft --- .github/workflows/rust.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 851a4ba..51bfe14 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -102,26 +102,7 @@ jobs: if: matrix.os.name == 'Windows' run: | git clone https://github.com/Chia-Network/mpir_gc_x64.git - echo 0 "$(Get-Location)/mpir_gc_x64" | Out-File -Append -FilePath $env:GITHUB_PATH - echo X - echo $GITHUB_PATH - echo Y - echo $Env:PATH - echo Z - echo $Env:GITHUB_PATH - echo A - echo $Env:GITHUB_ENV - - - name: Check if MPIR DLL is on the PATH - if: matrix.os.name == 'Windows' - run: | - $pathList = $Env:PATH -split ";" - foreach ($path in $pathList) { - if (Test-Path "$path\mpir.dll") { - Write-Output "Found mpir.dll in $path" - } - } - name: Install libclang-dev on Linux if: matrix.os.name == 'Ubuntu' From bb6a35afb1aed533d52f3715d091a1fb1d5e0784 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:27:31 -0400 Subject: [PATCH 30/31] Remove old flag --- rust_bindings/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust_bindings/build.rs b/rust_bindings/build.rs index 58c531e..5e5ba21 100644 --- a/rust_bindings/build.rs +++ b/rust_bindings/build.rs @@ -24,7 +24,6 @@ fn main() { .define("BUILD_CHIAVDFC", "ON") .env("BUILD_VDF_CLIENT", "N") .define("BUILD_PYTHON", "OFF") - .define("SKIP_MPIR_LINK", "ON") .build(); println!("cargo:rustc-link-lib=static=chiavdfc"); From 93166a0112d157cf9704e71e02fb38fa839a32b6 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 30 Sep 2024 09:28:57 -0400 Subject: [PATCH 31/31] Add concurrency --- .github/workflows/rust.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 51bfe14..603a805 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,6 +10,10 @@ on: branches: - "**" +concurrency: + group: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.workflow_ref, github.event.pull_request.number) || github.run_id }} + cancel-in-progress: true + permissions: id-token: write contents: read