Skip to content

C algorithms phase1 - #1142

Merged
ehartford merged 70 commits into
mainfrom
c-algorithms-phase1
Sep 14, 2026
Merged

ehartford merged 70 commits into
mainfrom
c-algorithms-phase1

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

No description provided.

Eric Hartford added 30 commits September 12, 2026 04:42
Compute immutable FnAbi/ArgAbi records once and share them across named
declarations, callable types, adapters, prologues, and call marshalling.
Remove parallel ABI tables and 64-bit parameter masks. Preserve owned
destructor storage across body/field cleanup without reclassifying it as
a borrow. Extend declaration/call audits to check descriptor shapes and
actual byval attributes.

LLDB evidence: raw_fn_type selected internal_abi_needs_sret=false for a
large indirect C return; declare_function_at_inner's owner-type shortcut
registered consuming parameters as references. The 65th C aggregate's
attribute was skipped at apply_c_abi_byval_attrs+120: x25=64, x8=0,
x22=0xffffffffffffffff after the out-of-range shift check.

Restore the function-level temporary frame in default trait methods.
The native allocator traced one leaked 16-byte clone through Person.name;
register_stmt_temp+36 had x0=0, local=2, type=16 and skipped registration
from generate_default_trait_method_for_impl. Track the audit's missing
synthesized-body ownership coverage in #1117.

Validation: source check and -O1 stage1 build; five-target callable and
c_va_list IR/audit matrices; 65-parameter aggregate audit; native callback
and consuming-receiver results; default-tail and consumed-field allocator
fixtures report leak count=0. Full bootstrap battery follows this commit.

Refs #1106
Register async declarations from finalized signatures, preserving inferred Unit, scalar and aggregate returns. Remove the obsolete 64-parameter default-method guard now that FnAbi uses vectors.

Proof: compiler audit identified task_cancel_point missing FnAbi; LLDB declare_async_function showed direct LLVM type construction with an i32 default and no descriptor registration. Wide method LLDB observed w8=66 at generate_default_trait_method_for_impl +1052, taking the >64 early return; IR called undef. Native regressions now return async ok and wide default ok; five-target async audits report zero violations. Audit target-coverage gap filed as #1119.
The centralized descriptor path exposed missing TY_TRAIT_OBJ branches in both semantic and MIR LLVM type mapping. Share the existing dyn layout and cover direct and callable trait-object arguments.

LLDB proof: sema_type_to_llvm and mir_sema_type_to_llvm received kind 17 and returned x0=0 into type_fallback (sealed-kind-proof.txt and dyn-mir-kind-proof.txt under out/fnabi-validation). The MIR fallback produced an i32 parameter for an actual struct{ptr,ptr} argument. Both routes now return the shared dyn type.

Validation: source check, stage1 rebuild, sealed_trait_match native test, dyn callback native run, and callable audit:all on all five targets pass.
Resolve unregistered LLVM aggregate fields through their MIR source owner,
including projected places and reordered literals. Diagnose a failed projected
assignment instead of silently emitting an unreachable body.

LLDB proof: mir_resolve_field_index returned -1 for generation with two LLVM
elements; mir_place_ptr returned zero and mir_emit_stmt took its silent false
return at the projected assignment (handle-field-proof.txt). The Handle mapper
constructs an anonymous LLVM struct with no field-name registry. SlotMap.ptr
reads also lost the field identity. Audit accepted the assignment-last repro
with zero violations; #1120 records that tool gap alongside the codegen bug.

Validation: compiler source check, -O1 stage1, native field matrix (local,
return, reordered literal, nested receiver, tuple, array, Vec), audit:all,
SlotMap generation-exhaustion test, and debug allocator pass.

Refs #1120
Inventory current engines and future algorithm families; add an optimized
N/4N complexity lane to :test with correctness checks and explicit #937/#938
expected failures. Add opt-in allocation request tracing and empty/positive
controls to measure #939's temporary buffers independently of leak reporting.

Replace SlotMap's occupancy scan with a FIFO free list and permanently retire
exhausted generations. Record the runtime header change as ABI v4. Extend
native, spec, allocator, and drop-audit coverage for reuse, growth and cleanup.

