Skip to content

Kaboom: do not build it on a GCC that cannot instantiate it - #10

Merged
jcelerier merged 1 commit into
mainfrom
fix/kaboom-gcc-oom
Aug 14, 2026
Merged

Kaboom: do not build it on a GCC that cannot instantiate it#10
jcelerier merged 1 commit into
mainfrom
fix/kaboom-gcc-oom

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Compiling Kaboom/Kaboom.hpp with GCC runs the compiler out of memory.

It is the front end, not codegen

-fsyntax-only performs no code generation at all, and still dies:

flags (g++-14, 10 GB cap unless noted) wall peak RSS result
-O3 (40 GB cap) 261 s 40.9 GB OOM-killed
-O1 (30 GB cap) 202 s 30.6 GB OOM-killed
-O0 67 s 10.2 GB killed
-O2 68 s 10.2 GB killed
-fno-inline-functions 67 s 10.2 GB killed
-finline-limit=100 / =40 66 s 10.2 GB killed
--param inline-unit-growth=5 --param large-function-growth=20 67 s 10.2 GB killed
-O2 --param ggc-min-expand=10 --param ggc-min-heapsize=32768 86 s 10.2 GB killed
-fsyntax-only 64 s 10.1 GB killed

Memory grows ~9.4 GB/min, linearly. Since every optimisation level and every inliner knob behaves identically, and -fsyntax-only reproduces it, this is template instantiation — nothing in the optimiser is involved and no flag can help.

Cause and the one configuration that works

GCC < 16 has no P1061 structured-binding packs, so avendish selects the boost.pfr aggregate backend, and instantiating pfr over Kaboom's ~336-field aggregate is what exhausts the front end. Getting off pfr fixes it:

compiler wall peak RSS result
g++-14 gnu++23 261 s 40.9 GB OOM-killed
g++-15 gnu++23 >16 GB OOM-killed
g++-16 gnu++23 419 s 16.0 GB OOM-killed
g++-16 gnu++26 151 s 7.1 GB compiles (obj 11.9 MB)

So the guard tests the version and the standard: g++-16 in C++23 mode still selects pfr and still dies, so the version alone would not be a safe test.

clang is unaffected — it has been on the structured backend since 21, and the wasm lane (clang 23) selects it already at gnu++23.

Guard truth table, verified by evaluating the expression in CMake:

GNU 13.0 cxx_std_23 -> skip      GNU 16.1 cxx_std_23 -> skip
GNU 14.2 cxx_std_23 -> skip      GNU 16.1 cxx_std_26 -> BUILD
GNU 15.3 cxx_std_26 -> skip      Clang 23.0 cxx_std_23 -> BUILD

Companion fix in avendish, where g++-15 currently selects a backend it cannot compile: celtera/avendish#190

Kaboom's port count is large enough that going through the boost.pfr aggregate
fallback exhausts the compiler. g++-14 peaks at 40.9 GB and is OOM-killed;
-fsyntax-only alone reaches 10 GB, so the cost is front-end instantiation and no
optimisation flag reduces it (-O0, -O1, -fno-inline-functions, -finline-limit
and the ggc params all behave identically).

GCC only leaves that fallback with P1061 packs, i.e. g++ >= 16 built as C++26,
where the same TU compiles in 151 s at 7.1 GB. Skip the object everywhere else
rather than letting the build die. clang is unaffected: it has taken the
structured path since 21.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ux7eanJYt46tkpQhitnk2r
@jcelerier
jcelerier merged commit 2f84abb into main Aug 14, 2026
1 of 10 checks passed
@jcelerier
jcelerier deleted the fix/kaboom-gcc-oom branch August 14, 2026 12:25
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