Skip to content

fix(abi): model target va_list layout and passing semantics - #1108

Merged
ehartford merged 5 commits into
mainfrom
va-list
Sep 12, 2026
Merged

ehartford merged 5 commits into
mainfrom
va-list

Conversation

@ehartford

@ehartford ehartford commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

C va_list now retains its target-specific identity through migration, typedefs, explicit pointers, layout, and call lowering. SysV x86_64 uses the caller's place; other targets preserve value semantics through the shared ABI marshaller. Target-aware auditing checks the caller copy, and raw extern declarations retain their own signature when a curated wrapper takes the public name.

Regression coverage spans all five targets and executes mixed integer/floating-point variadic arguments beyond register capacity. Linux C callbacks and SysV With function-value parameters that lack the shared callable-type descriptor fail explicitly; the remaining foundation work is tracked in #1106.

Based on #1107's native/interpreted action paths, approved SDK expectations, scoped gunzip cleanup, compiler cleanup fixes, independent MIR validator tests, and bounded compiler partitions for small-memory hosts.

Local verification passed: full build, byte-identical fixpoint, full tests (997 behavior files and 16 internals tests; 415 MiB peak test-target RSS), test-green/last-green evidence for f501b64, fresh pinned v0.15.2.0 bootstrap, compiler audit (2,510,543 facts / zero violations), and 15 move / 115 drop cases with zero regressions.

All five native CI platforms passed on f501b64: macOS ARM64, Linux x86_64, Linux ARM64, Windows x86_64, and Windows ARM64. The macOS full battery passed at 415 MiB peak test-target RSS; its internals tests completed in 9.6 seconds.

The seed-compat cache defect found during verification is tracked in #1113; bootstrap evidence comes from a fresh run against the final tree. No seed update or installation.

Fixes #1104.
Fixes #1105.

@ehartford
ehartford force-pushed the va-list branch 6 times, most recently from cd08b87 to 647e152 Compare September 11, 2026 10:04
Eric Hartford added 5 commits September 11, 2026 03:13
va_list was modeled as the migration host's shape — a pointer on Darwin.
A variadic definition migrated on macOS (zlib's gzprintf, pcre2test's
cfprintf) got `var va: *mut i8`, so llvm.va_start wrote into an 8-byte
slot; on SysV x86_64 the __va_list_tag is 24 bytes and vsnprintf wants a
pointer to it, so the drift harness crashed with a corrupted stack (exit
139, #1103's linux lane). Only variadic definitions that read varargs are
affected; calls and externs already work.

c_va_list (TypeKind.TY_VA_LIST) is Copy, sized by TypeLayout per target —
8 bytes (pointer) on Darwin/Windows, 24 on SysV x86_64, 32 on AAPCS64
Linux — and lowered to a pointer or a byte buffer in codegen. On Linux a
c_va_list parameter uses the share-place ABI (a pointer to the caller's
list, C's array decay): Sema.sig_param_is_c_va_list_by_place sets
value_ref_abi, the extern prologue declares the param as ptr, and the
call site passes the address. Verified from the IR: vsnprintf takes ptr,
the call passes the 24-byte alloca's address on linux_x86_64 and the
loaded char* by value on darwin.

The migrator emits c_va_list for C's va_list: translate_type_recursive
(ClangBridge) checks the pre-canonical spelling so a macOS `char *`
va_list is caught before it decays, the structural path returns
c_va_list, and std.libc's vsnprintf/vfprintf/vprintf take c_va_list. A
corpus migrated on one host now runs its variadic definitions on the
others. Corpora re-promoted in this batch; docs/with-abi.sha256 re-recorded
because TypeLayout.w changed.
…n, zlib half)

Re-migrated gzwrite.c with the va_list-aware migrator: __local_va and
gzvprintf's __param_va are c_va_list, not *mut i8 — the only delta from
the committed file (defs.w's SDK-macro drift discarded, that is #1102).
The pcre2 half (pcre2test.w's cfprintf) is blocked on #1102: re-migrating
pcre2 now emits the host SDK's macros into defs.w and they collide
(shadowing errors), so #1102 must land before pcre2 can be re-promoted.
WIP: the branch does not build until pcre2test.w is re-promoted and
docs/with-abi.sha256 re-recorded.
LLDB proves declare_extern_fn+372 selected curated memchr signature 244 (2 parameters) for the raw 3-parameter declaration and panicked at parameter 2. Record signatures by declaration node. memchr/memcmp execution, memchr audit:all (11617 facts, zero violations), and both va_list regressions pass.
Run 34426003885 reported the va_list regression without its per-test stderr or any downloadable artifacts. Preserve the same test graph and p7 captures as Windows, plus the runner compiler for debugging.
@ehartford
ehartford marked this pull request as ready for review September 11, 2026 12:34
@ehartford
ehartford changed the base branch from macro-token-paste to main September 12, 2026 07:46
@ehartford
ehartford merged commit 00a2fc9 into main Sep 12, 2026
5 checks passed
@ehartford
ehartford deleted the va-list branch September 24, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant