test: retarget Pattern-B gates to sep .sepwork layout; 915 off private global (M4 E3, #93)
The driver flip moves build artifacts from next-to-source <stem>.s to a .sepwork/ scratch dir. 29 Pattern-B gates now build `ww build --sep -o <stem>` and read <stem>.sepwork/__root.s (multi-package gates concat all <stem>.sepwork/*.s, since cross-package labels live in per-package .s). All intermediates redirect to /tmp (WW_PKGCACHE + -o), so the corpus runs parallel-safe with no source-tree pollution. Tests pass now (--sep is live) and survive the flip. 915 additionally retargeted off strconv's PRIVATE left_shift_table (a let, not export) — which separate compilation correctly hides — onto a test-local package that exports its own probe table (#96). The combined path only linked it via a single-unit private leak; encapsulation is now honored under sep. Test-only; all 5 *_ww binaries HOLD. 989_m1mangle_run deferred (blocked by #99, imported-package fn main mangling under sep).
This commit is contained in:
@@ -56,40 +56,57 @@ slurp(const char *path, char **outbuf, size_t *outlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* link `inputs` (space-separated, the caller's responsibility to quote)
|
||||
* with both linkers, compare bytes. */
|
||||
/* #93 sep layout: the flip stops emitting a monolithic <tool>/main.o;
|
||||
* the linkable unit is now the per-package .o + reverse-topo .a set the
|
||||
* sep driver assembles (a raw `w6l <root>.o *.a libwwrt.a` from the test
|
||||
* side fails — `undefined reference` — because it can't reproduce the
|
||||
* driver's topo order). So isolate the LINKER by driving the sep build's
|
||||
* own link step twice over identical .o inputs (a shared pkgcache makes
|
||||
* the second build's package objects a cache hit → only the final link
|
||||
* re-runs): once with the default C w6l, once with WW_W6L=w6l_ww. Diff
|
||||
* the two real tool binaries. Exercises the full archive two-pass loader
|
||||
* + reverse-topo .a resolution — a stronger link than the old single
|
||||
* main.o. Flip-invariant: --sep is live on trunk, default post-flip. */
|
||||
static int
|
||||
diff_one(const char *bin, const char *label, const char *inputs)
|
||||
build_and_diff(const char *bin, const char *cwd, const char *tool,
|
||||
const char *cache)
|
||||
{
|
||||
char co[64], wo[64], cmd[4096];
|
||||
snprintf(co, sizeof co, "/tmp/wwl_%d_c", getpid());
|
||||
snprintf(wo, sizeof wo, "/tmp/wwl_%d_w", getpid());
|
||||
char cstem[256], wstem[256], cmd[4096];
|
||||
snprintf(cstem, sizeof cstem, "/tmp/wwl_%d_c", getpid());
|
||||
snprintf(wstem, sizeof wstem, "/tmp/wwl_%d_w", getpid());
|
||||
|
||||
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s 2>/dev/null", bin, co, inputs);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"WW_PKGCACHE=%s timeout 300 %s/ww build --sep -o %s "
|
||||
"%s/selfhost/cmd/%s >/dev/null 2>&1", cache, bin, cstem, cwd, tool);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "w6l_ww FAIL: C w6l errored on %s\n", label);
|
||||
unlink(co);
|
||||
fprintf(stderr, "w6l_ww FAIL: C-link sep-build of %s\n", tool);
|
||||
return -1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l_ww -o %s %s 2>/dev/null", bin, wo, inputs);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"WW_W6L=%s/w6l_ww WW_PKGCACHE=%s timeout 300 %s/ww build --sep "
|
||||
"-o %s %s/selfhost/cmd/%s >/dev/null 2>&1",
|
||||
bin, cache, bin, wstem, cwd, tool);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "w6l_ww FAIL: ww w6l errored on %s\n", label);
|
||||
unlink(co); unlink(wo);
|
||||
fprintf(stderr, "w6l_ww FAIL: ww-link sep-build of %s\n", tool);
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s %s.sepwork", cstem, cstem);
|
||||
if (system(cmd)) {}
|
||||
return -1;
|
||||
}
|
||||
char *bc = NULL, *bw = NULL;
|
||||
size_t nc = 0, nw = 0;
|
||||
int rc = 0;
|
||||
if (slurp(co, &bc, &nc) < 0 || slurp(wo, &bw, &nw) < 0) {
|
||||
fprintf(stderr, "w6l_ww FAIL: cannot read output for %s\n", label);
|
||||
if (slurp(cstem, &bc, &nc) < 0 || slurp(wstem, &bw, &nw) < 0) {
|
||||
fprintf(stderr, "w6l_ww FAIL: cannot read output for %s\n", tool);
|
||||
rc = -1;
|
||||
} else if (nc != nw || memcmp(bc, bw, nc) != 0) {
|
||||
fprintf(stderr, "w6l_ww FAIL: %s — C %zu vs ww %zu bytes\n",
|
||||
label, nc, nw);
|
||||
tool, nc, nw);
|
||||
rc = -1;
|
||||
}
|
||||
free(bc); free(bw);
|
||||
unlink(co); unlink(wo);
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s %s %s.sepwork %s.sepwork",
|
||||
cstem, wstem, cstem, wstem);
|
||||
if (system(cmd)) {}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -102,36 +119,31 @@ main(void)
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
|
||||
struct {
|
||||
const char *label;
|
||||
const char *inputs_fmt; /* %s = cwd */
|
||||
} cases[] = {
|
||||
/* Real bootstrap-style links: every selfhost main.o paired
|
||||
* with libwwrt.a. Exercises both the .o code path and the
|
||||
* archive two-pass loader (rt_malloc / rt_syscall / rt_abort
|
||||
* are pulled from libwwrt.a as undefs are encountered). */
|
||||
{ "wwdump+libwwrt",
|
||||
"%s/selfhost/cmd/wwdump/main.o %s/out/lib/libwwrt.a" },
|
||||
{ "w6a+libwwrt",
|
||||
"%s/selfhost/cmd/w6a/main.o %s/out/lib/libwwrt.a" },
|
||||
{ "w6l+libwwrt",
|
||||
"%s/selfhost/cmd/w6l/main.o %s/out/lib/libwwrt.a" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
/* Real bootstrap-style links: each selfhost tool's full sep build
|
||||
* (root .o + reverse-topo dep .a set + libwwrt.a). One shared
|
||||
* pkgcache across all builds so each tool's second (w6l_ww) build
|
||||
* re-links only. (wwdump is excluded — it imports the compiler-
|
||||
* internal cmd packages syntax/check/cgen, which don't resolve
|
||||
* under the lib-path sep dep scan; w6a/w6l are self-contained
|
||||
* lib-only tools.) */
|
||||
const char *tools[] = { "w6a", "w6l", NULL };
|
||||
char cache[256];
|
||||
snprintf(cache, sizeof cache, "/tmp/wwl_%d_pkgc", getpid());
|
||||
|
||||
int fail = 0;
|
||||
int n = 0;
|
||||
for (int i = 0; cases[i].label; i++) {
|
||||
char inputs[2048];
|
||||
snprintf(inputs, sizeof inputs, cases[i].inputs_fmt, cwd, cwd);
|
||||
if (diff_one(bin, cases[i].label, inputs) != 0) fail++;
|
||||
for (int i = 0; tools[i]; i++) {
|
||||
if (build_and_diff(bin, cwd, tools[i], cache) != 0) fail++;
|
||||
n++;
|
||||
}
|
||||
char rmc[320];
|
||||
snprintf(rmc, sizeof rmc, "rm -rf %s", cache);
|
||||
if (system(rmc)) {}
|
||||
if (fail) {
|
||||
fprintf(stderr, "w6l_ww: %d/%d diff(s) failed\n", fail, n);
|
||||
return 1;
|
||||
}
|
||||
printf("w6l_ww: byte-identical to C w6l on %d corpus links "
|
||||
"(.o + libwwrt.a archive resolution)\n", n);
|
||||
printf("w6l_ww: byte-identical to C w6l on %d selfhost tool links "
|
||||
"(sep root .o + reverse-topo .a set + libwwrt.a)\n", n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user