ww: build intermediates follow -o output stem, not the source dir (test-perf T3a)

build_one/buildone gain an explicit objstem: 'ww build -o X' derives
main.{combined.ww,s,o} beside X; 'ww run' uses its per-pid /tmp stem;
default no--o stays next-to-source (load-bearing for the make regen of
tracked combined.ww and the freshness gate). Realizes the redirect TODO
in 995_self_rebuild.c. Kills the concurrent-test torn-read race on
selfhost/cmd/<tool>/main.* (the 991 transient). 993/995/949 pass -o
into their per-pid workdirs; 949's '-o /dev/null' relied on the old
driver ignoring -o (audited: the only live driver case). Atomic
combined write (os.rename) deferred to its own commit - lib/os lacks
rename and that addition is an import-floor regen.
This commit is contained in:
2026-06-10 17:02:28 +09:00
parent 9b99d0883f
commit 44c47c3ea0
6 changed files with 178 additions and 60 deletions

View File

@@ -35,21 +35,26 @@ static int
run_miss(const char *bin)
{
int pid = getpid();
char src[64], errf[64], cmd[2048], line[4096];
char src[64], errf[64], outb[64], comb[80], cmd[2048], line[4096];
snprintf(src, sizeof src, "/tmp/mp949_miss_%d.ww", pid);
snprintf(errf, sizeof errf, "/tmp/mp949_miss_%d.err", pid);
/* -o a writable /tmp stem (not /dev/null): post-T3 the intermediate
* .combined.ww/.s/.o follow -o, so /dev/null would yield an
* uncreatable /dev/null.combined.ww and mask the missing-pkg fatal. */
snprintf(outb, sizeof outb, "/tmp/mp949_miss_%d.out", pid);
snprintf(comb, sizeof comb, "/tmp/mp949_miss_%d.out.combined.ww", pid);
FILE *f = fopen(src, "w");
if (!f) { fprintf(stderr, "949 FAIL: stage miss\n"); return 1; }
fputs("import nosuchpkg;\n"
"export fn main() i32 = { return 0; };\n", f);
fclose(f);
snprintf(cmd, sizeof cmd, "%s/ww build %s -o /dev/null 2>%s",
bin, src, errf);
snprintf(cmd, sizeof cmd, "%s/ww build %s -o %s 2>%s",
bin, src, outb, errf);
int rc = runwait(cmd);
if (rc == 0) {
fprintf(stderr, "949 FAIL: ww accepted a missing import\n");
unlink(src); unlink(errf);
unlink(src); unlink(errf); unlink(outb); unlink(comb);
return 1;
}
int found = 0;
@@ -61,7 +66,7 @@ run_miss(const char *bin)
}
fclose(f);
}
unlink(src); unlink(errf);
unlink(src); unlink(errf); unlink(outb); unlink(comb);
if (!found) {
fprintf(stderr, "949 FAIL: no 'cannot find package nosuchpkg' "
"on stderr\n");