Exact baseline evidence: LLDB with_slotmap_insert_out+120 observed occupied
index zero taking the scan branch (slotmap-scan-proof.txt); with_slotmap_remove
+156 observed w20=0xffffffff entering checked-add overflow at rt_core.w:2961
(slotmap-generation-add-proof.txt). The runtime allocator route used the test
runner's retained binary with WITH_ALLOC_NO_REUSE=1 and --debug-alloc.

Validation so far: runtime source checks and -O1 objects on all five targets;
compiler/build/tool source checks; stage1; all SlotMap spec/FIFO tests; exactly
130 Drop calls with zero leaks; optimized complexity cases pass with the known
cliffs recorded, and trace controls observe 0/1/6 allocations. Full bootstrap,
fixpoint and suite verification follows this commit.

Refs #936, #1118
Fixes #1122. Allocator traps and LLDB identify the premature temporary drop, literal insertion bypass, and comparison copy in docs/phase0-ownership-debug.md. The expanded native fixture has exact destructor counts and zero leaks with and without allocator reuse. Source checks, the development build, and focused audit pass; broader audit coverage is tracked in #1123.
Fixes #1121. LLDB observed Sema.check_binary+5452 classify TY_GENERIC_INST as 14, then skip the known-nonstr rejection at +5456. Native concat interpreted a Result header as str. Both Result operand positions and a generic record now fail with the intended diagnostic; development build and focused tests pass.
LLDB observed cli_has_flag begin at argv[2], skipping --trace-alloc before -e. Scan from argv[1], keep the allocation fixture idiomatic, and report process exit codes and capture paths from the complexity lane. Correct stale bundle and sourcing status banners.
Fixes #1125. LLDB observed build_cache_current_compiler_fingerprint+200 reset its cached global from a 64-byte fingerprint to zero while the ready flag stayed set. Return an explicit clone and cache unresolved identity too. The native regression verifies repeated graph keys against the executable fingerprint; compiler source checks pass. Proof is recorded in docs/build-compiler-fingerprint-debug.md.
LLVM rejected an i32 undef versus str comparison on a Box payload. LLDB observed lower_field_base_place+204 returning the Box place through lower_observer_probe_arg; lower_expr_place now uses lower_field_access, including its recorded autoderef and payload handling.
Closes #1124. LLDB observed underscore tags branch to c_void and NullStmt return zero into lower_for_stmt_ir+428; the parser rejected generated use probe.a-b. See docs/c-algorithms-migration-debug.md for the exact evidence and regression scope.
LLDB observed Codegen.resolve_type+952 discard NK_INDEX type application node 7425 after frozen Sema returned zero. Both application syntax forms now share the substitution-aware resolver; add nested-record and multi-parameter layout coverage.
Native LLDB stops prove the missing __builtin_expect structural branch, filtered __assert_rtn binding, and StringLiteral cursor 897 returning invalid IR despite a valid Clang spelling. Preserve these paths without weakening upstream assertions. Compiler source check and dev build pass for the effect/builtin paths; final literal recovery and native fixture verification remain pending.
LLDB proved Codegen.gen_closure lowered node 889 using the last generic specialization type, sending the i32 comparator to with_str_cmp_ref. Prepare anonymous bodies in the concrete lowering context, validate their retained contracts, and read them in codegen. Mixed-width/string comparator and ordinary closure/async captures pass on the dev compiler. LLVM also proved an async result-buffer state leak into nested closure returns; save and restore it across anonymous functions. Full self-host verification follows.
LLDB proves generic declaration validation reads private Entry from the importing context (#1130), and the C initializer scanner classifies variable2 as initialized from variable1’s equals sign. Use declaring-module context and Clang’s per-variable initializer cursor. Source checking passes; regression and upstream pipeline verification follow.
Native LLDB proof: monomorphize_struct_nodes recurses at +2184 while resolving an enclosing record; get_llvm_field_index receives source index 1 and returns slot 0. The Trie constructor IR overwrites its engine pointer with the empty entries pointer. Reserve all parallel field columns before resolving nested fields in generic, ordinary, union, and generator records.

Source checking passes. Regression covers returned nested generic records, reordered initialization, and owned strings. Native verification follows in the batch; layout audit gap tracked in #1131.
LLDB at resolve_generic_type +404 observed lookup_named_type_visible returning zero from check_let_binding. The declaration-table contains branch at +884 then returned a concrete type (138), bypassing privacy. Check the private symbol path before the declaration-presence fallback. Preserve the negative annotation regression and repair its public marker signature; create the migration fixture output directory. Compiler source check passes; multi-declarator native regression passes.
The pinned upstream hash-table test stopped at atoi(val): ci_libc_symbol_kind_mask omitted atoi despite the text call mapper recognizing it. Add the concrete foreign ABI binding and structural allowlist entry, with direct-call and function-pointer coverage. Compiler source check passes; native migration verification follows.
The upstream test_alloc_testing output contained integer 0 in a function-pointer array and a vacuous unsafe strcmp call. The atoi regression also emitted a local unsafe callback with an unconverted str argument. Coerce array elements against their element types, classify direct function references by canonical Clang type, and use the callable signature for all argument conversions. Stage nested callable parameters before appending their shared extra range.

Apply the existing Sema std-module extern policy to every std shared-defs corpus, replacing the pcre2-only migrator condition. Source check passes; regressions include callback arrays, typedefs, local and field callbacks, and nested callback parameters. Native verification follows.
Native allocator trap and LLDB observed str.cmp freeing a live SortedVec element through rt_core.w:2730. MIR copied the shared pointee into an owning local and scheduled drop#10; retain the Sema projection and bind its place instead. Reject owned mutable bindings and clone the two compiler fields that require independent mutable storage.

Stage 1: reduced repro, repeated string comparisons, SortedVec, BinaryHeap and eight custom destructor checks pass with debug allocation and zero leaks. Consuming and mutable borrowed bindings reject. Validator gap tracked in #1132.
Native LLDB stopped at the callbacks data symbol: the array slot address was used as the branch target instead of its stored atoi pointer. Normalize callable reference projections in shared MIR call lowering; FnAbi remains the argument/result authority. Add raw C callback, reference parameter and With closure collection coverage. Validator gap: #1133.
LLDB observed ci_c_initializer_is_null_pointer_cast return true for (void *)0, then the source initializer path only recognized pointer/Option destinations and emitted integer zero for a function pointer. Route macro nulls through the common target coercion. Only wrap indirect calls whose rendered callable contract is unsafe. Compile the raw upstream corpus without the application prelude, matching migration and bundle options.
Eric Hartford and others added 21 commits September 13, 2026 18:31
…s is FIXED, not a regression

The three empty facade cells phase-bugged under the seed (the generic
Drop-only type, fixed in 27ed60c) and pass under the candidate; the
classifier read any difference as a regression. A candidate PASS against a
non-PASS baseline is printed as FIXED and never red.
…backs ==, !=; fixed-name methods override

Eric's ruling (decisions.md D41). Sema selects the family's primitive when
neither operand type defines the fixed-name method and records the
derivation (operator_method_derived); MirLower lowers cmp(...) <op> 0 and
not eq(...), flipping the ordering's sign when the primitive lives on the
right operand's type. The operator sidecars are cleared per recheck: a
generic body rechecked per instantiation kept the first T's method (the
str/i32 specializations of a T: Ord body called Tag.cmp). Eq.eq and
Ord.cmp take other: &Self and every impl in the tree conforms; the
facades' element types need only Ord; #1137's diagnostic names the
primitive. Fixture behav_ord_cmp_operators covers owned and view
operands, the derived four, an override, and a reversed selection.
# Conflicts:
#	docs/stdlib_sourcing_plan.md
… seed miscompiles the literal

