Skip to content

fix: add -g0 to zig presets to eliminate 11GB debug info bloat#21071

Merged
ludamad merged 2 commits intomerge-train/barretenbergfrom
claudebox/1a779e17d1e4caac-2
Mar 3, 2026
Merged

fix: add -g0 to zig presets to eliminate 11GB debug info bloat#21071
ludamad merged 2 commits intomerge-train/barretenbergfrom
claudebox/1a779e17d1e4caac-2

Conversation

@AztecBot
Copy link
Collaborator

@AztecBot AztecBot commented Mar 3, 2026

Summary

Zig cc injects DWARF debug info into every object file by default, even in Release (-O3) mode. This inflates the barretenberg build directory from 2.8 GB to 14.0 GB (5x blowup). Adding -g0 to suppress this brings zig builds in line with system clang builds.

Key numbers (measured on 186-core machine with full AVM build):

Artifact Before (-g0) After (-g0) Reduction
Total build dir 14.0 GB 2.8 GB 80%
libvm2.a 1,406 MB 219 MB 84%
bb-avm 1,271 MB 182 MB 86%
prover.cpp.o 486 MB 31 MB 94%

What this changes

  • Adds "CFLAGS": "-g0", "CXXFLAGS": "-g0" to the clang20 preset (native zig builds)
  • Adds the same to the zig-base preset (all cross-compilation presets inherit from this)
  • Presets that intentionally use -g (tracy, debug, xray) override these flags as expected

What it does NOT change

  • Machine code output is identical (verified: .text sections are byte-for-byte the same)
  • Incremental builds are fully preserved
  • Build time improves marginally (5m29s → 5m06s)

Full analysis: https://gist.github.com/AztecBot/5c919316852d4d66095d0eefaa1a7c00

ClaudeBox log: http://ci.aztec-labs.com/1a779e17d1e4caac-2

@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 3, 2026
@ludamad ludamad marked this pull request as ready for review March 3, 2026 19:23
@ludamad ludamad changed the base branch from next to merge-train/barretenberg March 3, 2026 19:53
@ludamad ludamad added ci-draft Run CI on draft PRs. and removed ci-draft Run CI on draft PRs. labels Mar 3, 2026
@ludamad ludamad enabled auto-merge (squash) March 3, 2026 19:53
@AztecBot AztecBot force-pushed the claudebox/1a779e17d1e4caac-2 branch from f4b260c to 8ba75e9 Compare March 3, 2026 21:07
The -g0 flags set in CMakePresets.json leak to LMDB's make -e build,
replacing its CFLAGS entirely (losing -O2, -pthread, -fPIC, etc).
This causes zig cc to insert UBSan instrumentation at -O0, leading
to undefined __ubsan_handle_* symbols at link time.

Fix by unsetting CFLAGS/CXXFLAGS in the cmake -E env wrapper so
LMDB uses its own Makefile-defined CFLAGS.
@ludamad ludamad merged commit fb40bb1 into merge-train/barretenberg Mar 3, 2026
10 checks passed
@ludamad ludamad deleted the claudebox/1a779e17d1e4caac-2 branch March 3, 2026 22:13
@AztecBot
Copy link
Collaborator Author

AztecBot commented Mar 3, 2026

❌ Failed to cherry-pick to v4 due to conflicts. Dispatching ClaudeBox to resolve. View backport run.

AztecBot added a commit that referenced this pull request Mar 3, 2026
Zig cc injects DWARF debug info into every object file by default, even
in Release (-O3) mode. This inflates the barretenberg build directory
from **2.8 GB to 14.0 GB** (5x blowup). Adding `-g0` to suppress this
brings zig builds in line with system clang builds.

| Artifact | Before (-g0) | After (-g0) | Reduction |
|----------|-------------|-------------|-----------|
| Total build dir | 14.0 GB | 2.8 GB | **80%** |
| libvm2.a | 1,406 MB | 219 MB | 84% |
| bb-avm | 1,271 MB | 182 MB | 86% |
| prover.cpp.o | 486 MB | 31 MB | 94% |

- Adds `"CFLAGS": "-g0", "CXXFLAGS": "-g0"` to the `clang20` preset
(native zig builds)
- Adds the same to the `zig-base` preset (all cross-compilation presets
inherit from this)
- Presets that intentionally use `-g` (tracy, debug, xray) override
these flags as expected

- Machine code output is identical (verified: .text sections are
byte-for-byte the same)
- Incremental builds are fully preserved
- Build time improves marginally (5m29s → 5m06s)

Full analysis:
https://gist.github.com/AztecBot/5c919316852d4d66095d0eefaa1a7c00

