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:
@@ -62,17 +62,20 @@ slurp_eq(const char *a, const char *b)
|
||||
* success. */
|
||||
static int
|
||||
build_via(const char *bin, const char *driver, const char *src,
|
||||
const char *workdir, const char *incs)
|
||||
const char *workdir, const char *incs, const char *out_basename)
|
||||
{
|
||||
char cmd[4096];
|
||||
/* -o <workdir>/<out> keeps the binary where the diff expects it AND
|
||||
* routes the .combined.ww/.s/.o into the workdir (T3) — no longer
|
||||
* next to the source, so concurrent driver builds never collide. */
|
||||
if (incs && incs[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/%s build -I %s %s 2>/dev/null",
|
||||
workdir, bin, driver, incs, src);
|
||||
"cd %s && timeout 180 %s/%s build -o %s/%s -I %s %s 2>/dev/null",
|
||||
workdir, bin, driver, workdir, out_basename, incs, src);
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/%s build %s 2>/dev/null",
|
||||
workdir, bin, driver, src);
|
||||
"cd %s && timeout 180 %s/%s build -o %s/%s %s 2>/dev/null",
|
||||
workdir, bin, driver, workdir, out_basename, src);
|
||||
}
|
||||
return runwait(cmd);
|
||||
}
|
||||
@@ -90,11 +93,11 @@ diff_one(const char *bin, const char *cwd, const char *label,
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s %s && mkdir -p %s %s", dc, dw, dc, dw);
|
||||
if (runwait(cmd) != 0) return -1;
|
||||
|
||||
if (build_via(bin, "ww", src, dc, incs) != 0) {
|
||||
if (build_via(bin, "ww", src, dc, incs, out_basename) != 0) {
|
||||
fprintf(stderr, "ww_ww FAIL: C ww errored on %s\n", label);
|
||||
return -1;
|
||||
}
|
||||
if (build_via(bin, "ww_ww", src, dw, incs) != 0) {
|
||||
if (build_via(bin, "ww_ww", src, dw, incs, out_basename) != 0) {
|
||||
fprintf(stderr, "ww_ww FAIL: ww ww errored on %s\n", label);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user