Same #1122 seed miscompile as the base branch's fix: build-layer code runs
on the pinned seed, so a collection literal with moved element temporaries
(the compiler path, the program path) is a freed string there.
…les the literal

The action runner is compiled by the pinned seed (v0.15.2.0), which has
#1122: a collection literal with moved element temporaries frees them
before the collection is used. argv[0] (the compiler path) was a freed
string: exit 127 on POSIX (reproduced locally with the pinned seed as the
driver), the interior-NUL panic on the CI Linux/macOS lanes, and
CreateProcessW's FILE_NOT_FOUND (-2) on Windows aarch64. 9ccd1e2 fixed
the compiler in this tree, but build-layer code runs on the seed
(D14; the seed-gated build-layer rule), so the literal cannot be used
there until the seed carries the fix.
# Conflicts:
#	docs/handoff.md
#	docs/stdlib_sourcing_plan.md
… timed probes on failure

The Windows x86_64 lane's stage2 has timed out at 1801 s on every run of
this branch (main: ~380 s) with no capture uploaded. The build now runs
under WITH_PROFILE so a hung stage leaves its last completed phase in
out/command/<stage>/stderr.txt; on failure the lane prints those captures,
runs stage1 check on the compiler source (Sema/MIR alone) and a
single-codegen-unit build (no emit threads), and uploads out/command.
… operands; fixed-name methods override (D41, blessed by Eric 2026-09-14)
…ore taking its address

