Repository navigation
Make builds deterministic across output bases and tighten hermeticity - #17
Conversation
Two clean builds of this commit in different checkouts and output bases now produce identical action keys and identical outputs for every spawn of `//...` and of the CI `-c opt` APK and WASM build, and the APKs and WASM are bit-for-bit identical. Before this, rav1e and av-scenechange were never cache hits on a fresh output base: their build scripts echo CARGO_ENCODED_RUSTFLAGS back as `cargo:rustc-env`, and that value carries `--remap-path-prefix=<exec_root>=.`. The rules_rust build-script runner shipped by rules_rs only redacts the exec root when a `/` or `\` follows it, so the per-action sandbox path leaked into `_bs.env`. A local patch also redacts it before `=`. The response-file bootstrap patch is dropped: the pinned rules_rs already includes the upstream fix (hermeticbuild/rules_rust#53), and without the patch process_wrapper is byte-identical across output bases and embeds no absolute paths. .bazelrc: - Disable sandbox networking. Every toolchain is downloaded and checksummed; the full `//...` and `-c opt` APK/WASM builds pass offline. - Never autodetect a host C/C++ toolchain; @llvm is the only one. - Sandbox persistent workers (Javac, Kotlin, Android tools), which otherwise run in the unsandboxed execroot. - Share a disk cache across checkouts and worktrees, garbage collected at 60G. Action keys are path-independent, so a fresh worktree reuses every other worktree's outputs. CI keeps using its output base and BuildBuddy. - CI: fail on a stale MODULE.bazel.lock and download only what each step inspects. Pipelined Rust compilation was measured and left off: on clean 24-core builds it was slower for both `//...` (110s vs 97s) and the `-c opt` APK/WASM build (184s vs 168s), since the builds are CPU-bound rather than critical-path-bound.
The default Linux workflow VM (3 CPU, 8GB RAM, 20GB disk) ran out of disk in the -c opt APK step: the Android SDK/NDK, LLVM, Flutter and JDK repositories plus the fastbuild and opt output trees on a recycled runner exceed 20GB. More CPUs also shorten every remote-cache miss. Drop --remote_download_toplevel from the buildbuddy config: it is Bazel's default, and with --config=ci adding --remote_download_minimal it only produced a conflicting-expansion warning.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Since main's #14, CI builds and tests only in -c opt, so there is no separate fastbuild output tree.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
CARGO_ENCODED_RUSTFLAGSback, and the build-script runner in the rules_rust that rules_rs ships leaves--remap-path-prefix=<exec_root>=.unredacted. Each run's sandbox path ends up in_bs.env, so neither crate was ever a cache hit on a fresh output base. A local patch (bazel/rules_rs_build_script_env_determinism.patch) fixes it until fix: redact exec root before=in build script env output hermeticbuild/rules_rust#84 ships in a rules_rs release.rules_rs_bootstrap_determinism.patch. The pinned rules_rs already includes the upstream fix (fix: remap bootstrap source paths in rustc hermeticbuild/rules_rust#53). Without our patch,process_wrapperis byte-identical across output bases and embeds no absolute paths..bazelrchermeticity:.bazelrcspeed:~/.cache/bazel-disk-cache, shared by every checkout and worktree and capped at 60G.MODULE.bazel.lock.Verification
--execution_log_json_file. Every spawn of//...and of the CI-c optAPK and WASM build has identical action keys and outputs. The APKs and.wasmare bit-for-bit identical.//...build and the-c optAPK/WASM build pass with sandbox networking disabled.//...in 10s, all disk-cache hits, against 97s from clean. The-c optAPK/WASM build takes 41s, against 168–379s.//...and 184s vs 168s for opt.