Skip to content

Build graph: one producer per output, checked at graph load (#2014); one-liners import modules (#2015) - #2018

Merged
ehartford merged 7 commits into
fix-2023from
fix-2014
Oct 3, 2026
Merged

ehartford merged 7 commits into
fix-2023from
fix-2014

Conversation

@ehartford

@ehartford ehartford commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2014. Fixes #2015. Does not address #2016 (see below).

#2014: two targets, one output

  • Root cause of the silence: build_graph_validate_outputs (src/BuildGraphDispatch.w) already refused a duplicate output, but run_build_graph ran it over the selected closure (build_graph_filter_target), and linux-sysroot / linux-sysroot-aarch64 were never in one closure. The build and run commands (src/main.w) now validate the whole loaded graph before selecting, and the error names every shared output and both declarers.
  • Surveyed today's darwin build.w with the stage1 driver; it found three collisions, all fixed:
    • linux-sysroot (off Linux, a placeholder writing an EMPTY pack) and linux-sysroot-<host arch> both owned the host-arch pack; linux_sysroot_target_name("aarch64") on macOS named the placeholder. linux-sysroot is now a Linux host's own only; off Linux every pack is linux-sysroot-<arch>.
    • sdk-package / sdk-cross-aarch64-package (source-built SDKs) and package-llvm-sdk-<host> (.deps repackaging) all wrote out/release/with-llvm-sdk-*. Source-built SDKs now package into out/sdk-release; the source-sdk action and sdk-release.yml read it there (release-only workflow: not exercised here).
    • bootstrap-c-emit-sources, emit-c-test, emit-c-roundtrip all wrote out/gen/wl_decls.h/wl_stubs.c; each now writes beside its own emitted C.
    • linux-x86_64 (and windows-x86_64): <name>-wo-install-* and <name>-wo-<host>-install-* installed into one store slot. A cross compiler for the host's own target now embeds the host bundle.
  • Test: cli-selfhost-build-w-tests shared_output (two actions, one output, build one of them: refused, neither runs). Fails on the seed (writer-a runs, rc 0), passes on stage1/release.
  • The check lives in the driver: it takes effect for the build itself at the next seed bump. Verified clean with a stage1 driver on darwin-aarch64 and linux-x86_64 (eric-5090). Windows and linux-aarch64 graphs not run.

#2015: one-liner use

  • Root cause: cli_build_synthetic_source (src/main.w) spliced -n/-p code into the body of for line in stdin.lines() { ... }, where use does not parse. A part's leading use declarations (read from its tokens) are now hoisted above the loop and blanked to spaces in the body, so diagnostics keep their line/column.
  • Tests: cli-selfhost-one-liner-tests -e/-n/-p with use, a use in its own part, user stays code, diagnostic after a hoisted use maps to <cli -n #1>:2:8. -n/-p fail on v0.15.3.0.

Not here: #2016

Its four items are defects in the #1899 build store's terms (PR #2008, draft, not on main), and its acceptance ("a second worktree's :dev re-runs none of them") needs that store. It belongs on a layer stacked on wave-build.

Evidence

Eric Hartford added 7 commits October 3, 2026 04:02
…tions above the per-line loop (#2015)

`with -n 'use std.time.now_ns; ...'` (and -p) spliced the `use` into the
body of `for line in stdin.lines() { ... }`, where a declaration does not
parse ("expected expression" at <cli -n #1>:1:1). cli_build_synthetic_source
now reads each part's leading `use` declarations from its tokens
(cli_leading_use_len: a name like `user` or a `use` in a string is never
one; a braced list may span lines), emits them before the loop, and blanks
them to spaces in the body so every later byte keeps its line and column
(the diagnostic mapping still reads the part's own text). -e already took
them: the program is top-level.

Tests (cli-selfhost-one-liner-tests): -e/-n/-p with `use`, a `use` in its
own -n part, `user` stays code, and a diagnostic after a hoisted `use`
maps to <cli -n #1>:2:8. The -n/-p cases fail on v0.15.3.0 with "expected
expression".
…ads, not only inside the selected closure (#2014)

build_graph_validate_outputs already refused a duplicate output, but
run_build_graph ran it over the selected graph (build_graph_filter_target's
closure), so linux-sysroot and linux-sysroot-aarch64, which both declare
out/gen/linux-sysroot-aarch64.pack on macOS, were never in one closure and
never refused. The build and run commands now validate the whole loaded
graph before selecting, and the error names both declarers:
"duplicate build.w output path: <path> is declared by both target 'a' and
target 'b'; every output has exactly one producing target".

Test: cli-selfhost-build-w-tests `shared_output` builds one of two actions
that declare one output; it must fail naming both, and run neither.
…host `linux-sysroot` placeholder (#2014)

Off Linux, `linux-sysroot` was a placeholder that wrote an EMPTY pack at
sdk_linux_sysroot_pack() = the host architecture's path, which
`linux-sysroot-<host arch>` also declared and filled: on macOS both owned
out/gen/linux-sysroot-aarch64.pack (on Windows x86_64,
out/gen/linux-sysroot.pack), so the pack depended on which ran last, and
linux_sysroot_target_name("aarch64") named the placeholder, so the darwin
cross linux-link-pack depended on the empty writer, not the real one.

`linux-sysroot` is now a Linux host's own sysroot only; every other
architecture's, and every one off Linux, is `linux-sysroot-<arch>`, named by
linux_sysroot_target_name in both the declaration and every dep. Off Linux,
the link metadata and the host linux-link-pack (which writes an empty pack
and reads no sysroot there) no longer depend on it, and
run_linux_sysroot_action no longer has an off-Linux empty branch.
…, not only the first (#2014)

Found surveying today's build.w with the check: one refusal per run hid
the next. Every collision is printed, then the load fails.
…se/<asset> has one producer (#2014)

The whole-graph output check (previous commit) refused today's build.w a
second time: `sdk-package` (the source-built SDK, the source-sdk action's
entry) and `package-llvm-sdk-<host>` (the runbook's repackaging of the
.deps SDK) both declared out/release/with-llvm-sdk-<ver>-<host>.tar.gz and
its .sha256/.manifest; on linux-x86_64 `sdk-cross-aarch64-package` and
`package-llvm-sdk-linux-aarch64` did too. Which archive a release carried
depended on which ran last.

package_llvm_sdk_platform_target takes its directory: the .deps
repackagers keep out/release (tools/release_local.w, the runbook), the
source-built ones write out/sdk-release, and run_package_llvm_sdk_action
writes beside its stamp, root-relative so the .sha256 sidecar still names
the archive relatively. The source-sdk action and sdk-release.yml read
out/sdk-release.
…ted C (#2014)

The whole-graph output check refused today's build.w a third time:
bootstrap-c-emit-sources, emit-c-test and emit-c-roundtrip each declared
out/gen/wl_decls.h and out/gen/wl_stubs.c, and each compile read whichever
target wrote them last. emitc_generate_stub_files now writes into the
emitted C's directory (out/bootstrap-c/src, out/emit-c-test,
out/emit-c-roundtrip) and every C compile and migrate includes
emitc_decls_beside(main_c); package-bootstrap-c copies the header from
out/bootstrap-c/src. With this, the stage1 driver loads today's build.w
on darwin with no shared output.
…undles; one store slot, one installer (#2014)

The whole-graph output check, run on linux-x86_64, refused every corpus
bundle: `<name>-wo-install-{o,wi,manifest}` (the host plan) and
`<name>-wo-linux-x86_64-install-*` (the cross plan for the cross-rt
compiler, the same target) both installed into
<store>/<name>/linux_x86_64-<abi>/; windows-x86_64 has the same pair.
cross_wo_plan now returns the host plan for the host's own tag, and
cross_wo_bundle_targets registers no second build or install for it: the
cross compiler embeds and links the host bundle (out/wo/<name>, built from
the same corpus at the same ABI, D38).
@ehartford
ehartford changed the base branch from main to fix-2023 October 3, 2026 11:27
@ehartford
ehartford added this pull request to stack #2032 October 3, 2026 11:27
@ehartford
ehartford marked this pull request as ready for review October 3, 2026 15:13
@ehartford
ehartford merged commit 03eadeb into main Oct 3, 2026
@ehartford
ehartford deleted the fix-2014 branch October 3, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant