mirror of
https://github.com/logos-blockchain/logos-blockchain-circuits.git
synced 2026-07-03 15:39:46 +00:00
Unify gmp across OS, prover/verifier and witness generators.
This commit is contained in:
parent
e98e02300e
commit
6de559701e
19
.github/resources/witness-generator/Makefile
vendored
19
.github/resources/witness-generator/Makefile
vendored
@ -7,6 +7,7 @@ endif
|
||||
|
||||
# ---- Common ----
|
||||
CXX := g++
|
||||
PRIORITY_FLAGS ?=
|
||||
CXXFLAGS_COMMON := -std=c++11 -O3 -I. -Wno-address-of-packed-member -Dmain=circom_main
|
||||
COMMON_SRCS := main.cpp calcwit.cpp fr.cpp $(PROJECT).cpp
|
||||
COMMON_OBJS := $(COMMON_SRCS:.cpp=.o)
|
||||
@ -26,30 +27,36 @@ endif
|
||||
LIB := $(LIB_PREFIX)$(PROJECT)$(LIB_EXT)
|
||||
|
||||
# ---- Linux (x86_64 and aarch64) ----
|
||||
linux: CXXFLAGS=$(CXXFLAGS_COMMON)
|
||||
# NOTE: linux (bin) links system gmp via -lgmp. CI uses linux-lib only, which
|
||||
# relies on PRIORITY_FLAGS to prefer the gmp built from source over the system one.
|
||||
linux: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON)
|
||||
linux: LDFLAGS=-static
|
||||
linux: LDLIBS=-lgmp
|
||||
linux: $(BIN)
|
||||
|
||||
linux-lib: CXXFLAGS=$(CXXFLAGS_COMMON) -fPIC
|
||||
linux-lib: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON) -fPIC
|
||||
linux-lib: $(LIB)
|
||||
|
||||
# ---- macOS ----
|
||||
macos: CXXFLAGS=$(CXXFLAGS_COMMON) -I/opt/homebrew/include -include gmp_patch.hpp -mmacosx-version-min=11.0
|
||||
# NOTE: macos (bin) hardcodes Homebrew gmp for both includes and linking. CI uses
|
||||
# macos-lib only, which relies on PRIORITY_FLAGS to prefer the gmp built from source.
|
||||
macos: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON) -I/opt/homebrew/include -include gmp_patch.hpp -mmacosx-version-min=11.0
|
||||
macos: LDFLAGS=-Wl,-search_paths_first -Wl,-dead_strip
|
||||
macos: LDLIBS=/opt/homebrew/lib/libgmp.a
|
||||
macos: $(BIN)
|
||||
|
||||
macos-lib: CXXFLAGS=$(CXXFLAGS_COMMON) -fPIC -I/opt/homebrew/include -include gmp_patch.hpp -mmacosx-version-min=11.0
|
||||
macos-lib: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON) -fPIC -I/opt/homebrew/include -include gmp_patch.hpp -mmacosx-version-min=11.0
|
||||
macos-lib: $(LIB)
|
||||
|
||||
# ---- Windows (MinGW) ----
|
||||
windows: CXXFLAGS=$(CXXFLAGS_COMMON) -I/include -Duint="unsigned int"
|
||||
# NOTE: windows (bin) links system gmp via -lgmp. CI uses windows-lib only, which
|
||||
# relies on PRIORITY_FLAGS to prefer the gmp built from source over the system one.
|
||||
windows: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON) -I/include -Duint="unsigned int"
|
||||
windows: LDFLAGS=-static
|
||||
windows: LDLIBS=-L/lib -lgmp -lmman
|
||||
windows: $(BIN)
|
||||
|
||||
windows-lib: CXXFLAGS=$(CXXFLAGS_COMMON) -fPIC -I/include -Duint="unsigned int"
|
||||
windows-lib: CXXFLAGS=$(PRIORITY_FLAGS) $(CXXFLAGS_COMMON) -fPIC -I/include -Duint="unsigned int"
|
||||
windows-lib: $(LIB)
|
||||
|
||||
# Localizes all circuit-specific code to prevent conflicts when multiple circuit
|
||||
|
||||
74
.github/workflows/ci.yml
vendored
74
.github/workflows/ci.yml
vendored
@ -195,14 +195,8 @@ jobs:
|
||||
working-directory: rapidsnark
|
||||
run: sudo apt update -y
|
||||
|
||||
- name: Check GMP Before Deps
|
||||
run: dpkg -l | grep libgmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Prover]
|
||||
run: sudo apt install -y build-essential cmake libgmp-dev libsodium-dev nasm curl m4
|
||||
|
||||
- name: Check GMP After Prover Deps
|
||||
run: dpkg -l | grep libgmp || echo "gmp not installed"
|
||||
run: sudo apt install -y build-essential cmake libsodium-dev nasm curl m4
|
||||
|
||||
- name: Install Dependencies [Witness Generator]
|
||||
run: sudo apt install -y nlohmann-json3-dev llvm
|
||||
@ -231,6 +225,12 @@ jobs:
|
||||
./build_gmp.sh host
|
||||
make host_linux_x86_64_static
|
||||
|
||||
- name: Prioritize Built GMP Headers Over System GMP
|
||||
run: |
|
||||
# System gmp (6.2.1) is preinstalled on the runner. Prepend our built gmp headers
|
||||
# so the witness generator compiles against the same gmp version as the prover.
|
||||
echo "PRIORITY_FLAGS=-I${{ github.workspace }}/rapidsnark/depends/gmp/package/include" >> $GITHUB_ENV
|
||||
|
||||
- name: Bundle Rapidsnark Prover
|
||||
env:
|
||||
BINARY_NAME: prover
|
||||
@ -446,14 +446,8 @@ jobs:
|
||||
working-directory: rapidsnark
|
||||
run: sudo apt update -y
|
||||
|
||||
- name: Check GMP Before Deps
|
||||
run: dpkg -l | grep libgmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Prover]
|
||||
run: sudo apt install -y build-essential cmake libgmp-dev libsodium-dev nasm curl m4
|
||||
|
||||
- name: Check GMP After Prover Deps
|
||||
run: dpkg -l | grep libgmp || echo "gmp not installed"
|
||||
run: sudo apt install -y build-essential cmake libsodium-dev nasm curl m4
|
||||
|
||||
- name: Install Dependencies [Witness Generator]
|
||||
run: sudo apt install -y nlohmann-json3-dev llvm
|
||||
@ -484,6 +478,12 @@ jobs:
|
||||
ln -s package depends/gmp/package_aarch64
|
||||
make host_linux_aarch64_static
|
||||
|
||||
- name: Prioritize Built GMP Headers Over System GMP
|
||||
run: |
|
||||
# System gmp (6.2.1) is preinstalled on the runner. Prepend our built gmp headers
|
||||
# so the witness generator compiles against the same gmp version as the prover.
|
||||
echo "PRIORITY_FLAGS=-I${{ github.workspace }}/rapidsnark/depends/gmp/package/include" >> $GITHUB_ENV
|
||||
|
||||
- name: Bundle Rapidsnark Prover
|
||||
env:
|
||||
BINARY_NAME: prover
|
||||
@ -705,10 +705,6 @@ jobs:
|
||||
$env:RUSTFLAGS="-A dead_code"; cargo install --path circom
|
||||
circom --version
|
||||
|
||||
- name: Check GMP Before Deps
|
||||
shell: msys2 {0}
|
||||
run: pacman -Q | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Witness Generator]
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
@ -724,18 +720,10 @@ jobs:
|
||||
make install
|
||||
popd
|
||||
|
||||
- name: Check GMP After Witness Generator Deps
|
||||
shell: msys2 {0}
|
||||
run: pacman -Q | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Prover]
|
||||
shell: msys2 {0}
|
||||
run: pacman --noconfirm -Sy --needed cmake nasm mingw-w64-ucrt-x86_64-libsodium
|
||||
|
||||
- name: Check GMP After Prover Deps
|
||||
shell: msys2 {0}
|
||||
run: pacman -Q | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Replace Prover Makefile # TODO: Make a fork generate the appropriate Windows Makefile
|
||||
shell: msys2 {0}
|
||||
run: cp .github/resources/prover/Makefile rapidsnark/Makefile
|
||||
@ -779,6 +767,13 @@ jobs:
|
||||
./build_gmp.sh host
|
||||
make host_windows_x86_64_static
|
||||
|
||||
- name: Prioritize Built GMP Headers Over System GMP
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
# System gmp (6.3.0) is preinstalled on the runner. Prepend our built gmp headers
|
||||
# so the witness generator compiles against the same gmp version as the prover.
|
||||
echo "PRIORITY_FLAGS=-I$(cygpath -u "$GITHUB_WORKSPACE")/rapidsnark/depends/gmp/package/include" >> $GITHUB_ENV
|
||||
|
||||
- name: Bundle Rapidsnark Prover
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
@ -995,21 +990,12 @@ jobs:
|
||||
- name: Setup Dependencies
|
||||
run: mkdir include
|
||||
|
||||
- name: Check GMP Before Deps
|
||||
run: brew list --versions | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Witness Generator]
|
||||
run: brew install nlohmann-json binutils
|
||||
|
||||
- name: Check GMP After Witness Generator Deps
|
||||
run: brew list --versions | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Install Dependencies [Prover]
|
||||
run: brew install nasm m4
|
||||
|
||||
- name: Check GMP After Prover Deps
|
||||
run: brew list --versions | grep gmp || echo "gmp not installed"
|
||||
|
||||
- name: Cache GMP Archive
|
||||
id: cache-gmp
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
|
||||
@ -1026,11 +1012,23 @@ jobs:
|
||||
echo "Download complete."
|
||||
|
||||
- name: Compile Prover and Verifier
|
||||
env:
|
||||
# Ensures gmp and the prover are built targeting macOS 11.0 (the minimum for
|
||||
# aarch64-apple-darwin), preventing rust-lld deployment target mismatch warnings
|
||||
# when nomos links against the bundled libgmp.a.
|
||||
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
||||
working-directory: rapidsnark
|
||||
run: |
|
||||
./build_gmp.sh macos_arm64
|
||||
make macos_arm64
|
||||
|
||||
- name: Prioritize Built GMP Headers Over System GMP
|
||||
run: |
|
||||
# System gmp (6.3.0) is preinstalled on the runner. Prepend our built gmp headers
|
||||
# so the witness generator compiles against the same gmp version as the prover,
|
||||
# and the built gmp targets macOS 11.0 rather than the runner's current OS version.
|
||||
echo "PRIORITY_FLAGS=-I${{ github.workspace }}/rapidsnark/depends/gmp/package_macos_arm64/include" >> $GITHUB_ENV
|
||||
|
||||
- name: Bundle Rapidsnark Prover
|
||||
env:
|
||||
BINARY_NAME: prover
|
||||
@ -1234,9 +1232,6 @@ jobs:
|
||||
- name: Install Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt install -y libgmp-dev
|
||||
|
||||
- name: Cache Cargo artifacts
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # Version 4.2.3
|
||||
with:
|
||||
@ -1290,9 +1285,6 @@ jobs:
|
||||
- name: Install Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt install -y libgmp-dev
|
||||
|
||||
- name: Cache Cargo artifacts
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # Version 4.2.3
|
||||
with:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user