Skip to content

Build: keep build-driver files seed-compatible (str-index revert) + hash action text via ToolFs.sha256_file - #956

Closed
ropoctl wants to merge 2 commits into
mainfrom
fix-comptime-sha256-text
Closed

ropoctl wants to merge 2 commits into
mainfrom
fix-comptime-sha256-text

Conversation

@ropoctl

@ropoctl ropoctl commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

withlang-dev/main is red on the self-host lanes. Two independent build-graph
bugs, both hit before any test runs — the pinned-seed lanes (linux x86_64,
windows x86_64/aarch64) die first at graph materialization (~2s in); the
newer-seed lanes (linux aarch64) then fail at the .wo build step.

Root cause

1. Comptime str indexing in build-driver files (bootstrap-ordering violation).
0173d08e ("least-ceremony sweep, build-driver files") rewrote
str.byte_at(i) → s[i] across build.w, build/*.w, and lib/std/build.w
(232 sites). Those files are comptime-evaluated by the pinned seed compiler
when with build materializes the build graph — before any stage
compilation. Comptime str indexing is a compiler feature newer than the
pinned seed
(v0.15.1.3): it rejects s[i] with comptime index requires an array, tuple, or vec, so those lanes never reach stage compilation.

2. Raw-pointer sha256 at comptime (kind-26). Once the graph materializes,
pcre2-wo-build / the .wo action-hash step fails with expression kind 26 is not comptime-evaluable yet — the &raw mut raw-pointer path in
sha256_hash_str.

Fix

Two commits, each a single logical change, both keeping the build graph
comptime-legal against the already-tagged pinned seed:

  1. Revert the str.byte_at(i) → s[i] sweep for build-driver files only
    (exact content inverse of 0173d08e; 232 insertions / 232 deletions across
    the same 19 files). The later .get(i) → v[i] Vec sweep is untouched —
    Vec indexing is supported by the pinned seed; only str indexing is not.
  2. Hash in-memory action text via ToolFs.sha256_file, not the raw-pointer
    sha256_hash_str
    — routes the .wo action-hash through a comptime-legal
    path.

No compiler/stdlib source is touched — this changes only comptime-evaluated
build-graph code, so it cannot affect stage codegen or fixpoint determinism.

Verification

From the CI-pinned v0.15.1.3 seed on linux x86_64, clean (rm -rf out) build:

  • with build → green, all targets (pristine main head dies at ~2s
    materialization with comptime index requires an array, tuple, or vec).
  • with build :fixpoint → stage2 == stage3 byte-identical (27 targets,
    stage2/stage3 built fresh).

Bootstrappable from the already-tagged v0.15.1.3 seed; no new seed required.
Base rung of the stack that greens every self-host lane.

@ropoctl

ropoctl commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

CI classification — this PR's scope vs pre-existing reds

This PR is one logical change: it makes the .wo build-graph hash helper
(wo_sha256_text in build/wo.w, and the interface-sha check in build/selfhost.w)
comptime-evaluable. with build runs build-action bodies under the seed's comptime
evaluator, which serves ToolFs.sha256_file but not the raw-pointer
sha256_hash_str (&raw mut digest[0] as *mut u8 — NK_UNARY, AST kind 26; the
evaluator does not model raw pointers into a mutable stack buffer). Every lane was
failing at that comptime eval on :pcre2-wo-build / :bundle-interface-tests. The
fix stages the bytes into the action's project-relative scratch dir and hashes the
file — byte-identical to hashing the string, and legal under comptime.

Verified locally: :pcre2-wo-build and :bundle-interface-tests both pass; full
with build + :fixpoint green.

Result per lane

  • linux aarch64 — SUCCESS. This PR flips it from red (kind-26 build wall) to green.
  • linux x86_64, windows x86_64, windows aarch64 — Build + Fixpoint now PASS
    (kind-26 wall cleared). The remaining "Green battery" failures are pre-existing,
    not regressions from this PR
    (evidence below).
  • macOS arm64 — fails ~9s on the missing darwin LLVM SDK asset lookup (release
    infra skew, not code; affects all PRs).

The remaining battery failures are pre-existing and outside this PR's diff

This PR changes only build/wo.w and build/selfhost.w (the hash helper). It does
not touch any linker input, migrated corpus, or the migrator.

  1. pcre2-wo-drift (linux/windows x86_64) — the drift target builds the harness
    lib/std/re/pcre2test.w with the local compiler (no --link-bundle), and the link
    fails:
    ld.lld: error: undefined symbol: __stderrp
    ld.lld: error: undefined symbol: __stdoutp
    ld.lld: error: undefined symbol: __stdinp
        referenced by pcre2test.w → out/wo-drift/pcre2/pcre2test.o
    
    __stderrp/__stdoutp/__stdinp are the Darwin stdio globals. pcre2test.w
    is a Darwin-migrated artifact (91 refs) — it links on darwin-arm64 but is undefined
    on linux/glibc (streams are stderr/stdout/stdin). lib/std/libc.w documents
    the invariant: migrated output is target-specific, "only the target's set is ever
    referenced." The run_wo_drift_action target and the 91 Darwin refs are both
    already present on this PR's base (54651442) — the failure was simply unreachable
    before, behind the kind-26 build wall. This is migrator/artifact portability
    (task use Sema from Lsp.w causes cascading false TypeId type errors #57 / migrate: preamble declares with_alloc/free/memcpy family as *i8, diverging from the rt defs (*mut u8) #880), not this hash change. wo_sha256_text is never on the drift
    harness-build path.
  2. c-migrator-core-tests (linux x86_64) — missing expected output for paste_suffix_intmax_max_literal. This is the paste-suffix migrator promoted by
    migrate: fold c ## L paste macros (INTMAX_C, UINTMAX_C, …) to typed literals so INTMAX_MAX/INTMAX_MIN/PTRDIFF_MIN/MAX become data #945 (this PR's base commit itself); C-migrator domain, not this change.
  3. windows behav_project_overflow_modes (p7 harness) and bundle-interface-tests
    emitted-wi content
    — pre-existing windows OS-surface / windows-only failures
    tracked separately.

Net: this PR is the correct, scoped kind-26 fix that unblocks the build wall on all
five lanes and greens linux-aarch64. The other reds are separate, pre-existing bugs
owned by their respective areas.

@ropoctl
ropoctl force-pushed the fix-comptime-sha256-text branch 3 times, most recently from ce445e7 to 6d3e622 Compare September 4, 2026 09:10
@ropoctl ropoctl changed the title Build: hash in-memory action text via ToolFs.sha256_file, not raw-pointer sha256_hash_str Build: keep build-driver files seed-compatible (str-index revert) + hash action text via ToolFs.sha256_file Sep 4, 2026
…ndex sweep)

0173d08 rewrote str.byte_at(i) -> s[i] across build.w, build/*.w, and
lib/std/build.w (256 sites). These files are comptime-evaluated by the
pinned seed compiler when `with build` materializes the build graph,
before any stage compilation runs. Comptime `str` indexing is a compiler
feature newer than the pinned seed (v0.15.1.3, and also v0.15.1.7): the
seed fails graph materialization with "comptime index requires an array,
tuple, or vec", breaking the very first build step on every self-host
lane (linux x86_64/aarch64, windows x86_64/aarch64, macOS arm64).

Per the bootstrap-ordering invariant, build-driver code reached at
comptime must not use a language feature the pinned seed lacks. Revert
the sweep for these files only; it can re-land once a released seed
supports comptime `str` indexing. The compiler-source commits stacked on
top (9dc3c43 HashMap `[k]` diagnostic, b9e0e65 retire Vec.set_i32) are
unaffected: they change stage-compiled source, not comptime build-graph
code.
…nter sha256_hash_str

The pcre2 `.wo` bundle build and the bundle-interface self-host test both
hashed in-memory strings with `sha256_hash_str(text, &raw mut digest[0] as
*mut u8)`. That `&raw mut` (NK_UNARY, AST kind 26) takes a raw pointer into a
mutable stack buffer, which the comptime build-graph evaluator does not model
— the seed drives `with build` under the comptime evaluator, so evaluating
those action bodies fails with "expression kind 26 is not comptime-evaluable
yet", reddening `pcre2-wo-build` (part of `with build`) and
`bundle-interface-tests` on every lane.

The comptime evaluator serves `ToolFs.sha256_file` natively. So hash through
it instead:

- build/wo.w: `wo_sha256_text(fs, text)` stages the bytes into the action's
  own project-relative scratch dir (`fs.scratch_dir()`) and hashes the file —
  byte-identical to hashing the string. A store slot can live outside the
  project root, so its callers `host_read_text` the file and hand the bytes
  here rather than `sha256_file` an out-of-root path (the comptime
  project-relative guard would reject it). All six call sites thread `fs`.
- build/selfhost.w: the interface-sha assertion hashes the emitted `.wi`,
  which is already a project-relative file, so `ctx.fs().sha256_file(wi_path)`
  directly. Drops the raw-pointer helper and its `std.crypto.sha256` import.

Both are byte-identical to the previous hashes: `sha256_file(p)` equals
`sha256(read_text(p))` for a text file, and each `.wo` manifest field is
written and validated through the same helper, so they stay self-consistent.

Verified on linux-x86_64: `with build :pcre2-wo-build` and
`with build :bundle-interface-tests` both green (were the two failing targets).
@ropoctl
ropoctl force-pushed the fix-comptime-sha256-text branch from 6d3e622 to 3951069 Compare September 4, 2026 11:04
@ehartford ehartford closed this Sep 4, 2026
@ehartford

Copy link
Copy Markdown
Contributor

not reverting str index sweep.
I am currently fixing the build.

@ehartford

Copy link
Copy Markdown
Contributor

(this PR throws out the baby with the bathwater)

@ehartford ehartford reopened this Sep 4, 2026
@ehartford

Copy link
Copy Markdown
Contributor

I will rebase this to main after my fix is in

@ehartford

Copy link
Copy Markdown
Contributor

Split and superseded. The useful half — hashing the in-memory .wo action text via ToolFs.sha256_file instead of the raw-pointer sha256_hash_str — landed on main as 888d1f0, and it is what let the v0.15.1.8-seed comptime evaluator build the .wo bundle (part of the v0.15.1.10+ seed chain). The other half (reverting the build-driver str[i] sweep) is declined per Eric's ruling: the least-ceremony surface stays; the seed is re-cut to match the tree, not the tree reverted to appease an old seed. Closing.

@ehartford ehartford closed this Sep 6, 2026
@ehartford
ehartford deleted the fix-comptime-sha256-text branch September 24, 2026 16:56
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.

2 participants