Skip to content

zlib corpus gains minizip's reader; six defects it exposed (a ? compiler crash, survey running through failures, three migrator bugs, an unchecked promotion) - #1219

Merged
ehartford merged 5 commits into
mainfrom
zlib-minizip
Sep 20, 2026
Merged

ehartford merged 5 commits into
mainfrom
zlib-minizip

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

zlib's contrib/minizip ships in the same release tarball, so it joins the zlib migration rather than becoming a corpus of its own. Migrating it exposed six defects; all are fixed here, each with a test.

Corpus. ioapi, unzip and mztools are staged and bundled as std.zl.ioapi, std.zl.unzip, 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 compile switch, and the migrator refuses setjmp (#1217; libpng and libjpeg need the same support). The two command-line programs and iowin32 stay out. defs.w also picks up what main's migrator has emitted since the last promotion.

Defects.

  1. ? over Result[Unit, E] crashed the compiler in LLVM (exit 133), on every compiler back to the pinned seed. lower_question_mark_value read a Unit payload type as "no type known" and typed the payload place as the whole Result; codegen loaded an unsized field. Unit is an answer: the pass path extracts nothing. --validate-all said ok over that MIR because mir_validate_place_type trusts the declared place type; enum payload reads are now checked where the payload type is exact (a plain enum, Option, Result). That check first went red on user Try types: the verifier's helper assumed every two-argument generic enum orders its variants like Result, and ControlFlow declares Continue(C) before Break(B). The positional rule is now Result's alone.
  2. Survey ran the dependents of a failed target. zlib-promote ran after 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 and counted as a failure.
  3. migrate: a FILE * local or cast inside a body became *mut __sFILE. CI gates: the pinned seed drives the battery; std.libc seams only; one path boundary #1151 fixed only the signature path; bodies use the structural type builder, which never asked. On main since then, unseen because the battery never re-migrates.
  4. migrate: *array dereferenced the array value (mztools' READ_8(header)). C decays the operand first.
  5. c_import and migrate: a constant-array parameter (int v[4]) was bound by value as [4]i32. C adjusts it to a pointer to the element. ABI-facing for any c_import of such a function.
  6. The pre-promotion check was a text scan, so a module no harness program imports was first compiled after promotion. check-generated now type-checks the generated bundle root (which imports every module) with --no-prelude --bundle-corpus, so the corpus is read from the generated sources and not from the stale bundle interface the compiler embeds.

std.libc / std.fs. fseek and ftell over a 64-bit seam (fseeko/ftello on POSIX, _fseeki64/_ftelli64 on Windows, where C's long is 32 bits); the migrator rewrites the hosts' wide spellings to them. remove (C-standard). std.fs.chmod.

Not in this PR. The std.zip facade and its test (reads an Info-ZIP-made archive: stored and deflated members, Unix modes, extraction, a path-escaping entry refused, a corrupted byte caught) are written and pass, and are held out because spec-inventory-check rightly refuses a stdlib module with no §21 row; the row needs Eric's words. with get switches its zip extraction to std.zip after the next seed: the pinned seed cannot compile anything that reaches std.libc (unknown type 'c_va_list'). Filed, not fixed: #1218 (Option[Unit] as a return type does not compile; loud).

Evidence (pinned seed, head f27eca3):

build rc=0   fixpoint rc=0   test rc=0   move-audit rc=0   drop-audit rc=0
test-green rc=0   last-green rc=0   release-uat rc=0

The first battery on this branch was red in :test (the two user-Try tests above); the fifth commit is that fix. validate-all over src/main.w is ok with the new check.

Eric Hartford added 5 commits September 19, 2026 20:43
…yload 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 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.
…c 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.
…erated 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.
…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.
@ehartford
ehartford merged commit 66b5fd1 into main Sep 20, 2026
5 checks passed
ehartford added a commit that referenced this pull request Sep 20, 2026
… UATs; c_import lends strings (D47); the spec stops cataloguing lib/std (D48) (#1222)

* A user program is a contract: the spiral UAT as published, and no `unsafe` in UATs or examples

2026-06-17 (a88df01, #379) replaced the blanket `const char*` modeling with
a curated libc overlay: a c_import function with a string parameter outside
that list became the raw surface. That broke the raylib spiral release UAT,
which sat broken until 2026-09-07 (bd9683f), when the fixture was rewritten
to `unsafe { InitWindow(900, 600, c"...".ptr) }` so it would pass. Eric was
not told; his blog and the project primer ("Functions imported via c_import
are callable directly. The import is the opt-in.") still show the original.

- The spiral fixture is again the program a user writes: plain string
  literals to InitWindow and DrawText, no `unsafe`, and `sin`/`cos` from the
  language (D42) instead of two `extern fn` lines. It is red until c_import
  models a string lent to C for a call; that red is the truth.
- `with build :user-programs-safe`, a gate of `:release-uat`: no release UAT
  fixture and no program under examples/ says `unsafe`. It reports 28 uses
  today, across the zlib, bzip2, sqlite3 and libcurl fixtures: the list of C
  surfaces the compiler has not yet made humane.
- CLAUDE.md / AGENTS.md: editing a user program so a new rule passes is
  deleting a failing test; an application developer never writes `unsafe`.
- The release runbook no longer documents the workaround.

* The spec does not catalogue lib/std (D48); lending is not receiving (D47, §16.3c); std.zip

Eric, 2026-09-20: "I do not want the language spec to care what we do in
lib/std." §18.6's Module Map table and the std.internal paragraph are
removed, and spec-inventory-check no longer reads lib/std against the spec
(its keyword, attribute, command and flag arms stay). What remains normative
is the library surface the language depends on, each in its own section.

§16.3c gains the sentence Eric blessed 2026-09-20, verbatim: binding evidence
governs what With receives from C; a c_imported `const char *` parameter
accepts a `str` lent for the call, a literal passed directly and any other
`str` through call-scoped storage that stays readable if the callee retains
it. The compiler is NON-COMPLIANT until the next commits: it still calls such
a function the raw surface.

std.zip lands as an ordinary documented module (list, read, extract over the
migrated minizip reader), with the test that reads an Info-ZIP-made archive.
It was held out of #1219 only because the inventory wanted a spec row.

* Delete docs/requirements.md and its lane

Eric, 2026-09-20. The file was a hand-maintained snapshot of the spec with no
generator in the tree (build/requirements.w was removed earlier) and line
references about 870 lines stale. requirements-informative-check, its two
helpers, its :test dependency and the implementation-plan entry (#386,
closed) go with it.

* A call argument is evaluated once

`strlen(name(1))` called `name` twice, on main too:

    bb0: call name(1) -> _2      // lower_auto_deref_call_arg, probing
    bb1: _3 = move _2
         call name(1) -> _4      // lower_call_arg, for real
    bb2: call strlen(copy _4)

lower_auto_deref_call_arg (src/MirLower.w) lowered the argument into a place
before it knew whether any deref path leads from the argument's type to the
parameter's; for a `str` going to `*const c_char` there is none, so it
returned -1 with the call already emitted and lower_call_arg lowered the
argument again. (Found with --dump-mir, --explain-mir-origin main:_4, and an
lldb backtrace at each MirBuilder.lower_call.)

auto_deref_reaches decides the walk from the types; the argument is lowered
only when the walk can finish. The test counts calls for the failing walk
(str to a C string), a walk that needs none, and one through a field.

* c_import lends a str to a `const char *` parameter (§16.3c, D47)

The compiler now conforms to the sentence blessed 2026-09-20.

- Sema: a `const char *` input never makes a c_imported function the raw
  surface. ci_overlay_cstr_in_param_count, the hardcoded list of libc names
  that vouched for string inputs, is deleted; evidence still governs what
  With receives (pointer returns, mutable buffers).
- A string literal is passed directly: its bytes are a static NUL-terminated
  global, so nothing is lent and nothing can dangle. One with an interior NUL
  is a compile error.
- Any other str is lent by with_cstr_lend and returned by with_cstr_release
  (rt_core.w): blocks mapped outside the allocator, reused only for lent
  strings, each ending in a zero byte no lend overwrites. A callee that keeps
  the pointer reads stale text, never freed memory. The memory held is the
  peak of strings lent at once.

The raylib spiral, as published and with no `unsafe`, checks and runs:
"raylib spiral UAT passed: 581/7342 bright spiral samples". Generated code
for `remove("/x")` calls remove alone; for `remove(f"/x{n}")` it calls
with_cstr_lend, remove, with_cstr_release.

err_c_import_const_char_requires_overlay_evidence asserted #379's rule and is
replaced by behav_c_import_lends_str_to_const_char (non-curated functions
with a literal and a runtime str; every size class of the lending storage up
to 300000 bytes).

---------

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]>
@ehartford
ehartford deleted the zlib-minizip branch September 24, 2026 16:58
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.

codegen: a function returning Option[Unit] fails — return type mismatch at call site (struct{i32,i32} vs struct{i32})

1 participant