Skip to content

Integers print at their full width and signedness (#1922); tests drive the compiler under test; stage compilers resolve from their own tree; build runners shared machine-wide - #1929

Merged
ehartford merged 9 commits into
simd-implfrom
fix-int-fmt
Sep 30, 2026

Conversation

@ehartford

@ehartford ehartford commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
  • Printing an i128/u128 shows only its low 64 bits (f"{x}" of 1 << 100 prints 0) #1922: i128/u128 print in full; unsigned and narrow values keep their width under a format spec (u32 0xffffffff under :x was ffffffffffffffff); i64::MIN under :d no longer panics. LLVM and C backends.
  • behav_debug_info_variables and behav_action_capability_process: with test names the compiler under test in WITH_TEST_COMPILER (no more guessing a missing path, rc=127).
  • A stage compiler resolves out/gen and lib modules from its own tree, from any directory.
  • Build runners are shared machine-wide by content key, so a project's first build reuses one another project compiled (12–16 s saved per new project).
  • behav_return_temporary_cleanup builds once (128 s → 16 s); the binary-read cases split by strictness (both under the 120 s limit).

Draft until the stack battery is green.

@ehartford
ehartford added this pull request to stack #1928 September 30, 2026 06:04
@ehartford ehartford changed the title fix int fmt Integers print at their full width and signedness (#1922); tests drive the compiler under test; stage compilers resolve from their own tree; build runners shared machine-wide Sep 30, 2026
Eric Hartford added 9 commits September 30, 2026 03:42
…28-bit values, unsigned and narrow values under a format spec, i64::MIN (#1922)

Root cause (src/CodegenDispatch.w coerce_val_to_str_ext): every integer
wider than 32 bits went to with_fmt_i64/u64 after coerce_int_ext truncated
it to 64 bits, so an i128/u128 printed its low word (`1 << 100` printed 0).
On the same path, gen_fmt_with_spec and gen_fmt_buf_write_fmt passed
is_unsigned = 0 and sign-extended every value to 64 bits although both
intrinsics carry the value's Sema type: a u32 0xffffffff printed
`ffffffffffffffff` under :x and `-1` under :>12, a u8 200 under :b printed
64 binary digits. And with_fmt_int_spec negated i64::MIN in i64 (panic).

- rt_core: with_fmt_int128 / with_fmt_int128_spec / with_fmt_buf_write_
  int128_spec take the value as its two 64-bit words (no target's i128
  convention involved); u128_base_to_buf divides over four 32-bit limbs (no
  128-bit division helper); with_fmt_int_spec and the 128-bit forms share
  one body; a negative magnitude is ~x + 1, which cannot overflow.
- Codegen reads Sema's signedness from the FMT_SPEC / FMT_BUF_WRITE_FMT type
  id, zero-extends unsigned values, and routes 128-bit values to the int128
  formatters; the C backend does the same (debug_int_format_expr,
  int_spec_value_args) and declares the new functions.

A negative signed value under x/b/o keeps today's behavior (the spec shows
no example); only unambiguous cases changed.

Test: behav_1922_integer_format_full_width — failed on the previous
compiler (0, 0, …, ffffffffffffffff, -1, and the i64::MIN panic), passes
on stage1; the 49 existing formatting behavior/spec tests pass.
…lib from any directory

Frontend.frontend_resolve_module_rel and Resolve's strategy chain read
generated modules and lib/ modules relative to the working directory
("out/gen", "lib"), so a stage compiler (stage1 embeds neither the bundle
corpora nor out/gen) compiled a stdlib program only from its own tree's
root. Driven from a test's case directory — behav_debug_info_variables
building `use std.process` — stage1 failed "import module not found:
'std.re.defs'" (std.re is a bundle corpus the embedded stdlib leaves out).

A last strategy, resolve_own_tree_candidate, tries the compiler's own tree
(compiler.Runtime runtime_own_tree_root: the directory holding the `out`
its executable sits under, confirmed by lib/std) — its out/gen, then its
lib — after every existing strategy, so in-tree resolution is unchanged and
an installed release (no enclosing out/, embeds everything) never takes it.
…es itself in WITH_TEST_COMPILER

behav_debug_info_variables failed "FAILED [with ir]: rc=127" under a stage1
`with test`: pre_d_build_runner's p7_compiler_path guessed a binary under
out/ (with-stage2, release, bin/with-stage2, bin/with) and, in a tree that
had built only stage1, returned the last guess unchecked — a path that did
not exist. It could also silently test a different compiler than the one
running the test.

- run_test_process sets WITH_TEST_COMPILER to this compiler (argv[0], made
  absolute) for the test child and restores it after, as it does
  WITH_TEST_FILTER.
- p7_compiler_path takes WITH_TEST_COMPILER first; run by hand with no
  compiler to find, it says so and stops instead of running a missing path.
- behav_action_capability_process hard-coded ../../../../out/release/bin/
  with as the process its action runs; it runs the compiler under test.

Red first: both tests failed on the previous stage1 (rc=127; the process
action's assert(result.rc == 0)); both pass on stage1 now.
…'s first build reuses a runner another project already compiled

Every project compiled its own native build runner into
out/.build-state/build-runner on its first `with build` (12–16 s on a stage
compiler), even when its key — the build sources' content, the compiler,
with.toml; never a path — matched a runner already compiled elsewhere: a
fresh `with init` project, or each case directory a behavior test builds
(behav_action_binary_read_errors did 16 builds from two distinct build.w
sources and outlasted the test runner's 120 s limit).

build_runner_ensure now looks in a machine-wide store
($WITH_BUILD_RUNNER_DIR, else ~/.local/with-build-runners, one file per
sha256 of the key, beside a .key file that must equal the key) before
compiling, and publishes what it compiles there. Copies go through a
temporary and a rename, binary before key, so a concurrent build never runs
a half-written runner.

Verified: with an empty store, the binary-read tests compiled two runners
(one per distinct build.w) and every other case took the stored copy.
…es split by strictness

behav_return_temporary_cleanup compiled the same program thirty times
(`with run --debug-alloc src/main.w <mode>`) and outlasted the test
runner's 120 s limit on a stage compiler (128 s): it builds once and runs
that binary per mode with WITH_DEBUG_ALLOC=1 (what --debug-alloc sets),
still asserting "debug-alloc: leak count=0" for every mode — 16 s.

behav_action_binary_read_errors ran 16 genuinely different builds in one
file (127 s): its cases move to test/behavior/lib/binary_read_cases.w, and
the plain-effects and --strict-effects halves are two files (73 s, 95 s on
stage1).
… test pool and reports every failure

Explicit files ran one after another in-process (run_test_command →
run_test_target), and the first failing file ended the run: a set of tests
took the sum of their times and hid every failure after the first — so
checking a change against 136 tests took over an hour serially.

Two or more files (directories expanded) now run as a build.w test lane
does: build_graph_run_test_files_pool, a worker per core, a sliding window,
passes cached machine-wide, every failure listed. Each worker is this
compiler's `with test <file>` with the user's options passed through. The
pool gains an echo mode for the command line — workers run without a forced
--quiet and each file's output is printed as it finishes (a lane stays
quiet); one file still runs in-process, so -v and --keep-binary keep their
single-file behavior. The pool's messages no longer say "build.w" (the
command line uses it too). run_test_target had no callers left and is gone.

Verified: 138 files in one command, 273 s wall, both deliberately failing
files reported among the failures (before: the serial run stopped at the
first); behav_cli_test_command_args (per-file output on stdout) passes.
…omptime evaluator)

behav_action_absolute_paths ran ten distinct builds in one file (114 s on
stage1, past the test runner's 120 s limit under load). The cases move to
test/behavior/lib/absolute_path_cases.w; the native and comptime halves are
two files.
…four builds a file)

The --strict-effects half (eight comptime-evaluated builds, 95 s on stage1)
timed out at the test runner's 120 s limit in a full parallel run. Each of
the four files now runs one method under one strictness.
@ehartford
ehartford marked this pull request as ready for review September 30, 2026 07:59
@ehartford
ehartford merged commit 55d094b into main Sep 30, 2026
@ehartford
ehartford deleted the fix-int-fmt branch September 30, 2026 08:00
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…ves compiler-producing actions across worktrees (#1899)

A green belongs to the sources, not to the worktree (D49/D50); so does a
built artifact. Once an action that names its compiler (stage compiles,
runtime and bridge objects, .wo bundles, producer stamps) has run, its
declared outputs, state record and effect log are published under
$WITH_BUILD_CACHE_DIR (default ~/.local/with-build-cache; "none"
disables it), keyed on the local signature (the producing seed or stage
compiler, the action code, the compiler sources, with.toml), the content
of every declared input, the compiler= binary's identity and the driver's
own digest, so nothing is served across seeds or drivers. A worktree whose
freshness check misses restores the entry into its own out/ and
re-verifies it with the same check: a hit is exactly a fresh target, or
it is discarded and the target runs. The store keeps the 96
least-recently-used entries (WITH_BUILD_CACHE_KEEP).

What made a key worktree-specific, each found by a second worktree that
missed: directory fingerprints and the compiler-source hash named files
absolutely, and so did the action-code hash (the module closure's paths),
now all root-relative; records and effect logs are stored with <root> and
the restore re-pins the record's effects hash to the localized log; and
stage1 declared the seed-built out/bin/with-sha256 binary as an input,
whose bytes differ per worktree (its debug map names the worktree in
N_SO/N_OSO, so LC_UUID and the code signature differ) — stage1 now keys
on tools/with-sha256.w, what that binary is made from (the dep still
orders the build).

Proof (two fresh worktrees on one commit, a stage1 of this tree driving,
one store): the second `:dev` restored 25 entries, stage1 included, none
failed verification; with one byte changed in src/Lexer.w, stage1 was not
restored and rebuilt. Not yet seconds: 39 targets outside the store's
scope still run per worktree (SDK and sysroot packing, the empty
placeholder objects), and the pinned seed carries none of this until the
next seed, so seed-driven batteries see it then. The test verdicts and
build runners were already machine-wide (#1909, #1929).
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…ves compiler-producing actions across worktrees (#1899)

A green belongs to the sources, not to the worktree (D49/D50); so does a
built artifact. Once an action that names its compiler (stage compiles,
runtime and bridge objects, .wo bundles, producer stamps) has run, its
declared outputs, state record and effect log are published under
$WITH_BUILD_CACHE_DIR (default ~/.local/with-build-cache; "none"
disables it), keyed on the local signature (the producing seed or stage
compiler, the action code, the compiler sources, with.toml), the content
of every declared input, the compiler= binary's identity and the driver's
own digest, so nothing is served across seeds or drivers. A worktree whose
freshness check misses restores the entry into its own out/ and
re-verifies it with the same check: a hit is exactly a fresh target, or
it is discarded and the target runs. The store keeps the 96
least-recently-used entries (WITH_BUILD_CACHE_KEEP).

What made a key worktree-specific, each found by a second worktree that
missed: directory fingerprints and the compiler-source hash named files
absolutely, and so did the action-code hash (the module closure's paths),
now all root-relative; records and effect logs are stored with <root> and
the restore re-pins the record's effects hash to the localized log; and
stage1 declared the seed-built out/bin/with-sha256 binary as an input,
whose bytes differ per worktree (its debug map names the worktree in
N_SO/N_OSO, so LC_UUID and the code signature differ) — stage1 now keys
on tools/with-sha256.w, what that binary is made from (the dep still
orders the build).

Proof (two fresh worktrees on one commit, a stage1 of this tree driving,
one store): the second `:dev` restored 25 entries, stage1 included, none
failed verification; with one byte changed in src/Lexer.w, stage1 was not
restored and rebuilt. Not yet seconds: 39 targets outside the store's
scope still run per worktree (SDK and sysroot packing, the empty
placeholder objects), and the pinned seed carries none of this until the
next seed, so seed-driven batteries see it then. The test verdicts and
build runners were already machine-wide (#1909, #1929).
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…ves compiler-producing actions across worktrees (#1899)

A green belongs to the sources, not to the worktree (D49/D50); so does a
built artifact. Once an action that names its compiler (stage compiles,
runtime and bridge objects, .wo bundles, producer stamps) has run, its
declared outputs, state record and effect log are published under
$WITH_BUILD_CACHE_DIR (default ~/.local/with-build-cache; "none"
disables it), keyed on the local signature (the producing seed or stage
compiler, the action code, the compiler sources, with.toml), the content
of every declared input, the compiler= binary's identity and the driver's
own digest, so nothing is served across seeds or drivers. A worktree whose
freshness check misses restores the entry into its own out/ and
re-verifies it with the same check: a hit is exactly a fresh target, or
it is discarded and the target runs. The store keeps the 96
least-recently-used entries (WITH_BUILD_CACHE_KEEP).

What made a key worktree-specific, each found by a second worktree that
missed: directory fingerprints and the compiler-source hash named files
absolutely, and so did the action-code hash (the module closure's paths),
now all root-relative; records and effect logs are stored with <root> and
the restore re-pins the record's effects hash to the localized log; and
stage1 declared the seed-built out/bin/with-sha256 binary as an input,
whose bytes differ per worktree (its debug map names the worktree in
N_SO/N_OSO, so LC_UUID and the code signature differ) — stage1 now keys
on tools/with-sha256.w, what that binary is made from (the dep still
orders the build).

Proof (two fresh worktrees on one commit, a stage1 of this tree driving,
one store): the second `:dev` restored 25 entries, stage1 included, none
failed verification; with one byte changed in src/Lexer.w, stage1 was not
restored and rebuilt. Not yet seconds: 39 targets outside the store's
scope still run per worktree (SDK and sysroot packing, the empty
placeholder objects), and the pinned seed carries none of this until the
next seed, so seed-driven batteries see it then. The test verdicts and
build runners were already machine-wide (#1909, #1929).
ehartford added a commit that referenced this pull request Oct 3, 2026
…ty (#1899 #1906 #1905 #1865 #1835 #1888 #1900 #1998 #2000) (#2008)

* Build: a machine-wide build store under ~/.local/with-build-cache serves compiler-producing actions across worktrees (#1899)

A green belongs to the sources, not to the worktree (D49/D50); so does a
built artifact. Once an action that names its compiler (stage compiles,
runtime and bridge objects, .wo bundles, producer stamps) has run, its
declared outputs, state record and effect log are published under
$WITH_BUILD_CACHE_DIR (default ~/.local/with-build-cache; "none"
disables it), keyed on the local signature (the producing seed or stage
compiler, the action code, the compiler sources, with.toml), the content
of every declared input, the compiler= binary's identity and the driver's
own digest, so nothing is served across seeds or drivers. A worktree whose
freshness check misses restores the entry into its own out/ and
re-verifies it with the same check: a hit is exactly a fresh target, or
it is discarded and the target runs. The store keeps the 96
least-recently-used entries (WITH_BUILD_CACHE_KEEP).

What made a key worktree-specific, each found by a second worktree that
missed: directory fingerprints and the compiler-source hash named files
absolutely, and so did the action-code hash (the module closure's paths),
now all root-relative; records and effect logs are stored with <root> and
the restore re-pins the record's effects hash to the localized log; and
stage1 declared the seed-built out/bin/with-sha256 binary as an input,
whose bytes differ per worktree (its debug map names the worktree in
N_SO/N_OSO, so LC_UUID and the code signature differ) — stage1 now keys
on tools/with-sha256.w, what that binary is made from (the dep still
orders the build).

Proof (two fresh worktrees on one commit, a stage1 of this tree driving,
one store): the second `:dev` restored 25 entries, stage1 included, none
failed verification; with one byte changed in src/Lexer.w, stage1 was not
restored and rebuilt. Not yet seconds: 39 targets outside the store's
scope still run per worktree (SDK and sysroot packing, the empty
placeholder objects), and the pinned seed carries none of this until the
next seed, so seed-driven batteries see it then. The test verdicts and
build runners were already machine-wide (#1909, #1929).

* Build: the action runner links against a runtime root the driver names, of the driver's own generation (#1906)

Cause: the scheduler compiled the runner as soon as
prepare-bootstrap-link-root had completed in the run, executed or fresh,
and linked it under WITH_OUT_DIR, so the link probed out/lib first. The
prepare's freshness says nothing about out/lib: the stage chain re-creates
it (tree generation) after the prepare last ran, and a seed whose Link.w
lacked the per-candidate generation check (nightly-20260927, before
030293c) linked the tree's runtime into its runner: rt_compat_setenv_str
read an address as a length.

Reproduced on the pinned seed (c95ae12, which carries 030293c) in a
fresh worktree: out/lib a stage1 runtime set (.producer 91b9f004...),
out/bootstrap-lib the seed's (22a6c48c...), prepare fresh, runner store
empty: the runner compiled and ran. That seed's link skips the foreign
candidate, so the crash does not recur under it; the safety lived only in
the link's probe, and the driver still decided on the prepare's
freshness. The tool that should have refused stayed silent.

Fix: build_runner_link_root picks the first complete runtime directory of
the driver's generation (out/bootstrap-lib for the seed, out/lib for a
tree compiler) and the runner compile names it as WITH_RUNTIME_ROOT,
which Link.w refuses outright when its .producer is another generation
and never trades for a probed directory. The runner is compiled when such
a root exists, or when the prepare is done and the project has no runtime
directory at all (it links from the embedded runtime, as before); a
project whose only runtime is foreign says so instead of linking.

* Build: `--no-deps` runs an action in the native runner when a link root of the driver's generation exists, and refuses naming the dep when none does (#1835)

Cause: with --no-deps, prepare-bootstrap-link-root is not in the graph,
so the scheduler fell back to "no runtime directory belongs to another
generation". After a full build out/lib is the tree's generation, so
under the pinned seed that was false, the runner was never compiled, and
the action evaluated in the seed's comptime evaluator, which predates
7aed70f (generic calls without type arguments read Sema's
specialization) and failed after the smoke itself passed.

Failing first, pinned seed, fresh worktree, out/lib foreign, out/bootstrap-lib
the seed's own (.producer 22a6c48c...): `:embedded-clang-resource-source`
linked the runner and ran in 0.1 s; the same target with --no-deps
compiled no runner and ran 25.8 s in the comptime evaluator.

Fix: the runner decision is build_runner_link_root's (#1906): --no-deps
uses the seed's out/bootstrap-lib like any other run. When no root of the
driver's generation exists, --no-deps refuses, naming
prepare-bootstrap-link-root as the dependency it skipped, instead of
silently changing evaluators; a full run says once that actions evaluate
at comptime until the prepare builds the root.

* deps/seed: release discovery searches every page and says why it found nothing (#1888)

Cause: seed_release_from_api read one page of
`/releases?per_page=10` and returned "" for a miss. Every nightly
seed and SDK publish adds a release on top, so a platform's newest SDK
falls off that page within days: when #1888 was filed the darwin-aarch64
SDK (nightly-sdk-20260928-3ae5c9ec0b31) sat under more than ten newer
releases; today it is 9th, and the windows-aarch64 SDK is 17th, so
unpinned `:deps` on that host fails now. The miss said nothing about
whether the request failed, the response was malformed, or no release
carried the asset, and the response file was deleted.

Fix: the lookup walks the pages (100 releases each, at most 10 pages),
newest first, and reads the body as one text (each release's assets
follow its tag_name; an asset matches only as an exact quoted name, so
the .sha256 sidecar and a release body never do). It returns the tag or
the reason, keeps each response at out/tmp/seed-download/releases-<n>.json,
and both callers' errors name that reason.

Evidence (the real function through a temporary probe target, pinned
seed, reverted): windows-aarch64 -> nightly-20260907-34132069721-1-8a729db8d01f
(17th, beyond the old page); darwin-aarch64 -> nightly-sdk-20260928-3ae5c9ec0b31;
an absent asset -> "none of the 89 newest releases of withlang-dev/with
carries it (responses kept under out/tmp/seed-download)".

* test: the D acceptance corpus runs as the std fallback tier will resolve it (`:d-acceptance-tests`), import-free as D29 keeps it; the debug-alloc lane checks expect-stdout exactly (#1865)

test/d_acceptance (D29, #750): the import-free originals of the behavior
tests the §18.1 scaffolding gave explicit `use` lines, forked "not
overwriting" into a suite quarantined until D activation (#752)
un-quarantines it as the activation test. No lane compiled it, so it rotted
silently, and #1970 then inserted 183 explicit std imports into 166 of its
files (a mechanical §18.1 sweep that did not know the corpus's purpose),
which would make the activation test vacuous.

- The 183 `use` lines #1970 inserted are removed (exactly those lines; the
  eight files whose originals carried a `use std.` keep it). #1970's D71
  `xs[i]` respellings stay: a ruling moved that spelling.
- Respellings later rulings gave the behavior originals, mirrored into the
  forks: D32 field moves (behav_drop_tuple_field_extract,
  behav_mut_self_vec_owner_receiver: explicit `move` from a `var` base;
  behav_rc_arc_basic: `.clone()`), §4.2.6 narrowing (duck_method_ok:
  `-> i64`). Each now equals its behavior original minus imports.
- Deleted: behav_byvalue_view_escape_{nested,tail}. They pin the retired
  D5 share-place reading (a consuming T as the caller's place, escaping
  views valid); 2fdfbb9 (#718) turned their behavior originals into the
  negative fixtures err_consuming_param_{,nested_}view_escape.w.
- `:d-acceptance-tests` (in `:test`; build/acceptance.w): a copy under
  out/d-acceptance/corpus gains exactly the `use` lines the compiler's
  unique-match fix-it names, applied by tools/insert_std_uses.w (the tool
  the scaffolding used) to a fixpoint, and every file then runs under the
  exact-stdout runner. The tree's corpus stays import-free; at activation
  the fix-it step goes.

Census before (installed compiler, `check` per file): 14 of 181 red — 4
needing only `write`'s import (the fix-it's job), 3 D32, 2 retired D5,
1 §4.2.6, 4 issue59/61 fixtures whose helper modules live in
test/behavior/lib (the lane copies it beside the corpus).

tools/debug_drop.w `check` now also compares the program's stdout, from
the run under the debug allocator, with the fixture's `//! expect-stdout:`
lines: every line, in order, once each (#1855's runner rule). Failing
first: with one expected line changed, and with one dropped, the old
tool passes both (`debug-alloc lane: ok`); the new one fails each naming
the first difference. All 145 fixtures pass it. The tool also drops the
internal with_exec_*/with_fs_* externs (#901) for std.process
run_to_files and std.fs; its per-process capture paths are #2004's (PR #2005).

The lane's first run then named 11 more forks #1855 (c4a2863) had left
stale: it rewrote their behavior originals' expectation headers for the
exact-stdout rule (`expect-run-output:` -> `expect-stdout:` lines, subset
lists completed, a stray "\n" that printed a blank line dropped), and the
forks still pinned the old text. Each is re-derived as its behavior
original minus the scaffolding's `use` lines (a `use` the fork carried is
kept). `:d-acceptance-tests`: 179 files ok.

* Corpora are their migrator's output again, and `:corpus-drift-check` (in the gate) fails when they are not (#1905)

Cause: the checked-in corpora are generated (build/corpora.w: promotion
copies the migration; never hand-edited), but nothing compared them with
what this tree's migrator produces: the battery compiles the checked-in
output, and `<stem>-check-generated` runs only on a deliberate
re-migration. Two migrator changes landed without a re-promotion and the
drift was silent:
- D75 (173d8aa): a variadic definition spells `va_start()`; pcre2test.w
  and zl/gzwrite.w still called the retired with_va_start/with_va_end.
- #1933 (bfa0201): the migrator's own helpers take `__with_`-prefixed
  parameters, so a C global named `c` no longer makes them a refused
  shadow; every corpus's defs.w still had `c`.
(c_algorithms/binary_heap.w no longer differs.)

`<stem>-drift-check` (one per corpus, grouped as `corpus-drift-check` and
added to the gate's fixed list) runs the corpus's own stage, migrate and
finish hooks and writes its bundle root into a scratch tree — the migrate
action's steps, now shared as corpus_generate — with this tree's release
compiler as the migrator: an action carrying `migrator=<path>` runs
`<path> migrate` with exactly the workspace's option set
(corpus_migrate_argv), so the CLI and the workspace call
migrate_c_directory over the same settings. It then compares every
module byte for byte and fails naming each one that differs, is missing
or is extra, with the re-promotion command.

Failing first (`src/main build :corpus-drift-check` before the
re-promotion): pcre2 2 modules (defs.w, pcre2test.w), zlib 2 (defs.w,
gzwrite.w), c_algorithms 1 (defs.w), tommyds 1 (defs.w). Every hunk was
read: all are the two rules above, none changes behavior.

Re-promoted from the migrator's fresh output (exactly the six modules;
every corpus keeps its module count). After: corpus-drift-check green
("pcre2: 35 modules are the migrator's output", zlib 22, c_algorithms
24, tommyds 16); wo-drift, pcre2-wo-test, c-algorithms-test and
tommyds-test green over the re-promoted corpora.

* with get: a source build gets a CMake package config for every requirement, written from its recorded metadata as Conan's CMakeDeps would (#1900)

Cause: conan_install_from_source passes the installed requirements to
CMake only through CMAKE_PREFIX_PATH. A Conan Center binary package
carries no `<name>Config.cmake` (glfw/3.4's lib/cmake holds only
conan-official-glfw-targets.cmake): Conan's CMakeDeps generator writes it
at install time, and `with get` did not. So raylib/6.0, configured with
USE_EXTERNAL_GLFW=ON, failed at find_package(glfw3 3.4) whenever raylib
built from source while glfw came as a binary; every recipe that finds a
requirement by find_package(<Config>) has the same failure. (Under
`--from-source` the requirement is itself built from source and installs
its own config, which is why that path worked.)

Failing first (installed `with`, macOS arm64, fresh spiral project):
`WITH_GET_CMAKE_RAYLIB=SUPPORT_MODULE_RAUDIO=ON with get c.raylib` ->
glfw binary 71dfbca4fd16, then "Could not find a package configuration
file provided by "glfw3" (requested version 3.4)", rc 1.

Fix: for each resolved requirement without a config of its own,
`<file>Config.cmake` declares the recipe's target (cmake_file_name /
cmake_target_name read from the requirement's recipe, else CMakeDeps'
defaults: the package name, <name>::<name>) as an INTERFACE IMPORTED
target over the libraries, include directories, defines and link options
recorded in metadata.json, its requirements folded in; two-token Apple
flags stay one SHELL: option. `<file>ConfigVersion.cmake` answers the
version request (SameMajorVersion, CMakeDeps' default; a non-numeric
version such as "system" answers none). CMake finds it by -D<file>_DIR.
One metadata reader: ProjectConfig's, now public. No per-package table.

After (stage1 of this tree, same command): "-- Using external GLFW",
raylib/6.0 configures, builds and installs libraylib.a against the glfw
binary; the bundled rglfw is not compiled.

* stdlib-complexity times CPU, not the wall: std.libc cpu_time_ns over a with_libc seam, one body per backend; a quadratic control keeps the 6x bound honest (#1998)

Cause: test/complexity/stdlib.w timed each row with now_ns(), wall time.
On a loaded machine contention reads as super-linear growth, so a linear
row failed its 6x bound (#1998: trie 6.4x at load 36) and blocked a
battery for reasons unrelated to the change.

Failing first (the pre-change harness, ambient load ~50 from other
builds): 3 of 5 runs red, two on linear rows far outside the bound —
binary-heap 23x (0.43 ms -> 10.1 ms), trie 12x.

Fix: the harness times CPU — user + system of this process and of every
child it has reaped, so the stdin rows (whose work is a child process)
still count their work and nothing else on the machine does.
- std.libc cpu_time_ns(): a With function over the with_libc_cpu_time_ns
  seam in rt/rt_core.w (the category std.libc's rule names; POSIX
  getrusage itself may not be exported, and C's clock() leaves children
  out and on the UCRT counts wall time). rt_cpu_time_ns, one body per
  backend: getrusage(RUSAGE_SELF) + getrusage(RUSAGE_CHILDREN) on darwin
  and linux (each with its timeval layout); GetProcessTimes on Windows,
  each child's kernel + user time summed at every reap site as
  RUSAGE_CHILDREN does (GetProcessTimes gets its win32 facade row); 0 on
  wasm, which the harness's positive-duration assertion refuses.
- The harness declares the seam itself for now: importing std.libc into
  this file trips a Sema internal error in std/collections/sorted_vec.w
  (#2000, filed with the repro); it switches to `use std.libc.cpu_time_ns`
  when that is fixed.
- The 6x bound is kept. A `quadratic-control` row (each step scans all
  prior pushes) must miss it, or the run fails: the clock still sees
  super-linear growth on every run, not only in this commit's evidence.

After: `:stdlib-complexity` green; under 36 CPU hogs (load 49-60) the
harness passed 5 of 5 runs, every linear row inside the bound
(binary-heap ~4.6x, trie ~4x), the five XFAIL rows unchanged, and
quadratic-control outside it every time (16.5x in the lane run).
Every backend type-checks (`with check --no-prelude rt/<backend>.w`);
only darwin is run here.

* Sema: a generic instance is found by identity, never by the memo's absence; a comptime evaluation no longer duplicates Option[V] (#2000)

Cause (lldb + WITH_TRACE_INST on the reduced harness): the first check of
SortedVec[i32].index_of joined its `if` at Option[i32] (tid 1079). A
comptime evaluation (a `[x; N]` count; std.libc's import was only what
put one in the harness's order) runs on prepare_comptime_eval_copy, which
empties generic_inst_cache and writes the Sema back. preregister_mir_types
then read the memo's absence as "no Option[V] for HashMap[i32, i32] yet"
(Sema.w, `if not self.generic_inst_cache.contains(opt_key)`) and added a
second Option[i32] (tid 2225) under the same key. The re-check before MIR
lowering resolved `Option[i32]` through the memo to 2225 and met the
decision recorded at 1079: "conflicting contextual join decisions for one
expression". The same raw-memo read sat in SemaCheck's index-expression
instance lookup and MirLower.resolve_index_generic_inst, which also
trusted a bare hash hit as a type.

Fix: instance identity has one owner, find_generic_inst_type /
ensure_generic_inst_type (verify the memo hit, else scan); every
VecIter[T] / Option[V] / Vec[str] / VecIter[str] preregistration, the
index-expression lookup and the MirLower lookup go through it. The
internal error now names both decisions (sig, expected and final types
with their ids), so the next one says which types disagree.

Failing first: test/behavior/behav_2000_generic_inst_identity_after_comptime_eval.w
(a generic method joining at Option[i32], a `[0; 4]`, a HashMap[i32, i32])
reported the internal error on the unfixed stage1; it passes now, as do
the reduced harness and test/complexity/stdlib.w, which drops its #1998
workaround and imports std.libc.cpu_time_ns (harness run: all rows pass,
quadratic control outside the bound, rc 0).

* Build: the build store serves every cacheable target whose outputs are the same in every worktree; a second worktree's :dev is 9.7s, not 269s (#1899)

c558ec8 restored the 25 actions that name a compiler; a second worktree on
the same commit still ran 39 targets (268.7s :dev, release driver). Measured
in two fresh worktrees on one commit (driver = WITH = this tree's release
binary, as the next seed will be), what re-ran and why:

- Every runner action in a fresh worktree fell back to comptime evaluation
  (3.4s per empty placeholder, 38s compiler-no-c-export): the driver named
  out/bootstrap-lib as the runner's root because its rt_core.o matched the
  embedded one byte for byte, before bootstrap-runtime-producer had written
  its .producer, and Link.w then refused that named root for lacking one.
  One question, two answers: build_runner_link_root now asks the link's own
  test for a named root (link_stage_named_runtime_root_is_this_generation),
  and a runner already built for the key, here or in the machine-wide
  runner store, is used without any root (it links nothing).
- The store took only actions naming `compiler=`. It now takes every
  cacheable target (the local freshness contract: compiles, actions,
  generated sources, packs, placeholder objects) whose outputs and write
  scopes lie under out/, minus the always-run targets. The key hashes the
  signature with the worktree's root spelled <root> (an `llvm-prefix=<root>/
  .deps/...` arg is one argument everywhere); a restore re-pins the record's
  sig lines to this worktree's spelling, then verifies as before.
- An output that names its worktree is never stored, and the build says so
  ("[cache] X: not stored: ... names this worktree"): publishing it would
  hand another worktree this one's paths.
- darwin-sysroot depended on sysroot-zig-source, which extracts 279MB into
  .deps/src (outside out/, so no restore brings it) on every fresh worktree.
  It now fetches the pinned Zig source and libc++ ABI list into its own
  scratch and declares the tree every darwin link reads
  (out/gen/darwin-sysroot) as an output; pack and tree are byte-identical
  to the .deps-built ones.
- An embed target's assembly named its blobs by absolute path; it names
  them from the root (`.incbin "out/bootstrap-lib/rt_core.o"`) and the
  assembler reads a copy whose operands are resolved against the root.
- A restore forgets only the restored outputs' fingerprints, not the memo
  (src/ was re-hashed per stage-target restore).
- The store keeps 512 entries (a :dev publishes ~60, mostly small).

Numbers (same commit, fresh worktrees A then B, one store):
  before: A 342.2s, B 268.7s (39 ran), no-op 1.6s
  after:  A 334.5s, B 9.7s (59 restored, 4 ran), no-op 1.8s
B's 9.7s: ~4s evaluating build.w in a worktree with no graph cache (a
cached-graph run with every output deleted is 5.6s), ~1s hashing ~250MB of
restored outputs to verify them, the rest the four targets below.
Changed input (C: B's commit + one line in src/Lexer.w): 63.1s; ran stage1,
compiler-no-c-export and the two runtime-producer stamps (the targets whose
signature covers src/), restored the other 55.

Not storable, each named by the build when it runs:
- bootstrap-/stage1-llvm-link-metadata: llvm_link.rsp is an lld response
  file listing the SDK archives by absolute path (0.0s each; nothing stored
  keys on it);
- with-sha256: an Executable the driver compiles in-process, whose debug
  map names the worktree (no file-prefix map outside the stage actions);
- sdk-clang-main: adds clang's driver archive to the SDK in .deps, outside
  out/ (0.0s when present).

Failing first: test/behavior/behav_1899_build_store_serves_any_target.w
(an action naming no compiler is served to a second root; a changed input
misses; a root-naming output is not stored; a rooted arg is portable; an
embed's assembly carries no root) fails on the previous tree at the first
restore, passes now.

* Corpora: re-promote pcre2, zlib, c_algorithms and tommyds from this tree's migrator (#1905)

The drift check this stack adds found all four checked-in corpora stale
against the migrator on main: #1838 stopped emitting `-> Unit` on void C
functions and lowers a pure `(void)x` discard to nothing, and the D39
write contracts now print each function's `writes` clause. Nothing
re-promoted after those landed. Regenerated with
`WITH=out/release/bin/with out/release/bin/with build :<stem>-promote`,
each gated on the corpus's own tests (all four rc=0).

* Build: --no-deps refuses for a missing runner root only when it skipped the prepare that builds it (#1835)

The selfhost case build-w-evaluator-seed (`build :seed --no-deps` over a
foreign-generation out/lib) failed in the battery on c78e242 with
"--no-deps: ... `prepare-bootstrap-link-root` (a dependency of 'seed')
builds them and --no-deps skipped it". `seed` has no dependencies: the
refusal (src/main.w build_runner_explain_no_root, reached from the runner
check in run_build_graph) keyed on the --no-deps flag alone, so it named a
dependency that does not exist and refused a run that skipped nothing. The
same build without --no-deps evaluates at comptime and says so. It passed
on runs where the machine-wide runner store already held a runner for the
graph's key (build_runner_built), which links nothing and so never reached
the refusal.

run_build_command now computes what --no-deps skipped: the selected
target's full closure (build_graph_filter_target) containing
prepare-bootstrap-link-root. Only then does the run refuse; otherwise the
driver says actions evaluate in its comptime evaluator, as a full run does.

Verified with stage1 on a project with a foreign out/lib marker and an
empty runner store: `:x --no-deps` (x depends on the prepare) refuses
naming it; `:y --no-deps` (no dependency) evaluates at comptime; this
tree's `:seed --no-deps` prints "is the pinned seed" under the evaluator.

* Build: the build store never serves an action made from other reads; an entry is checked before it touches the outputs; WITH_BUILD_NO_EARLY_CUTOFF holds for the store (#1899)

The battery on c78e242 failed the four binary-read fixtures and
behav_build_early_cutoff, and cli-selfhost-build-w-tests on a second run.

Root cause (src/BuildGraphCache.w build_cache_store_key): the store key
hashes the signature, the driver, the compiler and the content of the
DECLARED inputs. An action's reads through ToolFs were recorded nowhere,
so the key and the record were the same for every project whose build.w
was the same, whatever the action read. binary_read_cases' action declares
no input and copies `input.bin`; its four kinds (missing, directory,
empty, binary) share one key. With an empty store, in one run: the empty
case published, and the binary case was served the empty output (fails at
binary_read_cases.w:39). Across runs the directory case was served a
success ("rc=0, expected a failure mentioning copy_file", store entry
9e5316c668ea, whose state has no in:/dep: line at all). The same gap holds
for the local state, which only hid behind each case's fresh root.

Fix: what an action reads through ToolFs is an input of its result.
- lib/std/build.w ToolFs.record_read (native runner) and
  ComptimeEvaluator.record_read_effect (evaluator, --strict-effects and the
  fallback) record every path an action reads, probes and listings
  included, outside its own write scope; build(ctx)'s reads (no write scope,
  or graph reconstruction with writes suppressed) are not the action's. The
  runner keeps one file per path beside its effect log (constant time per
  read); the driver reads them back (main.w build_runner_read_effects) and
  clears them before each run.
- build_cache_record turns `read` effects into `dep:` lines, fingerprinted
  like a compile's tracked inputs, so the local freshness check and a
  restored record both go stale when a read path's bytes, kind or absence
  differ.
- build_cache_store_restore checks the stored record's in:/dep:/env: lines
  against this worktree (build_cache_store_record_mismatch) BEFORE it
  replaces any output; an entry made from other reads is refused ("does not
  apply") and the target runs. It used to copy the outputs first and verify
  after, so a refused entry had already overwritten what was on disk.
- Failed actions were never stored (build_cache_record is reached only on
  success, in the runner, pool and evaluator paths), and still are not.

behav_build_early_cutoff:67: with WITH_BUILD_NO_EARLY_CUTOFF=1 `gen` ran,
and `use` (dependency rebuilt) was restored from the store entry step 3 had
published for the same input bytes. The escape hatch means "a dependency
ran, so rebuild"; main.w build_graph_early_cutoff_enabled now gates the
store restore of a target whose dependency ran, as it gates the cutoff.

Tests assert what their builds ran, and the machine-wide store serves a
target another run built from the same inputs (an action that prints,
served, prints nothing: the selfhost evaluator_print case failed that way
on a second run with the same compiler). The p7 harness gives each test
process a store of its own, emptied on first use; the selfhost cwd helpers
give each case one under the action's output; a test or case that names
WITH_BUILD_CACHE_DIR keeps it. These stores still serve within a test, so
the binary-read fixtures keep exercising the refusal. The selfhost
evaluator cases also get an empty runner store: a runner built for the same
graph links nothing and so ran `:seed` natively despite the foreign out/lib
marker, while the test's only check was the absence of "runner compiled";
they now also require the driver to say actions evaluate at comptime.

Failing first: test/behavior/behav_1899_build_store_undeclared_read.w (two
projects, one shared store, the same build.w reading different undeclared
bytes; a directory there must fail without its output being replaced; the
same bytes must be served; runner and evaluator) fails on c78e242's
release ("served another project's output: alpha"), passes on stage1. The
four binary-read fixtures, behav_build_early_cutoff and
behav_1899_build_store_serves_any_target pass on stage1.

---------

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