Skip to content

Commit 52384e5

Browse files
committedFeb 18, 2025·
Merged latest main branch
2 parents 96f912f + 315a7d1 commit 52384e5

File tree

6 files changed

+113
-93
lines changed

6 files changed

+113
-93
lines changed
 

‎.github/workflows/build.yml

+58-58
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010

1111
jobs:
1212

13-
build-linux:
14-
runs-on: ubuntu-22.04
13+
build-linux-x86_64:
14+
runs-on: ubuntu-24.04
1515
steps:
1616
- uses: actions/checkout@v4
1717
with:
@@ -21,38 +21,15 @@ jobs:
2121
uses: awalsh128/cache-apt-pkgs-action@v1
2222
with:
2323
packages: build-essential cmake m4 nasm
24-
version: 1.0
25-
26-
- name: Setup QEMU to build ARM64 variant
27-
uses: docker/setup-qemu-action@v3
28-
29-
- name: Setup buildx for ARM64 platform
30-
uses: docker/setup-buildx-action@v3
31-
with:
32-
platforms: linux/amd64,linux/arm64
33-
34-
- name: Prepare Docker image builder for ARM64
35-
uses: docker/build-push-action@v6
36-
env:
37-
DOCKER_BUILD_SUMMARY: false
38-
DOCKER_BUILD_RECORD_UPLOAD: false
39-
with:
40-
push: false
41-
outputs: type=docker
42-
platforms: linux/arm64
43-
file: .github/images/Dockerfile.build
44-
context: ./.github/images/context.build
45-
cache-from: type=gha,scope=buildkit-arm64
46-
cache-to: type=gha,mode=max,scope=buildkit-arm64
47-
tags: builder:arm64
24+
version: x86_64-1.0
4825

4926
- name: Cache gmp build
5027
uses: actions/cache@v4
5128
with:
5229
path: |
5330
depends/gmp
5431
depends/gmp-6.2.1.tar.xz
55-
key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-4
32+
key: ${{ runner.os }}-${{ runner.arch }}-gmp-${{ hashFiles('build_gmp.sh') }}
5633

5734
- name: Build gmp for Android arm64
5835
run: if [[ ! -d "depends/gmp/package_android_arm64" ]]; then ./build_gmp.sh android; fi
@@ -63,12 +40,6 @@ jobs:
6340
- name: Build gmp for Linux x86_64
6441
run: if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi
6542

66-
- name: Build gmp for Linux arm64
67-
run: |
68-
if [[ ! -d "depends/gmp/package_aarch64" ]]; then
69-
docker run --rm --platform=linux/arm64 -i -v $PWD:/work --workdir=/work builder:arm64 ./build_gmp.sh aarch64
70-
fi
71-
7243
- name: Build prover Android ARM64
7344
run: |
7445
make android
@@ -95,16 +66,6 @@ jobs:
9566
make host_noasm
9667
ctest --rerun-failed --output-on-failure
9768
98-
- name: Build prover Linux arm64
99-
run: |
100-
docker run --rm --platform=linux/arm64 -i -v $PWD:/work --workdir=/work builder:arm64 bash -c "$(cat << 'EOF'
101-
set -x
102-
set -e
103-
make arm64
104-
ctest --rerun-failed --output-on-failure
105-
EOF
106-
)"
107-
10869
- name: Test rapidsnark
10970
run: |
11071
set -x
@@ -137,15 +98,6 @@ jobs:
13798
package_noasm
13899
if-no-files-found: error
139100

