wcc,ww: flip driver to separate-compilation only; delete build_one amalgamator (M4 E3-C1, #22)

build_one_sep (per-package compile + .wwi interfaces + link) becomes the
sole build path. do_build/do_run/do_test and the ww twins all route
through it; --sep is now an accepted no-op and the run-rejects-sep guard
is removed.

Deleted the single-file amalgamator, both stages: build_one, expand,
expand_dir, peek_package (+ the wwstage twins + strictpkgmismatch).
unit_has_package is retained -- the sep scan loop's inline-package check
needs it. The sep-shared helpers (enumerate_dir_ww, locate_import*,
import_path_form, ImportSet, and ww counterparts) stay; they back the
surviving sep path.

Restores missing-package enforcement under sep by construction: the sep
scan loop loudly rejects an unresolvable import (cannot find package
<name>) unless the package is defined inline in the same unit -- matching
the deleted amalgamator and closing the silent-accept the flip would
otherwise introduce.

All 5 wwstage tools relink (each is built via the now-sep `ww build`);
emitted asm is byte-identical to the combined build per bootstrap input,
so the binary md5 delta is pure link layout, not codegen.

selfhost/cmd/ww/main.combined.ww is now stale and unregenerable (its
writer build_one is deleted); #90 deletes it next.

Test retargets folded in (rule-11 carve-out, #61/#133 precedent): each
asserts post-flip-only behavior, is un-pre-migratable unlike #93/#94/#103,
and splitting reddens one side. Closes #97.
- 989_slttypepref -> dir-package layout (xb imports xa so both same-leaf
  `invalid` types are in scope at xb.f); inline-multipackage was the
  amalgamator shape, deleted with the flip.
- 989_sepbuild_run -> run --sep now genuinely runs (exit 7), not the old
  loud-reject (exit 2); + a private per-pid WW_PKGCACHE so the cs/ww
  per-package byte-id compare on the shared real lib pkgs (rt/time/os) no
  longer races concurrent siblings on the global out/.pkgcache (the flip
  made sep the sole path, so every test now contends that cache).
- 737_direnum -> the deleted strictpkgmismatch "differs from" wording ->
  sep's "does not match import path" (shared substring, wwstage terser #68).
- 989_lib_byteid -> corpus-completeness scan excludes generated .sepwork
  scratch (the old `! -name '*.combined.ww'` exclude didn't cover the new
  sep artifact).
This commit is contained in:
2026-06-18 02:51:31 +09:00
parent f98033293e
commit 33edc386f1
6 changed files with 275 additions and 1047 deletions

View File

@@ -88,8 +88,12 @@ main(void)
(void)tmp;
}
/* bad: mismatched package decls in same dir → strict-same-package
* error. Both stages must surface "differs from" in stderr. */
/* bad: mismatched package decls in same dir → import-path mismatch
* error. E3-C1: the amalgamator's strict-same-package "differs from"
* check is deleted; under sep w6c rejects the composed unit with
* "package <p> does not match import path <i>" (wwstage is terser per
* #68, so match the shared "does not match import path" substring).
* Both stages must surface it in stderr. */
{
const char *src = "test/wcc/data/direnum/bad_entry.ww";
snprintf(errp, sizeof errp, "/tmp/direnum_%d_bad.err", getpid());
@@ -102,8 +106,8 @@ main(void)
if (rc == 0) {
fprintf(stderr, "737[bad-cstage]: expected build failure, succeeded\n");
fail++;
} else if (!stderr_contains(errp, "differs from")) {
fprintf(stderr, "737[bad-cstage]: stderr missing 'differs from'\n");
} else if (!stderr_contains(errp, "does not match import path")) {
fprintf(stderr, "737[bad-cstage]: stderr missing 'does not match import path'\n");
fail++;
}
unlink(errp);
@@ -116,8 +120,8 @@ main(void)
if (rc == 0) {
fprintf(stderr, "737[bad-wwstage]: expected build failure, succeeded\n");
fail++;
} else if (!stderr_contains(errp, "differs from")) {
fprintf(stderr, "737[bad-wwstage]: stderr missing 'differs from'\n");
} else if (!stderr_contains(errp, "does not match import path")) {
fprintf(stderr, "737[bad-wwstage]: stderr missing 'does not match import path'\n");
fail++;
}
unlink(errp);
@@ -129,7 +133,7 @@ main(void)
* (#16): the old 2048-capped peek missed that decl, so the strict-
* same-package check skipped the file and the mismatch went
* undetected (build wrongly succeeded); the whole-file peek finds it
* → "differs from". Both stages. (reviewer-batcha pin.) */
* → "does not match import path". Both stages. (reviewer-batcha pin.) */
{
const char *src = "test/wcc/data/direnum/bad_deep_entry.ww";
snprintf(errp, sizeof errp, "/tmp/direnum_%d_baddeep.err", getpid());
@@ -142,8 +146,8 @@ main(void)
if (rc == 0) {
fprintf(stderr, "737[bad-deep-cstage]: expected build failure, succeeded\n");
fail++;
} else if (!stderr_contains(errp, "differs from")) {
fprintf(stderr, "737[bad-deep-cstage]: stderr missing 'differs from'\n");
} else if (!stderr_contains(errp, "does not match import path")) {
fprintf(stderr, "737[bad-deep-cstage]: stderr missing 'does not match import path'\n");
fail++;
}
unlink(errp);
@@ -156,8 +160,8 @@ main(void)
if (rc == 0) {
fprintf(stderr, "737[bad-deep-wwstage]: expected build failure, succeeded\n");
fail++;
} else if (!stderr_contains(errp, "differs from")) {
fprintf(stderr, "737[bad-deep-wwstage]: stderr missing 'differs from'\n");
} else if (!stderr_contains(errp, "does not match import path")) {
fprintf(stderr, "737[bad-deep-wwstage]: stderr missing 'does not match import path'\n");
fail++;
}
unlink(errp);