ww: rename toolchain to w-prefix + hare-style build/run/test driver
Plan 9-style w-prefix on the per-arch tools, disambiguating from the
real Plan 9 6c/6a/6l in ref/plan9front/:
cmd/wwc/ → cmd/wcc/ libwwc.a → libwcc.a
cmd/6{c,a,l} → cmd/w6{c,a,l} binary names too
test/wwc/ → test/wcc/ 6 test files w/ w6 prefix
selfhost/cmd mirror in lockstep
bootstrap/amd64/{w6c,w6a,w6l} snapshot binaries (gitignored)
WW_6{C,A,L} → WW_W6{C,A,L} env-var overrides
Plan 9 source-tree refs ("Plan 9 6c shape", ref/plan9front/, etc.)
preserved. Hare-style driver, both C and ww sides:
ww test [path] discover *_test.ww in a directory module, run
each; single-file mode for `ww test foo.ww`
Module-by-name `ww build foo` resolves to foo.ww or foo/foo.ww
via search path (cwd : -I dirs : $WW_LIB)
Default-to-cwd `ww build` / `ww test` build the cwd module
Run pass-through `ww run path arg1 arg2` reaches the program
lib/os: getcwd (79) and getdents64 (217) syscalls power `.` resolution
and directory enumeration on the ww side.
Makefile: wwstage tool deps now include lib/os/os.ww (+ lib/strconv
for wwdump_ww) so lib/* edits force their rebuild instead of leaving
stale binaries — surfaced when test 995 first failed against a stale
w6c_ww built before the lib/os additions.
Test 993 byte-identical parity gate (C-side ww vs ww-side ww_ww on a
build corpus) stays green; all 19 tests pass.
This commit is contained in:
@@ -18,19 +18,21 @@ export fn assert(cond: bool, msg: str) void = {
|
||||
if (!cond) { abort(msg); };
|
||||
};
|
||||
|
||||
def SYS_READ: i64 = 0;
|
||||
def SYS_WRITE: i64 = 1;
|
||||
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;
|
||||
def SYS_EXIT: i64 = 60;
|
||||
def SYS_WAIT4: i64 = 61;
|
||||
def SYS_UNLINK: i64 = 87;
|
||||
def SYS_READ: i64 = 0;
|
||||
def SYS_WRITE: i64 = 1;
|
||||
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;
|
||||
def SYS_EXIT: i64 = 60;
|
||||
def SYS_WAIT4: i64 = 61;
|
||||
def SYS_UNLINK: i64 = 87;
|
||||
def SYS_GETCWD: i64 = 79;
|
||||
def SYS_GETDENTS64: i64 = 217;
|
||||
|
||||
// open(2) flags. Linux values, matching <fcntl.h>.
|
||||
def O_RDONLY: i32 = 0;
|
||||
@@ -65,7 +67,7 @@ export fn close(fd: i32) 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
|
||||
// negative errno. Used by w6c_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;
|
||||
@@ -179,6 +181,32 @@ export fn wait4(pid: i32, status_out: *i32, options: i32, rusage: *void) i32 = {
|
||||
options: i64, rusage: i64): i32;
|
||||
};
|
||||
|
||||
// getcwd(2) — Linux flavour. Writes the NUL-terminated cwd into `buf`
|
||||
// and returns the number of bytes written (including the NUL), or a
|
||||
// negative errno. The driver uses it to expand `.` to the cwd's
|
||||
// basename for `ww build` / `ww test`.
|
||||
export fn getcwd(buf: *u8, n: u64) i64 = {
|
||||
return syscall2(SYS_GETCWD, buf: i64, n: i64);
|
||||
};
|
||||
|
||||
// getdents64(2) — Linux directory enumeration. The fd must be opened
|
||||
// with O_RDONLY on a directory. `buf` receives a packed sequence of
|
||||
// linux_dirent64 records:
|
||||
//
|
||||
// struct linux_dirent64 {
|
||||
// u64 d_ino; // 0..7
|
||||
// i64 d_off; // 8..15
|
||||
// u16 d_reclen; // 16..17 — total bytes for this record
|
||||
// u8 d_type; // 18 — DT_REG/DT_DIR/...
|
||||
// u8 d_name[]; // 19.. — NUL-terminated name + padding
|
||||
// };
|
||||
//
|
||||
// Returns bytes written into `buf` (advance by d_reclen to walk),
|
||||
// 0 at end-of-directory, or a negative errno.
|
||||
export fn getdents64(fd: i32, buf: *u8, n: u64) i64 = {
|
||||
return syscall3(SYS_GETDENTS64, fd: i64, buf: i64, n: i64);
|
||||
};
|
||||
|
||||
// strconv — number↔string conversions. Decimal i64 to/from a fixed
|
||||
// buffer. Two error idioms ship side by side:
|
||||
// - Plan 9 style (atoi64): tuple `(value, ok)`. Pre-dates the
|
||||
@@ -406,7 +434,7 @@ export fn toupper(c: u8) u8 = {
|
||||
// indicating which probe broke. The 990_selfhost test asserts 42.
|
||||
//
|
||||
// Note: only stack-local mutable state. Top-level `let` mutation
|
||||
// requires a writable .data segment in 6l, which is a separate
|
||||
// requires a writable .data segment in w6l, which is a separate
|
||||
// task; until then we exercise polymorphism via ctx pointers, which
|
||||
// is what the real port wants anyway.
|
||||
|
||||
@@ -423,7 +451,7 @@ type arena = struct {
|
||||
};
|
||||
|
||||
// In-place init. Returning a 24-byte struct by value isn't yet
|
||||
// supported in 6c (SysV requires a hidden return-slot pointer for
|
||||
// supported in w6c (SysV requires a hidden return-slot pointer for
|
||||
// structs >16 bytes), so we initialize through a pointer like the
|
||||
// real compiler does today.
|
||||
fn arena_init(a: *arena, buf: *u8, cap: u64) void = {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// indicating which probe broke. The 990_selfhost test asserts 42.
|
||||
//
|
||||
// Note: only stack-local mutable state. Top-level `let` mutation
|
||||
// requires a writable .data segment in 6l, which is a separate
|
||||
// requires a writable .data segment in w6l, which is a separate
|
||||
// task; until then we exercise polymorphism via ctx pointers, which
|
||||
// is what the real port wants anyway.
|
||||
|
||||
@@ -29,7 +29,7 @@ type arena = struct {
|
||||
};
|
||||
|
||||
// In-place init. Returning a 24-byte struct by value isn't yet
|
||||
// supported in 6c (SysV requires a hidden return-slot pointer for
|
||||
// supported in w6c (SysV requires a hidden return-slot pointer for
|
||||
// structs >16 bytes), so we initialize through a pointer like the
|
||||
// real compiler does today.
|
||||
fn arena_init(a: *arena, buf: *u8, cap: u64) void = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// `type NAME = TYPE;` (alias + struct), top-level `let NAME: TYPE = LIT;`.
|
||||
//
|
||||
// Function declarations are still recovered past — the body parser
|
||||
// is the next major chunk. See selfhost/cmd/wwc/parse.ww header.
|
||||
// is the next major chunk. See selfhost/cmd/wcc/parse.ww header.
|
||||
|
||||
use os;
|
||||
use mem;
|
||||
|
||||
Reference in New Issue
Block a user