You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
emit-c self-compile OOMs (>32 GiB): single ~12.9 GB allocation during with --emit-c on the compiler #619
The --emit-c self-compile of the compiler exceeds the 32 GiB memory tripwire. During with build :test, right after EMIT-C SMOKE OK, the emit-c-test phase aborts with:
i.e. committed = 33.8 GB, a single 12.9 GB allocation request, against the 32 GiB (34359738368) default cap. with build :test still exits 0 because the harness tolerates this late-phase abort, but it exceeds the tripwire and is a real resource bug.
Repro
# the emit-c-test phase runs, effectively:
./out/release/bin/with build out/gen/main.w --emit-c -o /tmp/main.c
# (or: with build :emit-c-test)
out/gen/main.w is the combined compiler source; this emits the whole compiler through the C backend.
Analysis / where to look
The abort is a single 12.9 GB allocation (committed already 33.8 GB), i.e. one runaway Vec doubling (~6.4 GB → 12.9 GB) rather than diffuse accumulation. Look for an unbounded/duplicated buffer in the C backend (build/emit_c.w, the --emit-c codegen path), or a clone-style leak analogous to the comptime one below.
This is the --emit-c cross-compilation path only (spec §16, --emit-c C source backend). The normal LLVM backend path is unaffected — check src/main.w is now 2.51 GB after the fix in the sibling change (comptime prepare_comptime_eval_copy was deep-cloning the full ~8.5 MB source text on every comptime eval). A similar per-something deep-copy in the emit-c path is a plausible cause.
Notes
Pre-existing (documented previously as a cli-selfhost/high-RAM peak); not introduced by the comptime source-text fix (that only reduces memory).
Retested on a7efb23 while unblocking #668: the full-compiler --emit-c run no longer OOMs — emission completed under the default 32 GiB limit and produced the full 1.84M-line C artifact. The comptime memory-profiling fixes that landed since this was filed (source-text leak, 4.76→2.51 GB) appear to have resolved the single ~12.9 GB allocation this issue reported; I did not re-observe it.
The cross-compilation story's current barrier has moved: the emitted compiler C fails cc with (a) lazy map-init assignments through const-qualified receiver pointers (18+ sites before the error limit) and (b) a missing with_str_split_vec extern declaration. Fixing those is the next step toward the emitted compiler actually building.
Suggest either repurposing this issue to track 'emitted compiler C compiles and runs' or closing it as resolved-by-memory-work when the maintainer next triages — leaving that call open.
The cross-compilation loop is closed in 33b064e. Following up on my earlier retest comment: both remaining barrier classes are fixed, plus three more that surfaced behind them, and the pipeline's own gates now pass end-to-end with no environment overrides:
with build src/main.w --emit-c emits the full compiler (1.84M lines of C) — no OOM, under the default memory limit
The emitted C compiles clean with the stock host cc (61 errors → 0)
The resulting with-from-c reports its version, compiles and runs real With programs
:emit-c-fixpoint passes: with-from-c re-emits the compiler's C byte-identically
Fix inventory (details in the commit): lazy map-init removed from MAP_INSERT (wrote through const receivers; LLVM has no such crutch), C99 compound literals for constant operands at pointer params, MAP_KEYS lowering implemented (VALUES/ITEMS fail loudly instead of leaking bare calls), VEC_PUSH result materialization guarded to vec-typed destinations, four missing with_runtime.h declarations, and an emitc_c_compiler existence-probe fallback (the static-LLVM SDK ships archives, not the clang driver — the old default was a dangling symlink, exit 127).
One infrastructure note for triage: the SDK's clang/clang++ symlinks in .deps/llvm-22.1.6-darwin-arm64/bin dangle (clang-22 absent). The fallback makes the pipeline independent of that, but if the SDK is meant to ship the driver, that's a tools/build-static-llvm.sh packaging question.
With the original OOM gone and the loop green, I believe this issue can close — leaving that to you since the issue title describes the OOM and the scope evolved.
Triage 2026-08-31: CLOSE (overcome by events). Fixed by 33b064e "emit-C: close the compiler cross-compilation loop (#619)" — the self-compile completes under the default memory cap with no override; out/gen/.emit-c-test-stamp records the full compiler emitting and rebuilding byte-identically.
Activity
emit-C: set inserts, canonical map key types, tuple projections (#668)
ehartford commentedon Jul 17, 2026
Retested on a7efb23 while unblocking #668: the full-compiler
--emit-crun no longer OOMs — emission completed under the default 32 GiB limit and produced the full 1.84M-line C artifact. The comptime memory-profiling fixes that landed since this was filed (source-text leak, 4.76→2.51 GB) appear to have resolved the single ~12.9 GB allocation this issue reported; I did not re-observe it.The cross-compilation story's current barrier has moved: the emitted compiler C fails
ccwith (a) lazy map-init assignments throughconst-qualified receiver pointers (18+ sites before the error limit) and (b) a missingwith_str_split_vecextern declaration. Fixing those is the next step toward the emitted compiler actually building.Suggest either repurposing this issue to track 'emitted compiler C compiles and runs' or closing it as resolved-by-memory-work when the maintainer next triages — leaving that call open.
emit-C: close the compiler cross-compilation loop (#619)
ehartford commentedon Jul 17, 2026
The cross-compilation loop is closed in 33b064e. Following up on my earlier retest comment: both remaining barrier classes are fixed, plus three more that surfaced behind them, and the pipeline's own gates now pass end-to-end with no environment overrides:
with build src/main.w --emit-cemits the full compiler (1.84M lines of C) — no OOM, under the default memory limitcc(61 errors → 0)with-from-creports its version, compiles and runs real With programs:emit-c-fixpointpasses: with-from-c re-emits the compiler's C byte-identicallyFix inventory (details in the commit): lazy map-init removed from
MAP_INSERT(wrote through const receivers; LLVM has no such crutch), C99 compound literals for constant operands at pointer params,MAP_KEYSlowering implemented (VALUES/ITEMS fail loudly instead of leaking bare calls),VEC_PUSHresult materialization guarded to vec-typed destinations, four missingwith_runtime.hdeclarations, and anemitc_c_compilerexistence-probe fallback (the static-LLVM SDK ships archives, not the clang driver — the old default was a dangling symlink, exit 127).One infrastructure note for triage: the SDK's
clang/clang++symlinks in.deps/llvm-22.1.6-darwin-arm64/bindangle (clang-22absent). The fallback makes the pipeline independent of that, but if the SDK is meant to ship the driver, that's atools/build-static-llvm.shpackaging question.With the original OOM gone and the loop green, I believe this issue can close — leaving that to you since the issue title describes the OOM and the scope evolved.
ehartford commentedon Aug 31, 2026
Triage 2026-08-31: CLOSE (overcome by events). Fixed by 33b064e "emit-C: close the compiler cross-compilation loop (#619)" — the self-compile completes under the default memory cap with no override; out/gen/.emit-c-test-stamp records the full compiler emitting and rebuilding byte-identically.