Improve build output to use shared dependencies and better output path#212
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a repo-level, shared-cache Docker BuildKit pipeline for building and packaging all RISC Zero guest programs, producing only deployable .bin artifacts in a single consistent output directory (target/guest/).
Changes:
- Adds
make build-programsto build all guest programs via a shared BuildKit build (scripts/build-guests.sh+scripts/build-guests.Dockerfile). - Introduces a new
risc0-packagertool to convert each built guest ELF into a deployable RISC Zero.bin. - Updates ignore rules and documentation to reflect the new shared-build output paths and reduced checkout footprint.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/risc0-packager/src/main.rs | Adds a CLI tool to package guest ELFs into RISC Zero .bin binaries. |
| tools/risc0-packager/Cargo.toml | Defines the new risc0-packager crate and dependencies. |
| scripts/build-guests.sh | New top-level build script driving a single BuildKit build and exporting target/guest/*.bin. |
| scripts/build-guests.Dockerfile | New Dockerfile building all guests with shared BuildKit caches and exporting only packaged .bin outputs. |
| Makefile | Adds build-programs target to standardize the guest build entrypoint. |
| CLAUDE.md | Documents the new build flow and output locations for guest binaries. |
| Cargo.toml | Adds tools/risc0-packager to the workspace members. |
| Cargo.lock | Locks dependencies for the new risc0-packager crate. |
| .gitignore | Simplifies ignores by removing per-guest target/ entries (root target/ already covers them). |
| .dockerignore | Excludes local build output and VCS metadata from Docker build context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e528ec0 to
103c6e5
Compare
103c6e5 to
1fd4fd8
Compare
Collaborator
Author
|
@vpavlin Requested your opinion, since @jimmy-claw submitted a PR to risk zero regarding BulidKit. |
0x-r4bbit
approved these changes
Jul 2, 2026
5e515af to
38008ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #211
make build-programsas the repo-level command for building every RISCZero guest program binary.
amm,ata,stablecoin,token, andtwap_oraclein one DockerBuildKit build with shared Cargo git, registry, and target cache mounts.
.binformat andexport only those final program binaries into
target/guest/.target/directories out of the checkout output; staleper-program guest targets are removed when
make build-programswrites theroot-level binaries.
.dockerignoreentries so local target directories and.gitare notsent into the Docker build context.
environment variables.
Build Output
make build-programswrites deployable program binaries to:The exported directory contains only the five deployable
.binfiles. It doesnot export raw guest ELFs,
deps,.fingerprint, incremental state, or otherper-program RISC Zero target-tree artifacts.
The shared BuildKit caches are keyed by
RISC0_BUILD_CACHE_IDand stored inDocker BuildKit cache storage. By default the cache ID prefix is:
The cache mounts are:
${RISC0_BUILD_CACHE_ID}-cargo-git${RISC0_BUILD_CACHE_ID}-cargo-registry${RISC0_BUILD_CACHE_ID}-targetBenchmarks
Clean full guest build across all programs:
217.78s70.94s146.84sfaster,67.43%less wall time,3.07xspeedupIgnored workspace build output:
953,390,236bytes (927M du -sh)1,687,512bytes (1.7M du -sh)951,702,724bytes (907.61 MiB)99.82%564.97xlarger than the shared-output buildMost of the old checkout footprint is duplicated dependency output:
docker/depstotal:952,769,542bytes (908.63 MiB)docker/depstotal: none exported to the checkoutkeyed by
RISC0_BUILD_CACHE_IDBuildKit-cache:
1.431GB:128.4MBcargo git cache,293.3MBcargo registry cache, and1.009GBshared target cache
1,687,512bytes (1.7M du -sh) into thecheckout
11.4GBcache plus759.3MBexportedoutput before a repeated Cargo/libgit2 fetch hang prevented completing the
final guest in an isolated builder
bound of
12.35GBrequired by main versus about1.432GBrequired by thisbranch for the fresh cache mounts plus exported output
10.92GBsmaller when countingBuildKit cache mounts plus exported output
Compatibility checks:
spel inspectaccepts the generatedtarget/guest/<program>.binoutputs forall programs.
target/guest/ata.binfrommake build-programsmatched thecargo risczero buildoutput byte-for-byte in a SHA-256 check.