fix: add -g0 to zig presets to eliminate 11GB debug info bloat (backport #21071)#21085
Merged
fix: add -g0 to zig presets to eliminate 11GB debug info bloat (backport #21071)#21085
Conversation
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
approved these changes
Mar 3, 2026
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
Backport of #21071 to v4.
Adds
-g0to 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-g0from interfering.Conflict resolution
The
clang20preset on v4 uses systemclang-20(not zig), so the-g0addition to that preset was dropped — it only applies to zig's debug info behavior. Thezig-basepreset change (which all cross-compilation presets inherit) and thelmdb.cmakechange applied cleanly.ClaudeBox log: http://ci.aztec-labs.com/df32ffacdebfa007-1