140-
- name: Upload Linux arm64 dev artifacts
141-
if: github.event_name != 'release'
142-
uses: actions/upload-artifact@v4
143-
with:
144-
name: rapidsnark-linux-arm64
145-
path: |
146-
package_arm64
147-
if-no-files-found: error
148-
149101
- name: Upload Android dev artifacts
150102
if: github.event_name != 'release'
151103
uses: actions/upload-artifact@v4
@@ -226,6 +178,58 @@ jobs:
226178
zip -r rapidsnark-linux-x86_64-noasm-${{ github.ref_name }}.zip rapidsnark-linux-x86_64-noasm-${{ github.ref_name }}
227179
gh release upload ${{ github.event.release.tag_name }} rapidsnark-linux-x86_64-noasm-${{ github.ref_name }}.zip
228180
181+
build-linux-arm64:
182+
runs-on: ubuntu-24.04-arm
183+
steps:
184+
- uses: actions/checkout@v4
185+
with:
186+
submodules: "recursive"
187+
188+
- name: install requirements
189+
uses: awalsh128/cache-apt-pkgs-action@v1
190+
with:
191+
packages: build-essential cmake m4 nasm
192+
version: arm64-1.0
193+
194+
- name: Cache gmp build
195+
uses: actions/cache@v4
196+
with:
197+
path: |
198+
depends/gmp
199+
depends/gmp-6.2.1.tar.xz
200+
key: ${{ runner.os }}-${{ runner.arch }}-gmp-${{ hashFiles('build_gmp.sh') }}
201+
202+
- name: Build gmp for Linux arm64
203+
run: if [[ ! -d "depends/gmp/package_aarch64" ]]; then ./build_gmp.sh aarch64; fi
204+
205+
- name: Build prover Linux arm64
206+
run: |
207+
make host_arm64
208+
ctest --rerun-failed --output-on-failure
209+
210+
- name: Test rapidsnark
211+
run: |
212+
set -x
213+
set -e
214+
time package_arm64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
215+
time package_arm64/bin/verifier testdata/verification_key.json public.json proof.json
216+
# make a wrong public.json by decrementing the first element by 1
217+
(value_0=$(jq '.[0]' public.json | tr -d '"') && value_0=$(echo "$value_0 - 1" | BC_LINE_LENGTH=100 bc) && jq --arg value_0 "$value_0" '.[0] = $value_0' public.json) > public_bad.json
218+
set +e
219+
time package_arm64/bin/verifier testdata/verification_key.json public_bad.json proof.json
220+
exit_code=$?
221+
set -e
222+
[ $exit_code -ne 0 ]
223+
224+
- name: Upload Linux arm64 dev artifacts
225+
if: github.event_name != 'release'
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: rapidsnark-linux-arm64
229+
path: |
230+
package_arm64
231+
if-no-files-found: error
232+
229233
- name: Upload Linux ARM64 release artifacts
230234
if: github.event_name == 'release'
231235
env:
@@ -250,18 +254,15 @@ jobs:
250254
path: |
251255
depends/gmp
252256
depends/gmp-6.2.1.tar.xz
253-
key: ${{ runner.os }}-gmp-arm64-${{ hashFiles('build_gmp.sh') }}
257+
key: ${{ runner.os }}-${{ runner.arch }}-gmp-${{ hashFiles('build_gmp.sh') }}
254258

255259
- name: build
256260
run: |
257261
if [[ ! -d "depends/gmp/package_ios_arm64" ]]; then ./build_gmp.sh ios; fi
258262
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
259263
if [[ ! -d "depends/gmp/package_macos_arm64" ]]; then ./build_gmp.sh macos_arm64; fi
260-
261264
make ios
262-
263265
make ios_simulator
264-
265266
make macos_arm64
266267
ctest --rerun-failed --output-on-failure
267268
@@ -352,7 +353,7 @@ jobs:
352353
path: |
353354
depends/gmp
354355
depends/gmp-6.2.1.tar.xz
355-
key: ${{ runner.os }}-gmp-x86_64-${{ hashFiles('build_gmp.sh') }}-2
356+
key: ${{ runner.os }}-${{ runner.arch }}-gmp-${{ hashFiles('build_gmp.sh') }}
356357

357358
- name: install dependencies
358359
run: |
@@ -361,7 +362,6 @@ jobs:
361362
- name: build
362363
run: |
363364
if [[ ! -d "depends/gmp/package_macos_x86_64" ]]; then ./build_gmp.sh macos_x86_64; fi
364-
365365
make macos_x86_64
366366
ctest --rerun-failed --output-on-failure
367367

‎CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.10)
22

33
include(cmake/platform.cmake)
44

‎Makefile

+41-24
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ host:
88

99
host_noasm:
1010
rm -rf build_prover_noasm && mkdir build_prover_noasm && cd build_prover_noasm && \
11-
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_noasm -DUSE_ASM=NO && \
12-
make -j$(nproc) -vvv && make install
11+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_noasm -DUSE_ASM=NO && \
12+
make -j$(nproc) -vvv && make install
1313

1414
host_arm64:
15-
rm -rf build_prover && mkdir build_prover && cd build_prover && \
16-
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package && \
17-
make -j$(nproc) -vvv && make install
18-
19-
arm64:
2015
rm -rf build_prover_arm64 && mkdir build_prover_arm64 && cd build_prover_arm64 && \
2116
cmake .. -DTARGET_PLATFORM=aarch64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_arm64 && \
2217
make -j$(nproc) -vvv && make install
@@ -42,32 +37,54 @@ android_openmp_x86_64:
4237
make -j$(nproc) -vvv && make install
4338

4439
ios:
40+
@if [ ! -d "./depends/gmp/package_ios_arm64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh ios' first." && exit 1; fi
4541
rm -rf build_prover_ios && mkdir build_prover_ios && cd build_prover_ios && \
46-
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios -DBUILD_TESTS=OFF && \
47-
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release && \
48-
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnark -project rapidsnark.xcodeproj -configuration Release CODE_SIGNING_ALLOWED=NO && \
49-
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos && \
50-
echo "" && echo "Now open Xcode and compile the generated project" && echo ""
42+
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios && \
43+
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release && \
44+
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnark -project rapidsnark.xcodeproj -configuration Release CODE_SIGNING_ALLOWED=NO && \
45+
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos && \
46+
echo "" && echo "iOS Simulator artifacts built in build_prover_ios/src/Release-iphoneos" && echo ""
5147

5248
ios_simulator:
49+
@if [ ! -d "./depends/gmp/package_iphone_simulator" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh ios_simulator' first." && exit 1; fi
5350
rm -rf build_prover_ios_simulator && mkdir build_prover_ios_simulator && cd build_prover_ios_simulator && \
54-
cmake .. -GXcode -DTARGET_PLATFORM=IOS_SIMULATOR -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO -DBUILD_TESTS=OFF && \
55-
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj && \
56-
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnark -project rapidsnark.xcodeproj CODE_SIGNING_ALLOWED=NO ARCHS=arm64 && \
57-
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator && \
58-
echo "" && echo "Now open Xcode and compile the generated project" && echo ""
51+
cmake .. -GXcode -DTARGET_PLATFORM=IOS_SIMULATOR -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO && \
52+
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj && \
53+
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnark -project rapidsnark.xcodeproj CODE_SIGNING_ALLOWED=NO ARCHS=arm64 && \
54+
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator && \
55+
echo "" && echo "iOS Simulator artifacts built in build_prover_ios_simulator/src/Debug-iphonesimulator" && echo ""
5956

6057
macos_arm64:
58+
@if [ ! -d "./depends/gmp/package_macos_arm64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh macos_arm64' first." && exit 1; fi
6159
rm -rf build_prover_macos_arm64 && mkdir build_prover_macos_arm64 && cd build_prover_macos_arm64 && \
62-
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64 && \
63-
make -j$(nproc) -vvv && make install
60+
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64 && \
61+
make -j$(nproc) -vvv && make install
6462

6563
macos_x86_64:
64+
@if [ ! -d "./depends/gmp/package_macos_x86_64" ]; then echo "Looks like gmp lib is not built. Run './build_gmp.sh macos_x86_64' first." && exit 1; fi
6665
rm -rf build_prover_macos_x86_64 && mkdir build_prover_macos_x86_64 && cd build_prover_macos_x86_64 && \
67-
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64 && \
68-
make -j$(nproc) -vvv && make install
66+
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64 && \
67+
make -j$(nproc) -vvv && make install
6968

7069
clean:
71-
rm -rf build_prover build_prover_android build_prover_android_x86_64 build_prover_ios package package_android \
72-
package_android_x86_64 package_ios depends/gmp/package depends/gmp/package_android_arm64 \
73-
depends/gmp/package_android_x86_64 depends/gmp/package_ios_arm64
70+
rm -rf build_prover \
71+
build_prover_macos_arm64 \
72+
build_prover_macos_x86_64 \
73+
build_prover_android \
74+
build_prover_android_x86_64 \
75+
build_prover_ios \
76+
build_prover_ios_simulator \
77+
package \
78+
package_macos_arm64 \
79+
package_macos_x86_64 \
80+
package_android \
81+
package_android_x86_64 \
82+
package_ios \
83+
package_ios_simulator \
84+
depends/gmp/package \
85+
depends/gmp/package_macos_arm64 \
86+
depends/gmp/package_macos_x86_64 \
87+
depends/gmp/package_android_arm64 \
88+
depends/gmp/package_android_x86_64 \
89+
depends/gmp/package_ios_arm64 \
90+
depends/gmp/package_iphone_simulator

‎build_gmp.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ build_android()
128128
return 1
129129
fi
130130

131-
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
131+
if [ "$(uname)" == "Darwin" ]; then
132+
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
133+
else
134+
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
135+
fi
132136

133137
export TARGET=aarch64-linux-android
134138
export API=21
@@ -173,7 +177,11 @@ build_android_x86_64()
173177
return 1
174178
fi
175179

176-
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
180+
if [ "$(uname)" == "Darwin" ]; then
181+
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
182+
else
183+
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
184+
fi
177185

178186
export TARGET=x86_64-linux-android
179187
export API=21

‎cmake/platform.cmake

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.10)
22

33
string(TOLOWER "${TARGET_PLATFORM}" TARGET_PLATFORM)
44

@@ -55,11 +55,6 @@ elseif(TARGET_PLATFORM MATCHES "aarch64")
5555
set(GMP_PREFIX ${GMP_ROOT}/package_aarch64)
5656
set(ARCH arm64)
5757

58-
elseif(TARGET_PLATFORM MATCHES "arm64_host")
59-
60-
set(GMP_PREFIX ${GMP_ROOT}/package)
61-
set(ARCH arm64)
62-
6358
elseif(TARGET_PLATFORM MATCHES "macos_x86_64")
6459

6560
set(CMAKE_OSX_ARCHITECTURES x86_64)
@@ -79,7 +74,7 @@ else()
7974

8075
endif()
8176

82-
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
77+
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" AND NOT TARGET_PLATFORM MATCHES "^android(_x86_64)?")
8378
set(GMP_DEFINIONS -D_LONG_LONG_LIMB)
8479
endif()
8580

‎src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif()
1616

1717
if(USE_ASM AND ARCH MATCHES "x86_64")
1818

19-
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
19+
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" AND NOT TARGET_PLATFORM MATCHES "^android(_x86_64)?")
2020
set(NASM_FLAGS -fmacho64 --prefix _)
2121
else()
2222
set(NASM_FLAGS -felf64 -DPIC)

0 commit comments

Comments
 (0)
Please sign in to comment.