The FnAbi call path evaluated every IndirectPlace operand (a whole-aggregate
load) and then discarded the value for the place address. SROA scalarizes
that dead load into one load per leaf: 1660 for Compilation, before every
in-place receiver call; run_cli carried 26 such chains. marshal_ref_operand
applies the same address policy without materializing a place operand.
A struct move was 'store (load %T)'; SROA rewrites that first-class
aggregate into a load and a store per leaf, so a function moving a few
large records carried tens of thousands of scalar stores in one block and
SelectionDAG's store merging went quadratic on them: one unit of the
windows_x86_64 stage2 build took 635 s (checkMergeStoreCandidatesForDependencies,
the #1129 CI timeout), and every other unit 5-70 s. wl_lower_aggregate_copies
runs before the per-function cleanup: a store of a loaded aggregate of 64
bytes or more becomes llvm.memmove, a store of a zero aggregate llvm.memset,
and a load left without uses is erased. Every windows_x86_64 unit now emits
in under 3 s.

The hand-declared memcpy/memset intrinsics reuse an existing declaration
(LLVM declares them itself once a pass forms one; a second declaration under
the same name gets a .N suffix the verifier rejects).
…lace address

d7c75f2's no-eval marshal sent every non-transparent place operand to
mir_try_place_ptr_for_ref, which returns the place ADDRESS for a projected
place with no load. For an operand whose type is itself &T/*mut T (a
JsonView.source field passed to json_str(js: &str), print(v.source)) the
value IS the pointer the ref param wants; the callee received &&str and
read through it as the str (behav_derive_deserialize and the jq-scalar
one-liner exited 134 in the #1129 battery; IR showed json_str called with
the field GEP where main emits a load). Evaluate reference/raw-pointer
operands — one scalar load, never the aggregate copy the no-eval path
exists to avoid — and let marshal_ref_addr pass the pointer through.
__assert_rtn (Darwin) and __assert_fail (glibc) were bare externs, so a
corpus migrated on macOS could not link on Linux or Windows (#1138:
c_algorithms-wo-drift and c-algorithms-test, 'undefined symbol:
__assert_rtn'). Both are With functions now: the same report to stderr,
then abort, on every target.
72e1067 stopped rendering every underscore-tagged record as c_void, so
glibc's __locale_struct now names __locale_data — a record declared only
inside a member's type, never at file scope. It had no cursor in the
top-level walk and no 'type __locale_data = opaque' was emitted
(spec_ss16_ffi_and_c_import under use c_import("time.h") on Linux,
#1138). After the declaration walk the session walks every collected
declaration's types and appends each undefined record it names, so it
renders opaque next to its users. Fixture: behav_migrate_member_only_record.
…lls the migrated name

read_file returns a Result, and the migrated function keeps its C name;
the __with_cabi_ prefix is only for runtime-borrow bridges.
UCRT's assert.h expands to _wassert with wide string literals, which the
migrator does not lower; corpora migrated elsewhere run on Windows since
the reporters are modeled portably.
…ship in the migrator, HashIndex facade (#1141)

* migrate: bit builtins lower to integer methods; a pointer to a function typedef is a function pointer

__builtin_clz/ctz/popcount (and the l/ll forms) lower structurally to
(x as u32).clz() / u64 for the wide forms; __builtin_bswapN to
.swap_bytes() on the N-bit unsigned (TommyDS tommy_ilog2/tommy_ctz).
A CIE_FIELD with d2=2 is a method selected on a value and prints as
base.method. A pointer whose pointee is a typedef of a function
prototype (tommy_compare_func*) canonicalizes to the function pointer
instead of *mut fn. Fixtures: behav_migrate_bit_builtins,
behav_migrate_fn_typedef_pointer.

* rt: with_libc_mach_absolute_time, the monotonic clock in nanoseconds

The runtime seam behind std.libc's portable mach_absolute_time (next
commit): the same value on every target.

* std.libc: qsort, rand, srand; Darwin's mach clock modeled portably

The migrator's libc allowlist admits qsort/rand/srand and
mach_absolute_time/mach_timebase_info(_data_t)/kern_return_t (previous
migrate commit). mach_absolute_time is the runtime's monotonic clock in
nanoseconds and mach_timebase_info reports 1/1, so TommyDS's check.c
timing code migrated on macOS computes nanoseconds on every target.
Fixtures: behav_migrate_libc_qsort_clock (portable),
behav_migrate_libc_mach_clock (darwin-only migration).

* build: the TommyDS corpus as the fourth .wo bundle (Phase 2)

build/tommyds.w pins amadvance/tommyds 1f3727fc, migrates the 13 units
(tommy.c, the amalgamation, excluded) plus check.c as the harness
(module check_: check collides with the prelude), promotes to
lib/std/tommyds/, and runs tommycheck as the corpora lane tommyds-test.
tommy_wo is wired at every site calg_wo is; the corpus leaves the
embedded stdlib in build.w and build/runtime.w; std.tommyds is an
internal module. The corpus is the migration's output, never
hand-edited.

* migrate: a header's static inline definitions are published by the unit of the same name

A `static inline` function defined in a header is that header's API
(TommyDS keeps tommy_hashdyn_search, tommy_hashlin_search and the
tommy_inthash family in its headers); every includer compiled a private
copy, so nothing outside the corpus could call them. The project scan now
registers such a definition as owned by the unit whose stem matches the
header's (tommyhashdyn.c for tommyhashdyn.h); that unit publishes it and
every other unit imports it. A header no unit owns keeps a private copy per
includer as before. Fixture: behav_migrate_header_inline_owner.

* migrate: only a header's inline definitions are published; calls to an imported inline get their unsafe context

The ownership rule from ff4c58b also published a unit's own static
inline helpers (tommyhashdyn.c's hashdyn_grow_step) because their
location stem matched the unit; a definition is a header's API only
when it sits in a header. And a consumer unit's calls to an imported
header inline with raw parameters were emitted without an unsafe
context, because the unsafe-callee scan skipped every static function;
a header-owned one is treated like any imported raw function. The
fixture covers both: user_probe runs through the published engine_peek,
engine_scale stays private.

* tommyds: corpus re-promoted with the header-inline rule; bundle root

tommy_hashdyn_search, tommy_hashlin_search, tommy_hashtable_search and
the tommy_list/tommy_inthash inlines are published by their units and
imported by every other unit (1,469 lines of private copies gone);
check_.w resolves them through the imports. bundle.w is the root the
migrate action writes. tommycheck passes.

* std.collections.hash_index: HashIndex[K, V] over the TommyDS hashdyn engine

Node ownership for an intrusive engine (docs/stdlib_sourcing_plan.md,
Phase 2): the facade owns every node in one heap slot per entry: the
node first, so the engine's node pointer is the slot, then the key
comparator the one C trampoline reads, then the key and value. get
observes, remove and a replacing insert transfer, clear and drop walk
the buckets and release every slot exactly once; lookups reuse one
probe slot. Behavior test, complexity row (hash-index, linear),
drop-audit cells, and test/benchmark/hash_engines.w (facade vs raw
engines vs rt_core HashMap).

* docs: Phase 2 status (TommyDS bundle, header-inline rule, HashIndex, benchmark table)

* docs: handoff for Phases 0/1/2 (2026-09-14, evening)

* docs: handoff — Phase 2 battery green, PR #1141

---------

Co-authored-by: Eric Hartford <[email protected]>
# Conflicts:
#	docs/with-abi.sha256
#	src/CodegenDispatch.w
#	test/complexity/stdlib.w
#	tools/drop_audit.w
@ehartford
ehartford merged commit 5809ac1 into main Sep 14, 2026
3 of 5 checks passed
@ehartford
ehartford deleted the c-algorithms-phase1 branch September 14, 2026 20:57
ehartford pushed a commit that referenced this pull request Sep 16, 2026
…on base reads plain

Two #1142 regressions the corpora never showed because nothing
re-migrates them (wo-drift compiles the checked-in output):

- The bridge stopped treating a leading underscore as anonymity, so
  `FILE *` became `*mut __sFILE` (41 sites in pcre2test alone): a system
  record the migrator never emits, while std.libc's fopen returns
  `*mut c_void`. A reserved-spelled tag declared in a system header is
  now spelled c_void; a project's `_Tag` keeps its identity.
- The field printer's borrow-through-type form met a struct's unnamed
  union member (zlib's `ct_data.fc`), whose type is c_void, and emitted
  `(*(&raw const x.fc as *const c_void)).freq`. An opaque base prints
  plain `base.field`.

behav_migrate_system_record_pointer and behav_migrate_anon_union_field
pin both.
ehartford added a commit that referenced this pull request Sep 16, 2026
…e path boundary (#1151)

* build: the pinned seed drives the battery

CI drives `build` and `:test` with the seed pinned in seed.lock, so every
action body in build.w and build/*.w runs under that released compiler's
evaluator. The local battery was driven by ~/.local/bin/with, which every
battery replaced with the fresh compiler (`:update-seed`), so build-layer
code only the fresh compiler accepts passed locally and broke CI (#1143:
`<` on strings in an action). Rust and Go pin the compiler that runs the
build system and refuse a newer one for that job; With now does the same.

- src/main is always the seed.lock asset: `with build :seed` is idempotent
  on the lock's digest (a bump refetches, any other binary is replaced);
  `:update-seed` is gone.
- `seed-driver` (build/retention.w) hashes the driving compiler (the
  graph's "seed" resolution: WITH, PATH, src/main) against seed.lock, walks
  the action's process ancestry on POSIX so `WITH=src/main with build` is
  refused too, and checks the workflow pins. First in :test, a dep of
  test-green and last-green; test-green records driver_sha256 and
  last-green requires it and the seed-input digest.
- `seed-compat` (stage1 in a tree copy, never run in CI) is retired; its
  RSS-tripwire exemption goes with it.
- nightly-release drives :fixpoint, :test and :last-green with src/main on
  every platform; only the release UAT runs the rebuilt binary.
- CLAUDE.md/AGENTS.md, README, the release and bootstrap runbooks and
  tools/bump_seed_pins.w describe the seed-driven battery.

* rt: with_libc_* seams for the stdio streams, errno, fileno, isatty, rlimit, mkstemp, realpath

std.libc will export C-standard functions and With functions over
with_libc_* seams only (Eric, 2026-09-15): nothing POSIX-, Darwin- or
glibc-spelled, so a corpus migrated on one host links on every target.
This lands the runtime side first (Bootstrap Rules: new exports before
their consumers): rt_core.w gains with_libc_stdin/stdout/stderr/errno/
fileno/isatty/getrlimit/setrlimit/mkstemp/realpath over one rt_* body
per backend. Windows' stream accessors now return the UCRT streams
(__acrt_iob_func) instead of null. The Darwin-spelled shims each backend
still defines (__error, __std*p, getrlimit, mkstemp, realpath) go with
the std.libc change that stops referencing them.

* migrate: the Clang bridge is the one path boundary

Every file path or location the bridge hands upward is spelled with `/`,
whatever libclang or the host said: on Windows Clang spells locations
with `\` and mixes separators within one path, and GetFullPathNameA
answers realpath with `\`. buf_append_path/make_path_str rewrite at the
five location builders, the inclusion collector, realpath and the
cursor-in-file fallbacks, so basenames, stems, the header-owner pairing,
module paths and diagnostics see one spelling on every host. The migrator
normalizes its CLI paths (input, output, -I, forced includes) once at
entry and no longer looks for `\` anywhere (138c5f8's either-separator
basename is gone).

behav_migrate_backslash_locations includes a header through a name
carrying a literal backslash and migrates into a backslash output path:
on POSIX the header is a file literally named eng\engine.h, on Windows a
subdirectory, and either way the location's basename must pair the
header's inline with its unit and nothing downstream may see a `\`.

* migrate: FILE-class system records are c_void again; an anonymous union base reads plain

Two #1142 regressions the corpora never showed because nothing
re-migrates them (wo-drift compiles the checked-in output):

- The bridge stopped treating a leading underscore as anonymity, so
  `FILE *` became `*mut __sFILE` (41 sites in pcre2test alone): a system
  record the migrator never emits, while std.libc's fopen returns
  `*mut c_void`. A reserved-spelled tag declared in a system header is
  now spelled c_void; a project's `_Tag` keeps its identity.
- The field printer's borrow-through-type form met a struct's unnamed
  union member (zlib's `ct_data.fc`), whose type is c_void, and emitted
  `(*(&raw const x.fc as *const c_void)).freq`. An opaque base prints
  plain `base.field`.

behav_migrate_system_record_pointer and behav_migrate_anon_union_field
pin both.

* std.libc: C-standard functions and with_libc_* seams only

Eric's rule (2026-09-15): std.libc exports C-standard functions (the same
name and meaning in libSystem, glibc and the UCRT) and With functions
over with_libc_* runtime seams; nothing POSIX-, Darwin- or glibc-spelled,
so a corpus migrated on one host links and behaves the same on every
target. The Darwin stdio globals, glibc's stdin/stdout/stderr, __error,
fileno, isatty, mkstemp, realpath and get/setrlimit leave the module;
libc_stdin/stdout/stderr(), errno_ptr(), fileno, isatty, mkstemp,
realpath, getrlimit and setrlimit are With functions over the seams that
landed in fb2933d5. The Linux and Windows backends drop the Darwin-spelled
shims they carried to fake those symbols, and FnAbi's preserved-name list
shrinks with them. std.os stops c_importing isatty.

The migrator lowers the stdio globals to the accessor calls
(ci_libc_stream_accessor) and renames the host errno/fileno/isatty
spellings to the std.libc names (ci_libc_portable_callee), so migrated
output never names a host symbol.

Gates: libc-surface-check (:test) scans lib/std/libc.w for the rule and
cross-checks the migrator allowlist against the module and the preamble;
corpus_reject_foreign_symbols (<stem>-check-generated and -promote)
refuses any extern outside the migrator preamble, any extern variable and
any retired host spelling, with Corpus.declared_externs for a prototype
upstream declares but never defines (c-algorithms'
rb_tree_subtree_height); tools/rt_decl_audit.w becomes the rt-decl-audit
lane. The selfhost-linux-aarch64 lane's missing :test is #1149.

* corpora: pcre2 and zlib re-promoted by the current migrator

The stdio globals become libc_stdin/stdout/stderr() calls and __error()
becomes errno_ptr() (std.libc's seams; zl/gzread and gzwrite no longer
carry a Darwin-only symbol inside the bundle), and the output picks up
the migrator's explicit argument and array-literal casts that landed
since these corpora were last promoted. c_algorithms and tommyds
re-promote byte-identical.

* docs: handoff — the CI gates branch

* docs: seed.lock names seed-driver; handoff cites subjects, not hashes

---------

Co-authored-by: Eric Hartford <[email protected]>
ehartford pushed a commit that referenced this pull request Sep 16, 2026
…nd the two open decisions

Replaces the stdlib-sourcing/corpus-registry handoff (that work is merged:
#1129, #1142, #1151). Records the release state at 4ecfddb: what each
Release leg failed on and which fix addresses it, the evidence on this
commit (battery green through last-green; :release-uat red on openssl
alone), the two decisions blocking the cut (#1158 openssl double free,
windows-aarch64 placement), the exact publish sequence, the issues filed
today, and the environment traps that cost rebuild cycles to find.
ehartford added a commit that referenced this pull request Sep 16, 2026
…th SDKs on all platforms) (#1155)

* release: make every Release leg able to go green (linux-aarch64 host map, windows-aarch64 NM, reproducible Windows links)

The Release workflow has failed on every platform since 2026-09-12; v0.15.2.1
shipped SDKs for three of five platforms because its Windows legs never
finished. Three of the causes, each verified against the failed run
35102512299:

- build.w: release_asset_for_host() / supported_release_platform_tag() had
  no linux-aarch64 case and fell through to the darwin asset, so on that
  host the seed-driver, test-green, last-green and seed targets — and the
  SDK asset name — all keyed on darwin ("the driving compiler ... is not the
  pinned seed v0.15.2.0 (79a63ff...)" compared the linux-aarch64 seed to the
  darwin digest). Add the case.

- nightly-release.yml, windows-aarch64: the toolchain step never exported
  NM, so cli-selfhost-object-symbol-tests and bundle-interface-tests ran
  the runner's MSYS nm, which cannot parse an arm64 COFF image ("nm failed
  for emit_obj_globals"). Point NM at the SDK's llvm-nm.exe, as
  selfhost-windows-aarch64.yml already does.

- src/compiler/Link.w: pass /Brepro on the COFF link. The seed-driven gates
  relink the release compiler in every step on every platform (a separate
  inefficiency), and only on Windows did the bytes change, because lld-link
  stamps the PE header and PDB GUID from the wall clock; fixpoint compares
  emitted objects, never the linked image, so it never saw the churn. That
  is the "last-green: stale test pass marker" failure on windows-x86_64:
  the marker's compiler sha256 was taken before the relink.

* release: c_import generator fixes for the UAT packages, local-first release process, linux-aarch64 Docker host

The release UAT's zlib, sqlite3 and openssl legs broke because `with get`
now fetches zlib 1.3.2 and OpenSSL 4.0.2, whose headers reach three latent
gaps in the c_import modeler (the 09-06 compiler fails on them identically):

- src/CImport.w: an object-like macro whose value is a call is recorded
  untranslated, like a function alias — a known C function would be a raw
  call at program start (`#define zlib_version zlibVersion()`, "raw c_import
  function call requires unsafe context"), and a callee this import never
  emitted leaves a dangling name (`#define OSSL_DEPRECATEDIN_4_0
  OSSL_DEPRECATED(4.0)`, "undefined variable"). Referencing such a macro is
  the loud, allow-gated omission error.
- src/CImport.w: every type position now spells a raw C function pointer
  `unsafe extern "C" fn(...)` — the constant-probe emitter, the typedef
  alias resolver and ci_infer_cast_return_type had kept the safe spelling,
  so sqlite3's `#define SQLITE_STATIC ((sqlite3_destructor_type)0)` became
  `let SQLITE_STATIC: extern "C" fn(...) = (0 as unsafe extern "C"
  fn(...))`, a binding type mismatch.
- build/release_uat_fixtures/openssl_main.w: `write` is import-gated
  (#750); add `use std.builtins.write`.
- test/spec/spec_ss14_11_await_combinator_cancel_joins.w: `skip-on:
  linux-aarch64` — #916 does not reproduce there, so the known-issue gate
  reported "expected red but passed" (the one red file of 210 on that leg).

The openssl UAT still fails on darwin/linux until #1158 (a double free in
compile_source_frontend_mode while modeling OpenSSL 4.0.2's evp.h; a main
regression since v0.15.2.1, layout-dependent).

Process (Eric, 2026-09-16): the Mac builds and publishes darwin-aarch64 and
linux-aarch64; CI builds and appends the rest.
- tools/docker/linux-aarch64/Dockerfile: the native linux/arm64 release
  host (an Apple Silicon Mac runs it natively); bakes in what a bare
  ubuntu:24.04 lacks and fails silently without (g++, libxml2).
- tools/release_local.w: `with run tools/release_local.w vX.Y.Z` — the
  darwin gates, :release-uat, packaging and publish-first, then the same
  inside the container for linux-aarch64 (pins from seed.lock and the
  linux-aarch64 lane).
- .github/workflows/nightly-release.yml: darwin-aarch64 leaves the unix
  matrix for its own job; it and build-linux-aarch64 run only when
  github.event_name != 'push', so a tag push builds linux-x86_64,
  windows-x86_64 and windows-aarch64 and the nightly/test channels still
  exercise all five.
- docs/with-release-runbook.md: "Linux aarch64 Release Host (Docker on
  Apple Silicon)" and "Local-first: the Mac publishes darwin and
  linux-aarch64; CI appends the rest".

* docs: handoff — cutting v0.15.2.2, the local-first release process, and the two open decisions

Replaces the stdlib-sourcing/corpus-registry handoff (that work is merged:
#1129, #1142, #1151). Records the release state at 4ecfddb: what each
Release leg failed on and which fix addresses it, the evidence on this
commit (battery green through last-green; :release-uat red on openssl
alone), the two decisions blocking the cut (#1158 openssl double free,
windows-aarch64 placement), the exact publish sequence, the issues filed
today, and the environment traps that cost rebuild cycles to find.

---------

Co-authored-by: Eric Hartford <[email protected]>
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