Skip to content

build: gate Rust verifier build behind -Dverify (default off)#84

Merged
MatteoMer merged 1 commit into
mainfrom
feat/optional-verifier
Apr 16, 2026
Merged

build: gate Rust verifier build behind -Dverify (default off)#84
MatteoMer merged 1 commit into
mainfrom
feat/optional-verifier

Conversation

@MatteoMer
Copy link
Copy Markdown
Owner

Summary

Make the Rust jolt-verifier staticlib build opt-in via a new -Dverify build flag (default false). Most CI jobs and local zig build / zig build test runs no longer pay the ~2 minute cargo compile cost they don't need.

How it works

  • New build option: zig build -Dverify=true (default false)
  • When off: the cargo step is never created and linkJoltVerifier is never called. src/commands/verify.zig selects a stub impl via comptime-if, so the extern fn jolt_verify declaration literally does not exist — zero link dependency on libjolt_verifier.a, no requirement to have cargo or the Rust toolchain installed for the common case.
  • When on: identical behavior to before (full Jolt verifier linked, zolt verify works end-to-end).

Verified locally

default -Dverify=true
zig build no cargo run cargo runs
zig build test 539/539 pass, no cargo 539/539 pass + cargo
Binary size (zolt) 9.8 MB 39 MB
zolt verify stub: exits 1 with helpful message works end-to-end (~90 ms)

CI follow-up

To realize the speedup, the Prove + Verify (Linux/macOS) jobs need -Dverify=true added to their zig build invocation. Every other CI job works as-is and will skip the cargo compile automatically. Happy to do this in a follow-up PR — wanted to keep this one focused on the build mechanism.

Test plan

  • zig build (no flag) — succeeds, no cargo
  • zig build test (no flag) — 539/539 pass
  • ./zolt verify ... (no flag) — prints stub message, exits 1
  • zig build -Dverify=true — cargo runs, link succeeds
  • zig build test -Dverify=true — 539/539 pass
  • ./zolt verify ... (with flag) — VERIFIED in ~90 ms against a real proof

Add `-Dverify=<bool>` build option (default false). When disabled,
`zig build` and `zig build test` skip the cargo compile of
jolt-verifier entirely, and `src/commands/verify.zig` compiles to a
stub that prints a helpful message and exits with `VerifierNotEnabled`.

The `extern fn jolt_verify` declaration lives inside a comptime-`if`
struct so it literally doesn't exist when the flag is off — no link
dependency on libjolt_verifier.a, no requirement to have cargo or the
Rust toolchain installed for the common case.

Most CI jobs (Zig Tests, CLI Smoke, Release Build, …) build and test
without ever touching cargo. Only the prove+verify jobs need to opt in
via `zig build -Dverify=true`.

Verified locally:
  - default: 539/539 tests pass, no cargo run, binary 9.8 MB
  - -Dverify=true: 539/539 tests pass + verify command works
                   end-to-end against a real proof, binary 39 MB

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MatteoMer MatteoMer merged commit e6b834d into main Apr 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant