From c5878f77a558ebd2926780d3c002b2ca36a92464 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 20 Nov 2021 22:18:01 +0100 Subject: [PATCH] GMP/MPIR bindings fixups. --- .github/workflows/benchmark.yml | 15 ++++++++++++--- .github/workflows/build-arm64-wheels.yml | 10 +++++++--- .github/workflows/build-crate-and-npm.yml | 7 +++++++ .github/workflows/build-m1-wheel.yml | 4 ++-- .github/workflows/build-test.yml | 17 ++++++++++++++--- build.rs | 14 +++----------- 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 845a82d1..031cea57 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -45,6 +45,14 @@ jobs: python -m pip install maturin rustup target add x86_64-unknown-linux-musl + - name: Install GMP + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get install lzip -y + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x && \ + cd gmp-6.2.1 && ./configure --enable-fat --with-pic && \ + make -j 6 && sudo make install && cd .. && rm -rf gmp-6.2.1 + - name: Build Windows if: startsWith(matrix.os, 'windows') run: | @@ -114,11 +122,12 @@ jobs: - name: Install dependencies run: | + sudo apt-get install lzip -y + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x && \ + cd gmp-6.2.1 && ./configure --enable-fat --with-pic && \ + make -j 6 && sudo make install && cd .. && rm -rf gmp-6.2.1 python -m pip install maturin rustup target add x86_64-unknown-linux-musl - sudo apt install libgmp3-dev - ls -la /usr/lib64 - ls -la /usr/lib - name: Build env: diff --git a/.github/workflows/build-arm64-wheels.yml b/.github/workflows/build-arm64-wheels.yml index 05bcac0d..6172f47d 100644 --- a/.github/workflows/build-arm64-wheels.yml +++ b/.github/workflows/build-arm64-wheels.yml @@ -20,6 +20,9 @@ jobs: os: [ ARM64 ] # , ubuntu-latest ] steps: + + - uses: Chia-Network/actions/clean-workspace@main + - name: Checkout repository uses: actions/checkout@v2 with: @@ -41,9 +44,10 @@ jobs: echo $PATH && \ curl -L https://sh.rustup.rs > rustup-init.sh && \ sh rustup-init.sh -y && \ - yum -y install openssl-devel && \ - yum -y install gmp && \ - ls -la /usr/lib64/ && \ + yum -y install sudo openssl-devel && \ + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2 | tar -xj && \ + cd gmp-6.2.1 && ./configure --enable-fat --with-pic && \ + make -j 6 && sudo make install && cd .. && rm -rf gmp-6.2.1 && \ source $HOME/.cargo/env && \ rustup target add aarch64-unknown-linux-musl && \ rm -rf venv && \ diff --git a/.github/workflows/build-crate-and-npm.yml b/.github/workflows/build-crate-and-npm.yml index 7082f2f4..2fcb58ad 100644 --- a/.github/workflows/build-crate-and-npm.yml +++ b/.github/workflows/build-crate-and-npm.yml @@ -23,6 +23,13 @@ jobs: with: fetch-depth: 0 + - name: Install GMP + run: | + sudo apt-get install lzip -y + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x && \ + cd gmp-6.2.1 && ./configure --enable-fat --with-pic && \ + make -j 6 && sudo make install && cd .. && rm -rf gmp-6.2.1 + - name: Set up rusts uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 5bf40c91..b3b91b6d 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -37,7 +37,7 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh arch -arm64 sh rust.sh -y - - name: install GMP + - name: Install GMP run: | curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | tar x cd gmp-6.2.1 @@ -53,7 +53,7 @@ jobs: . ./venv/bin/activate export PATH=~/.cargo/bin:$PATH arch -arm64 pip install maturin - arch -arm64 maturin build --no-sdist -i python --release --strip --cargo-extra-args="--features=openssl" + arch -arm64 maturin build --no-sdist --release --strip --cargo-extra-args="--features=openssl" - name: Install clvm_rs wheel run: | diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9a07f6a7..45432e11 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -70,9 +70,10 @@ jobs: bash -exc '\ curl -L https://sh.rustup.rs > rustup-init.sh && \ sh rustup-init.sh -y && \ - yum -y install openssl-devel && \ - yum -y install gmp && \ - ls -la /usr/lib64 && \ + yum -y install sudo openssl-devel && \ + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2 | tar -xj && \ + cd gmp-6.2.1 && ./configure --enable-fat --with-pic && \ + make -j 6 && sudo make install && cd .. && rm -rf gmp-6.2.1 && \ source $HOME/.cargo/env && \ rustup target add x86_64-unknown-linux-musl && \ rm -rf venv && \ @@ -245,6 +246,16 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 1 + - name: Install GMP + run: | + sudo apt-get install lzip -y + curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x + cd gmp-6.2.1 + ./configure --enable-fat --with-pic + make -j 6 + sudo make install + cd .. + rm -rf gmp-6.2.1 - name: Install rust uses: actions-rs/toolchain@v1 with: diff --git a/build.rs b/build.rs index 8e500fb5..e84daf04 100644 --- a/build.rs +++ b/build.rs @@ -1,18 +1,10 @@ fn main() { - #[cfg(target_os = "windows")] - { + if cfg!(windows) { println!("cargo:rustc-link-lib=mpir"); println!("cargo:rustc-link-search=mpir_gc_x64"); - } - #[cfg(target_os = "linux")] - { - println!("cargo:rustc-link-lib=gmp"); - println!("cargo:rustc-link-search=/usr/lib64"); - println!("cargo:rustc-link-search=/usr/lib"); - } - #[cfg(target_os = "macos")] - { + } else { println!("cargo:rustc-link-lib=gmp"); + println!("cargo:rustc-link-search=/usr/local/lib"); println!("cargo:rustc-link-search=/opt/homebrew/lib"); } }