mopro
mopro copied to clipboard
rust-witness fails to compile for iOS targets if using both Circom and Noir
Description
When building a project that uses rust-witness v0.1.6 for iOS targets, the build fails during the w2c2 WASI compilation phase with an implicit function declaration error for getentropy in building C++ bindings, which is a part of Noir dependencies.
Environment
- rust-witness version: 0.1.6
- Selected proving system: Circom, Halo2, and Noir
- Rust toolchain: Stable 1.89.0
- Xcode: 16.0
Error Output
error: implicit declaration of function 'getentropy' [-Werror,-Wimplicit-function-declaration]
3970 | result = getentropy(
| ^
Full error context shows this occurs in w2c2/wasi/wasi.c during CMake build for iOS targets.
Root Cause
The issue appears to be in the w2c2 WASI implementation that rust-witness uses for transpiling WebAssembly to C. When cross-compiling for iOS:
- The
getentropyfunction is not properly declared/available for iOS targets - The CMake build uses macOS sysroot while targeting iOS, causing compatibility issues
- The w2c2 transpiler doesn't properly handle iOS cross-compilation requirements
Acceptance Criteria
mopro build should have no problems if using all of the supported proving systems. By either
- Detect iOS cross-compilation and use appropriate build flags/sysroot
- Consider providing pre-transpiled witnesses or alternative witness generation methods for mobile targets
Related Issues
- Should be considered and fixed with the refactor of #536