Repository navigation
Merged
Conversation
added 8 commits
September 15, 2026 17:21
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.
…limit, 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.
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 `\`.
…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.
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.
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.
This was referenced Sep 16, 2026
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]>
ehartford
added a commit
that referenced
this pull request
Sep 20, 2026
…piler crash, survey running through failures, three migrator bugs, an unchecked promotion) (#1219) * `?` over a Unit payload extracts nothing; the verifier checks enum payload reads `step()?` where step returns Result[Unit, E] crashed the compiler in LLVM (exit 133, DataLayout::getTypeSizeInBits under Codegen.mir_eval_operand), on every compiler back to the pinned seed. lower_question_mark_value read a Unit payload type as "no type known" and fell back to the scrutinee's type, so the pass path declared the payload place as the whole Result: _5: ty405 = move _3<as v0>.f0 // ty405 is Result[Unit, str] and codegen built a load of the variant's real, unsized, field. Unit is an answer there, not a missing one: the pass path now goes straight to the join and the expression is unit. --validate-all said ok over that body. mir_validate_place_type returns the type the lowering declared for a place and never compares it with what the projections yield, so a wrong declaration vouched for itself. A use of an enum payload (a field under a downcast) now has to agree with the variant's payload type; mir_test_enum_payload_read builds the bad and the good read by hand and checks both verdicts. validate-all over src/main.w stays ok. Option[Unit] is not covered: a function returning it does not compile at all (#1218). * Survey keeps going past a failure, never through one Survey is the default since --fail-fast became the opt-out, and it skipped only test-green and last-green by name after a failure. Every other target still ran when its dependency had failed: zlib-promote ran after zlib-build and zlib-test failed and replaced lib/std/zl with a corpus that did not compile. A target whose dependency failed or was skipped is now skipped, named with the dependency that stopped it, and counted as a failure of the run, so the skip carries through Groups and chains. An unrelated target still runs. * migrate: FILE pointers in bodies, `*array`, array parameters; std.libc gains fseek, ftell, remove Found migrating zlib's contrib/minizip. Nothing re-migrates a corpus in the battery, so the first had sat on main since #1151. - A `FILE *` local or cast inside a body became `*mut __sFILE`, a system record the migrator never emits (minigzip stopped compiling). #1151 taught the bridge's string translator that a reserved-spelled system record behind a pointer is c_void; bodies are typed by the structural builder, which never asked. It now asks the same rule (with_ci_type_is_reserved_system_record), and the test covers parameter, field, return, local, initialised local and cast. - Unary `*` on an array dereferenced the array value ("cannot dereference non-pointer value"; mztools' READ_8(header) over char header[30]). C decays the operand first: decay_deref_operand, at both places a dereference is built. A reference to an array-spelled parameter is left alone: libclang reports the written array type for it, and it is already a pointer. - A constant-array parameter (`int v[4]`) was bound by value as [4]i32, which no caller's decayed argument fits and which is the wrong ABI for a c_import of such a function. C adjusts it to a pointer to the element; translate_parameter_type does the same. std.libc: fseek and ftell are With functions over a 64-bit seam (fseeko and ftello on the POSIX backends, _fseeki64 and _ftelli64 on Windows, where C's long is 32 bits), and the migrator rewrites the hosts' wide spellings (fopen64, fseeko, fseeko64, ftello, ftello64, _fseeki64, _ftelli64) to them. remove is C-standard and joins the extern list the surface check reads. * zlib corpus: minizip's reader, repair and stream callbacks; every generated module is checked before promotion contrib/minizip ships in the same zlib release, so it is part of the zlib migration: ioapi, unzip and mztools join the staged sources and the bundle as std.zl.ioapi, std.zl.unzip and std.zl.mztools. The writer (zip.c with skipset.h) waits: zipAlreadyThere uses setjmp/longjmp as its out-of-memory landing pad, there is no switch to compile it out, and the migrator refuses setjmp (#1217). The two command-line programs and iowin32 stay out. The pre-promotion check was a text scan, so a module no harness program imports was first compiled by the bundle build, after promotion had replaced the corpus (mztools.w did not compile). check-generated now type-checks the generated bundle root, which imports every module, the way the bundle build compiles it: the prelude off and --bundle-corpus, so the corpus is read from the generated sources and not from the bundle interface the compiler embeds, which predates the migration. defs.w also picks up what main's migrator has emitted since the corpus was last promoted (function-like macros as generic functions, unfolded constant expressions, zlib_version left untranslated by #1191). std.fs gains chmod. * verifier: the payload-read check runs only where the payload type is exact The check added two commits back went red on user Try types (spec_ss11_7_try_trait, behav_return_temporary_cleanup's user-try cases): `validate(part)?` reads Continue's payload out of ControlFlow[str, i32], declared i32, and the verifier derived str. The lowering was right. mir_validate_enum_payload_type guessed that every two-argument generic enum carries its arguments in variant order, which is Result's declaration and not ControlFlow's (Continue(C) comes before Break(B)). Nothing had relied on that answer until the new check did. The positional rule is now Result's alone (the module records Result's symbol), and the payload-read check runs only for a plain enum or an Option or Result instance: another generic enum's payload is a type parameter this module cannot substitute, and an unknown is not a mismatch. --------- Co-authored-by: Eric Hartford <[email protected]>
ehartford
added a commit
that referenced
this pull request
Sep 20, 2026
…s which part changed (#1225) Every action's signature carried the fingerprint of the binary orchestrating the build (:WITH:). Our workflow alternates orchestrators all day: the iterate tier uses the installed compiler, the battery the pinned seed, corpus promotion the release compiler. With the seed held fixed (WITH=src/main) and only the orchestrator changed, --explain reported stage1, stage2, link-compiler, the runtime objects and the bundle builds all "stale: action signature changed": a full compiler rebuild, about 4.5 minutes, per switch. (:zlib-promote spent 270 s rebuilding stage1, stage2 and link-compiler right after a build had produced them.) The orchestrator produces a target's output only when it compiles it itself: the compile kinds, and an action with no `compiler=` (a workspace compile runs in the driver's compiler). An action that names its compiler is produced by that compiler; a tree compiler is already hashed by the stage-target block and `compiler=seed` is the seed WITH names. Such an action now keys on the seed (build_cache_producer_fingerprint). Go, Zig and Rust all key on the producing tool, never on the build driver. With WITH=src/main driven by src/main the signature text is unchanged, so seed-driven batteries stay warm. The state file held the signature as one hash, so "signature changed" could not say what changed. It now records each component's hash (target, producer, action-code or build-graph, compiler-source, compiler) and the stale reason names the ones that differ; WITH_BUILD_CACHE_TRACE=<target> prints them. Evidence, two binaries with different sha256 (release 32543048…, stage2 0dbd11f3…) over one seed, after a build orchestrated by the first: stage1, stage2, link-compiler, rt-core-object and zlib-wo-build are fresh under both. libc-surface-check (no compiler=, so the driver is its producer) is fresh under the first and "stale: action signature changed (producer)" under the second. The pinned seed (v0.15.2.0) still disagrees with a current compiler: it predates #1151/#1185/#1191's changes to this code and records no component hashes; that ends at the next seed. Co-authored-by: Eric Hartford <[email protected]>
ehartford
pushed a commit
that referenced
this pull request
Sep 22, 2026
…igration spells them void * Root cause: ClangBridge.w translate_type_recursive_mode's pointer branch (the `record_is_reserved_system` arm) spelled every pointer to a reserved-spelled record from a system header — Darwin's `struct __sFILE` behind FILE, glibc's `struct _IO_FILE` — as `*mut c_void`, and with_ci_type_is_reserved_system_record made CImport.w's structural builder agree. The rule is the migrator's (#1151, #1219): migrated code calls std.libc, whose stdio takes `*mut c_void`, and the migrator never emits system records. But the bridge is shared, so every c_import of <stdio.h> lost FILE's identity too, and the toolchain libc facade's `CFile wraps *mut FILE` could never match a real header. The erasure is now a property of a migration session (CImportSession.migration, set by with_cimport_session_set_migration at both CiMigrate parse sites). A c_import keeps the pointee's identity: fopen returns `*mut __sFILE` with `type FILE = __sFILE` on Darwin (`*mut _IO_FILE` / `type FILE = _IO_FILE` on glibc), which the facade's alias-aware comparison matches. The record's fields are translated as before; nothing gains a safe operation. Test: behav_c_facade_libc_system_headers imports the real <string.h>, <stdlib.h>, <stdio.h>, <dirent.h>, <unistd.h>: CHeapStr from strdup, CFile from tmpfile (fputs/rewind/fgets round-trip, fd closed once after drop), CDir from opendir with d.readdir()/d.rewinddir() (dirfd closed once after drop), leak count 0 under --debug-alloc. behav_c_facade_libc_stdio_stays_raw pinned the defect and is removed. All migrate tests pass unchanged; UAT fixtures and examples check byte-identically before and after.
ehartford
pushed a commit
that referenced
this pull request
Sep 23, 2026
…igration spells them void * Root cause: ClangBridge.w translate_type_recursive_mode's pointer branch (the `record_is_reserved_system` arm) spelled every pointer to a reserved-spelled record from a system header — Darwin's `struct __sFILE` behind FILE, glibc's `struct _IO_FILE` — as `*mut c_void`, and with_ci_type_is_reserved_system_record made CImport.w's structural builder agree. The rule is the migrator's (#1151, #1219): migrated code calls std.libc, whose stdio takes `*mut c_void`, and the migrator never emits system records. But the bridge is shared, so every c_import of <stdio.h> lost FILE's identity too, and the toolchain libc facade's `CFile wraps *mut FILE` could never match a real header. The erasure is now a property of a migration session (CImportSession.migration, set by with_cimport_session_set_migration at both CiMigrate parse sites). A c_import keeps the pointee's identity: fopen returns `*mut __sFILE` with `type FILE = __sFILE` on Darwin (`*mut _IO_FILE` / `type FILE = _IO_FILE` on glibc), which the facade's alias-aware comparison matches. The record's fields are translated as before; nothing gains a safe operation. Test: behav_c_facade_libc_system_headers imports the real <string.h>, <stdlib.h>, <stdio.h>, <dirent.h>, <unistd.h>: CHeapStr from strdup, CFile from tmpfile (fputs/rewind/fgets round-trip, fd closed once after drop), CDir from opendir with d.readdir()/d.rewinddir() (dirfd closed once after drop), leak count 0 under --debug-alloc. behav_c_facade_libc_stdio_stays_raw pinned the defect and is removed. All migrate tests pass unchanged; UAT fixtures and examples check byte-identically before and after.
ehartford
added a commit
that referenced
this pull request
Sep 23, 2026
…/borrows: deprecated (#1361) * Facade: a resource is the safe surface of its representation; the raw C name stays raw (§16.2b.5) A resource clause (producer, drop, destroys, init, preinit) no longer lifts the C function it names out of the raw classification, and an fn item no longer covers a parameter that takes a resource's representation or the one a `destroys` item destroys. Before, `db_close(d.repr)` compiled in safe code and Drop closed the handle again — "destroy through C, then Drop destroys again" is not expressible in safe code (§16.2b.5) — and a bare producer call handed back a pointer nothing destroys. The rendering calls each C operation inside an inner `unsafe {}` when the callee is raw (FacadeRender.w facade_render_is_raw, the AST reading of ci_function_requires_raw_abi), and a lend of a pointer representation is rendered as a `&self` method of the resource (`d.db_count()`): With proves the receiver live, unmoved and undestroyed, which it cannot prove of a raw pointer. The §61 "still a raw call" checks now ask whether the operation is raw apart from the representation it is handed (facade_op_raw_beyond). Tests: err_c_facade_raw_destroyer_stays_raw, err_c_facade_raw_producer_stays_raw, err_c_facade_raw_lend_on_resource_stays_raw; c_facade_lend_call_needs_no_unsafe keeps its covered lend over a non-resource parameter; c_facade_resource_renders calls the lend as a method. * Facade: a resource may have several producers, one constructor per `from` libc's fopen, fdopen and tmpfile each produce the FILE that fclose destroys; strdup and strndup each produce the string free releases. FacadeResource keeps a producer per `from` clause (with its out parameter), every §61 check runs over each, `borrows` names a parameter of the `from` it follows, and the renderer emits one safe constructor per direct-return producer. Test: behav_c_facade_resource_several_producers (Drop once per producer). * Facade: a pointer producer's constructor yields Option[R] (§16.2b.8) Unknown nullability is nullable and never silently becomes non-null (§16.2b.8). The rendered direct-return constructor of a pointer resource returned `R` over whatever C handed back, so a failed producer armed Drop over NULL — for libc, fclose(NULL) and closedir(NULL) are undefined. It now returns `Option[R]`: NULL produced nothing (§16.2b.4) and no Drop is armed. A by-value representation's constructor still returns `R`. Test: behav_c_facade_resource_null_producer_none (None arms no destroyer); the stage-4a tests unwrap their constructors. * Facade: types compare through pointee aliases; a facade names the imported declaration Two §61 verification defects that libc's own headers expose: - A header's `typedef struct __dirstream DIR` translates opendir as returning `*mut __dirstream` while a facade names `*mut DIR`. The producer-return, destroyer, out-parameter, init and lend comparisons resolved the outer alias only, so the same representation was refused. SemaFacade.w facade_same_type chases aliases through pointees; the renderer's facade_render_unalias does the same on the text (and stops at an `opaque` declaration, which is a distinct type, not an alias of void). - The renderer found an operation by name among every declaration of the compilation, so std.libc's hand-written `fclose(*mut c_void)` could stand in for the `fclose(FILE *)` the program imported. A facade describes imported declarations (§16.2b.13): the Frontend hands the renderer the c_import flags and a c_import declaration wins. Also exposes facade_render_import_shape for the toolchain libc facade. Test: behav_c_facade_resource_pointee_alias. * Modeled C stage 4c: the toolchain libc facade replaces Mechanism A; owns:/borrows: are deprecated facade spellings The #357 owning-wrapper tables (strdup/strndup -> free, fopen/fdopen/tmpfile -> fclose, opendir -> closedir, readdir/rewinddir borrowing the directory) and their COwned_* generators are deleted from CImport.w. The same eight rows are now a `c facade` shipped with the toolchain (ruling §5 "bounded knowledge"; spec §16.3c "the curated libc facade, which is a standard deliverable"), compiler/LibcFacade.w: c facade libc: resource CHeapStr wraps *mut i8 from strdup, strndup; drop free resource CFile wraps *mut FILE from fopen, fdopen, tmpfile; drop fclose resource CDir wraps *mut DIR from opendir; drop closedir fn readdir / fn rewinddir lend, of CDir After every c_import translation the Frontend splices the part of it the program's imported declarations support — each described declaration must have libc's shape (a producer returns the representation, the drop takes it or void *, a lend takes it) — as the synthetic file `<toolchain facade libc>`, owned by the importing module; names the program's own facades state are left to them. It renders and verifies like any facade: safe constructors yielding Option[R], Drop calling the destroyer once, lends as methods (`d.readdir()`), the raw C names raw. Darwin's <stdio.h> hands FILE * through as `*mut c_void`, not libc's shape, so CFile does not apply there and fopen stays raw. owns:/borrows: are deprecated spellings (plan stage 4: "become deprecated spellings with a diagnostic naming the facade clause"; the compatibility precedent is retains:, spec §16.3c): each entry is projected into the facade it spells — `owns: ["f -> d"]` is `resource F wraps <f's return>`, `from f`, `drop d`; `borrows: ["g(i) -> f"]` is `fn g`, `lend` — spliced as `<c_import annotations>`, with a warning naming the clauses to write. A malformed entry is an error. The c_import cache key drops its #owns/#borrows lines (translation no longer depends on them) and moves to cimport-v18. Both land together: retiring the generator alone would have turned the keys into silent no-ops. Flipped to the facade surface: behav_c_import_owning_wrapper_fopen, _strdup, behav_c_import_owns_annotation, _borrows_annotation, behav_c_import_borrow_param_readdir (+ d_acceptance copy). New: behav_c_facade_libc_free_once (Darwin malloc_size witness), behav_c_facade_libc_system_headers, behav_c_facade_libc_stdio_stays_raw, behav_c_import_owns_borrows_deprecated, behav_c_import_owns_deprecated_warns, err_c_import_owns_malformed. The §60 guards (err_c_import_destroy_heuristic_no_owning_wrapper, err_c_import_uncurated_ptr_return_raw, err_c_import_raw_call_requires_unsafe) still fail as pinned. * Tests: the libc system-header facade test is Darwin-only; name the bridge rule that erases FILE * The bridge types a pointer to a reserved system record as `*mut c_void` (CImport.w type_from_libclang): Darwin's `struct __sFILE` FILE and glibc's `struct __dirstream` DIR. Neither is libc's shape for the toolchain facade, so behav_c_facade_libc_system_headers (CDir over <dirent.h>) runs on Darwin only, and behav_c_facade_libc_stdio_stays_raw names the rule. * c_import keeps FILE * and DIR * as pointers to FILE and DIR; only a migration spells them void * Root cause: ClangBridge.w translate_type_recursive_mode's pointer branch (the `record_is_reserved_system` arm) spelled every pointer to a reserved-spelled record from a system header — Darwin's `struct __sFILE` behind FILE, glibc's `struct _IO_FILE` — as `*mut c_void`, and with_ci_type_is_reserved_system_record made CImport.w's structural builder agree. The rule is the migrator's (#1151, #1219): migrated code calls std.libc, whose stdio takes `*mut c_void`, and the migrator never emits system records. But the bridge is shared, so every c_import of <stdio.h> lost FILE's identity too, and the toolchain libc facade's `CFile wraps *mut FILE` could never match a real header. The erasure is now a property of a migration session (CImportSession.migration, set by with_cimport_session_set_migration at both CiMigrate parse sites). A c_import keeps the pointee's identity: fopen returns `*mut __sFILE` with `type FILE = __sFILE` on Darwin (`*mut _IO_FILE` / `type FILE = _IO_FILE` on glibc), which the facade's alias-aware comparison matches. The record's fields are translated as before; nothing gains a safe operation. Test: behav_c_facade_libc_system_headers imports the real <string.h>, <stdlib.h>, <stdio.h>, <dirent.h>, <unistd.h>: CHeapStr from strdup, CFile from tmpfile (fputs/rewind/fgets round-trip, fd closed once after drop), CDir from opendir with d.readdir()/d.rewinddir() (dirfd closed once after drop), leak count 0 under --debug-alloc. behav_c_facade_libc_stdio_stays_raw pinned the defect and is removed. All migrate tests pass unchanged; UAT fixtures and examples check byte-identically before and after. --------- Co-authored-by: Eric Hartford <[email protected]>
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.
PR #1143 went red twice for defects the local battery could not see: an action used
<on strings (the pinned seed's evaluator rejects it, the fresh compiler accepts it), a fixture split a Windows location on/only, and std.libc exported Darwin/glibc-only externs that only fail to link on another host. Two rulings (2026-09-15) and their gates:The pinned seed drives the battery (the Rust and Go way).
src/mainis always the seed.lock asset (with build :seedis idempotent on the digest and refetches on a bump).seed-driverhashes the driving compiler against seed.lock, walks the action's process ancestry on POSIX soWITH=src/main with buildis refused too, and checks the workflow pins; it runs first in:testand gatestest-greenandlast-green, which now recorddriver_sha256.:update-seedand:seed-compatare gone. nightly-release drives:fixpoint,:testand:last-greenwithsrc/mainon every platform. The battery isWITH=$PWD/src/main src/main build ...then:install-user(CLAUDE.md, README, runbooks).std.libc exports C-standard functions and With functions over
with_libc_*seams only. The stdio streams, errno, fileno, isatty, mkstemp, realpath and rlimit are seams with one body per backend (Windows' streams are now the real UCRT streams); the migrator rewrites the host spellings (__stderrp→libc_stderr(),__error()→errno_ptr(),_fileno,_isatty,__acrt_iob_func); the Linux/Windows backends drop the Darwin-spelled shims. Gates:libc-surface-check(:test),corpus_reject_foreign_symbols(check-generated and promote),rt-decl-audit(:test). All four bundle objects carry no host symbol (nm -u).The Clang bridge is the one path boundary. Every location and path it hands up is
/; the migrator normalizes its CLI paths once and no longer looks for\anywhere.behav_migrate_backslash_locationsruns on every host.Two #1142 migrator regressions, found only because this work re-migrates the corpora (nothing in the battery does):
FILE *had become*mut __sFILE, and an anonymous union base printed as an uncompilable borrow. Fixed with fixtures; pcre2 and zlib re-promoted.Filed #1149 (linux-aarch64 lane runs no
:test). Battery green under the pinned seed on macOS: build, fixpoint, test, last-green.