ClaudeBox log: http://ci.aztec-labs.com/1a779e17d1e4caac-2
ludamad pushed a commit that referenced this pull request Mar 3, 2026
…ort #21071) (#21085)

## Summary

Backport of #21071
to v4.

Adds `-g0` to zig cross-compilation presets to suppress DWARF debug info
that inflates the build directory from 2.8 GB to 14.0 GB. Also unsets
CFLAGS/CXXFLAGS for the lmdb external build to prevent `-g0` from
interfering.

### Conflict resolution

The `clang20` preset on v4 uses system `clang-20` (not zig), so the
`-g0` addition to that preset was dropped — it only applies to zig's
debug info behavior. The `zig-base` preset change (which all
cross-compilation presets inherit) and the `lmdb.cmake` change applied
cleanly.

ClaudeBox log: http://ci.aztec-labs.com/df32ffacdebfa007-1
johnathan79717 pushed a commit that referenced this pull request Mar 4, 2026
## Summary

Zig cc injects DWARF debug info into every object file by default, even
in Release (-O3) mode. This inflates the barretenberg build directory
from **2.8 GB to 14.0 GB** (5x blowup). Adding `-g0` to suppress this
brings zig builds in line with system clang builds.

### Key numbers (measured on 186-core machine with full AVM build):

| Artifact | Before (-g0) | After (-g0) | Reduction |
|----------|-------------|-------------|-----------|
| Total build dir | 14.0 GB | 2.8 GB | **80%** |
| libvm2.a | 1,406 MB | 219 MB | 84% |
| bb-avm | 1,271 MB | 182 MB | 86% |
| prover.cpp.o | 486 MB | 31 MB | 94% |

### What this changes

- Adds `"CFLAGS": "-g0", "CXXFLAGS": "-g0"` to the `clang20` preset
(native zig builds)
- Adds the same to the `zig-base` preset (all cross-compilation presets
inherit from this)
- Presets that intentionally use `-g` (tracy, debug, xray) override
these flags as expected

### What it does NOT change

- Machine code output is identical (verified: .text sections are
byte-for-byte the same)
- Incremental builds are fully preserved
- Build time improves marginally (5m29s → 5m06s)

Full analysis:
https://gist.github.com/AztecBot/5c919316852d4d66095d0eefaa1a7c00

ClaudeBox log: http://ci.aztec-labs.com/1a779e17d1e4caac-2
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2026
BEGIN_COMMIT_OVERRIDE
fix: add -g0 to zig presets to eliminate 11GB debug info bloat (#21071)
fix: resolve flaky p2p_client test race condition on ARM64 (#21088)
chore: remove domain iteration macros and address backing memory race
(#20988)
fix: [ECCVM] added domain separation for the multiset equality check.
(#20352)
feat: hybrid CRS hash verification — 8MB chunks, parallel, span-based
(#21113)
chore: unify splitting scalars interface (#20805)
chore: add a unique id to each origin tag (#20924)
chore: Native curve audit (#20936)
chore: Update bootstrap in test vk haven't changed script (#21153)
END_COMMIT_OVERRIDE
github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2026
BEGIN_COMMIT_OVERRIDE
fix: add -g0 to zig presets to eliminate 11GB debug info bloat (#21071)
fix: resolve flaky p2p_client test race condition on ARM64 (#21088)
chore: remove domain iteration macros and address backing memory race
(#20988)
fix: [ECCVM] added domain separation for the multiset equality check.
(#20352)
feat: hybrid CRS hash verification — 8MB chunks, parallel, span-based
(#21113)
chore: unify splitting scalars interface (#20805)
chore: add a unique id to each origin tag (#20924)
chore: Native curve audit (#20936)
chore: Update bootstrap in test vk haven't changed script (#21153)
fix: use reduced form in WASM FromMontgomeryForm test (#21164)
chore: erase ephemeral secrets from memory in schnorr and aes (#21106)
chore: suppress clangd target triple version diagnostic (#21180)
feat: Optimise new claim calculation (#21179)
docs: add Quick Start build instructions to barretenberg README (#20951)
feat: batched chonk verification (#21083)
fix: link libc++ instead of libstdc++ for Rust FFI on Linux (#21203)
fix: [ECCVM] in the transcript table, no-ops force the next accumulator
to be 0. (#20849)
fix: resolve merge-train conflict with next (zig wrapper scripts + -g0)
(#21201)
fix: [ECCVM] rare edge case completeness issue when `z1 == 0` but `z2 !=
0` (#20858)
fix: use actual data extent for CommitmentKey in HypernovaDeciderProver
(#21206)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4 claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants