zkmopro / mopro

Making client-side proving on mobile simple.
https://zkmopro.org
Apache License 2.0
131 stars 35 forks source link

Speed up rust-witness compile #249

Open vivianjeng opened 3 weeks ago

vivianjeng commented 3 weeks ago

Problem

When compile a big circuit (e.g. Anon Aadhaar), it might take ~100 minutes to build for the one target And it will be 3 targets for iOS (device, simulator, x86 simulator) and 4 targets for Android (x86_64-linux-android, i686-linux-android, armv7-linux-androideabi, aarch64-linux-android) Even if we don't build them all, it still takes too much time.

Details

It stucks here: rust-witness/transpile.rs when running cargo build or cargo run (because it is executed in build.rs) And the detail in Activity Monitor looks like

/Users/zhengyawen/Documents/GitHub/rust-witness
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
/Users/zhengyawen/Documents/GitHub/rust-witness/target/debug/build/rust-witness-9375e472cca69fda/out/w2c2/w2c2/w2c2_base.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/math.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/sys/cdefs.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/sys/_symbol_aliasing.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/Availability.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/AvailabilityVersions.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/AvailabilityInternal.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/sys/signal.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/mach/arm/_structs.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/AvailabilityInternalLegacy.h
/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include/sys/resource.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/stdint.h
/Users/zhengyawen/Documents/GitHub/rust-witness/target/debug/build/rust-witness-9375e472cca69fda/out/aadhaar-verifier.h
/Users/zhengyawen/Documents/GitHub/rust-witness/target/debug/build/rust-witness-9375e472cca69fda/out/aadhaar-verifier.c
/dev/null
->0xde50f28a4723ebb3
->0x132914d70ac794d7
->0x1957ffc909d3eff0
->0xcbeb88af98745501
->0xd0b6390b8edfc0a4
->0x8f965ea51463082
->0x3ab58a1ce1dc9325
->0x44237f2a1e141f6f
/Users/zhengyawen/Documents/GitHub/rust-witness/target/debug/build/rust-witness-9375e472cca69fda/out/a1a8944e04277820-aadhaar-verifier-fd5cb67b.o.tmp

Acceptance criteria

Should find a way to speed up this compile or we can just use the binary instead of compiling them all the time.