ww: driver shells to wwstage tools
build_one now invokes 6c_ww / 6a_ww / 6l_ww from $self_dir, not the C-built binaries that share the directory. After this change `ww_ww build foo.ww` touches no cstage code at runtime — the fresh-checkout cstage is still needed to bring the wwstage into existence, but day-to-day work runs on the ww toolchain end to end. The C `ww` driver in cmd/ww/ still drives the C 6c/6a/6l. Test 993 (which used to be trivial — both drivers invoked the same C tools) now meaningfully compares the cstage pipeline against the wwstage pipeline on hello + wwdump and confirms byte-identical exes. The .combined.ww files for 6a/6l/ww/wwdump and smoke are regenerated by the ww driver's `expand()` step; their diff is the lib/os dup2 wrapper and the cgen.ww port from the prior two commits, propagating into the bootstrap inputs.
This commit is contained in:
@@ -24,6 +24,7 @@ def SYS_OPEN: i64 = 2;
|
||||
def SYS_CLOSE: i64 = 3;
|
||||
def SYS_LSEEK: i64 = 8;
|
||||
def SYS_ACCESS: i64 = 21;
|
||||
def SYS_DUP2: i64 = 33;
|
||||
def SYS_GETPID: i64 = 39;
|
||||
def SYS_FORK: i64 = 57;
|
||||
def SYS_EXECVE: i64 = 59;
|
||||
@@ -62,6 +63,14 @@ export fn close(fd: i32) i32 = {
|
||||
return syscall1(SYS_CLOSE, fd: i64): i32;
|
||||
};
|
||||
|
||||
// dup2(2): make `newfd` refer to the same description as `oldfd`,
|
||||
// closing `newfd` first if open. Returns `newfd` on success or a
|
||||
// negative errno. Used by 6c_ww to redirect stdout into an output
|
||||
// file without changing the cgen emit path.
|
||||
export fn dup2(oldfd: i32, newfd: i32) i32 = {
|
||||
return syscall2(SYS_DUP2, oldfd: i64, newfd: i64): i32;
|
||||
};
|
||||
|
||||
// Fallible wrappers. The error variant is a plain str (Plan 9 errstr
|
||||
// model, see lib/errors); the sum type makes success/failure explicit
|
||||
// without overloading length-zero.
|
||||
@@ -687,16 +696,22 @@ fn append_lit(stem: *u8, suffix: str) *u8 = {
|
||||
};
|
||||
|
||||
// build_one — compile `src` into the executable named `out`.
|
||||
// self_dir: NUL-terminated dir containing this driver (and 6c/6a/6l)
|
||||
// self_dir: NUL-terminated dir containing this driver and the
|
||||
// wwstage tools (6c_ww/6a_ww/6l_ww)
|
||||
// src: NUL-terminated path to the .ww file
|
||||
// out: NUL-terminated desired output path
|
||||
// incs: NUL-terminated colon-list of -I dirs (may be empty)
|
||||
//
|
||||
// The ww-side driver shells to the ww-side tools so a `ww_ww build`
|
||||
// touches no C-built code at runtime. The C `ww` driver in cmd/ww/
|
||||
// still drives the C-built 6c/6a/6l. Test 993 pins the two
|
||||
// pipelines to byte-identical output on a corpus.
|
||||
fn build_one(self_dir: *u8, src: *u8, out: *u8, incs: *u8) i32 = {
|
||||
let a: *arena = newarena();
|
||||
|
||||
let c6: *u8 = join_path_lit(self_dir, "6c");
|
||||
let a6: *u8 = join_path_lit(self_dir, "6a");
|
||||
let l6: *u8 = join_path_lit(self_dir, "6l");
|
||||
let c6: *u8 = join_path_lit(self_dir, "6c_ww");
|
||||
let a6: *u8 = join_path_lit(self_dir, "6a_ww");
|
||||
let l6: *u8 = join_path_lit(self_dir, "6l_ww");
|
||||
|
||||
// Default lib search path: <self_dir>/../../lib
|
||||
let dotdot_lib: *u8 = os.alloc(PATH_MAX): *u8;
|
||||
|
||||
@@ -408,16 +408,22 @@ fn append_lit(stem: *u8, suffix: str) *u8 = {
|
||||
};
|
||||
|
||||
// build_one — compile `src` into the executable named `out`.
|
||||
// self_dir: NUL-terminated dir containing this driver (and 6c/6a/6l)
|
||||
// self_dir: NUL-terminated dir containing this driver and the
|
||||
// wwstage tools (6c_ww/6a_ww/6l_ww)
|
||||
// src: NUL-terminated path to the .ww file
|
||||
// out: NUL-terminated desired output path
|
||||
// incs: NUL-terminated colon-list of -I dirs (may be empty)
|
||||
//
|
||||
// The ww-side driver shells to the ww-side tools so a `ww_ww build`
|
||||
// touches no C-built code at runtime. The C `ww` driver in cmd/ww/
|
||||
// still drives the C-built 6c/6a/6l. Test 993 pins the two
|
||||
// pipelines to byte-identical output on a corpus.
|
||||
fn build_one(self_dir: *u8, src: *u8, out: *u8, incs: *u8) i32 = {
|
||||
let a: *arena = newarena();
|
||||
|
||||
let c6: *u8 = join_path_lit(self_dir, "6c");
|
||||
let a6: *u8 = join_path_lit(self_dir, "6a");
|
||||
let l6: *u8 = join_path_lit(self_dir, "6l");
|
||||
let c6: *u8 = join_path_lit(self_dir, "6c_ww");
|
||||
let a6: *u8 = join_path_lit(self_dir, "6a_ww");
|
||||
let l6: *u8 = join_path_lit(self_dir, "6l_ww");
|
||||
|
||||
// Default lib search path: <self_dir>/../../lib
|
||||
let dotdot_lib: *u8 = os.alloc(PATH_MAX): *u8;
|
||||
|
||||
Reference in New Issue
Block a user