selfhost: migrate tool sources to directory packages
Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
This commit is contained in:
@@ -133,60 +133,61 @@ fn textcount(s: str, sym: str) i32 = {
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
// barevalue (#55 cgen-side sibling) — the migrated 794 carrier
|
||||
// barevalue (#55 cgen-side sibling) — the migrated 794 compiler carrier
|
||||
// (test/wcc/794_xmod_ident_prefer.c, retired with this row; its header
|
||||
// documents both #55 halves). A bare VALUE ident read inside an
|
||||
// imported module must be classified by the checker-stamped type, not
|
||||
// a unit-wide leaf table: aa exports `v: i32 = 7` and getv() reads the
|
||||
// bare `v`; the root declares a same-leaf `fn v() i64`. FLAT layout
|
||||
// (file-keyed import) is REQUIRED — both files fold into one unit so
|
||||
// the foreign fn lands in the leaf table; a dir-keyed aa/ compiles aa
|
||||
// as its own sep unit where main.v is invisible and the collision
|
||||
// cannot express. Pre-fix wwstage cgen took fnretlookup's leaf
|
||||
// bare `v`; the root declares a same-leaf `fn v() i64`. This compiler
|
||||
// collision requires one explicitly composed raw unit; directory packages
|
||||
// correctly isolate the leaf tables and the driver no longer folds source
|
||||
// imports. Pre-fix wwstage cgen took fnretlookup's leaf
|
||||
// fallback and emitted `LEAQ aa.v(SB)` (fn address, no load) — the
|
||||
// binary exited 0; cstage loads 7 (LEAQ+MOVSXD). Both drivers must
|
||||
// build, run 7, and the flat __root.s must be cs==ww byte-identical
|
||||
// (rule 10) — the stronger assertion set the carrier deferred while
|
||||
// the cgen side was open.
|
||||
// binary exited 0; cstage loads 7 (LEAQ+MOVSXD). Both compilers must
|
||||
// emit byte-identical assembly and the raw fixture must run 7.
|
||||
@test fn barevalue() void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/aa.ww"), strings.concat(
|
||||
let unit: str = strings.concat(td, "/barevalue.unit.ww");
|
||||
testenv.writefile(unit, strings.concat(
|
||||
"//ww:module aa\n",
|
||||
"package aa;\n",
|
||||
"export let v: i32 = 7;\n",
|
||||
"export fn getv() i32 = {\n",
|
||||
" return v;\n",
|
||||
"};\n"));
|
||||
testenv.writefile(strings.concat(td, "/main.ww"), strings.concat(
|
||||
"};\n",
|
||||
"//ww:module-reset\n",
|
||||
"package main;\n",
|
||||
"import aa;\n",
|
||||
"fn v() i64 = { return 100; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
" return aa.getv();\n",
|
||||
"};\n"));
|
||||
let drvs: []str = ["ww", "ww_ww"];
|
||||
let comps: []str = ["w6c", "w6c_ww"];
|
||||
let tags: []str = ["cs", "ww"];
|
||||
let asms: []str = ["", ""];
|
||||
let s: i32 = 0;
|
||||
for (s < 2) {
|
||||
let stem: str = strings.concat(td, "/prog.", tags[s]);
|
||||
let av: []str = [testenv.driver(drvs[s]), "build", "-o", stem,
|
||||
"-I", td, strings.concat(td, "/main.ww")];
|
||||
asms[s] = strings.concat(td, "/", tags[s], ".s");
|
||||
let av: []str = [testenv.driver(comps[s]), "-o", asms[s], unit];
|
||||
if (runcode(td, strings.concat("build_", tags[s]), av) != 0) {
|
||||
fail("barevalue", strings.concat(drvs[s], " build failed"));
|
||||
fail("barevalue", strings.concat(comps[s], " compile failed"));
|
||||
};
|
||||
let rav: []str = [stem];
|
||||
if (runcode(td, strings.concat("run_", tags[s]), rav) != 7) {
|
||||
fail("barevalue", strings.concat(drvs[s], " exit != 7 ",
|
||||
"(bare v in aa.getv must LOAD aa.v, not take the ",
|
||||
"foreign fn's address)"));
|
||||
};
|
||||
asms[s] = testenv.readfile(strings.concat(stem,
|
||||
".sepwork/__root.s"));
|
||||
s += 1;
|
||||
};
|
||||
if (!testenv.same(asms[0], asms[1])) {
|
||||
if (!testenv.same(testenv.readfile(asms[0]), testenv.readfile(asms[1]))) {
|
||||
fail("barevalue", "cs .s != ww .s (rule 10)");
|
||||
};
|
||||
let obj: str = strings.concat(td, "/barevalue.o");
|
||||
let aav: []str = [testenv.driver("w6a"), "-o", obj, asms[0]];
|
||||
if (runcode(td, "assemble", aav) != 0) { fail("barevalue", "w6a failed"); };
|
||||
let prog: str = strings.concat(td, "/barevalue");
|
||||
let lav: []str = [testenv.driver("w6l"), "-o", prog, obj,
|
||||
strings.concat(testenv.repo(), "/out/lib/libwwrt.a")];
|
||||
if (runcode(td, "link", lav) != 0) { fail("barevalue", "w6l failed"); };
|
||||
let rav: []str = [prog];
|
||||
if (runcode(td, "run", rav) != 7) {
|
||||
fail("barevalue", "bare v loaded the foreign fn address");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@@ -198,7 +199,8 @@ fn textcount(s: str, sym: str) i32 = {
|
||||
// the mirror corner (d) in cgdot. Runtime pre-fix: 141, want 42.
|
||||
@test fn defshadow() void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/p5aa.ww"), strings.concat(
|
||||
assert(os.mkdir(strings.concat(td, "/p5aa"), 493) == 0);
|
||||
testenv.writefile(strings.concat(td, "/p5aa/p5aa.ww"), strings.concat(
|
||||
"package p5aa;\n",
|
||||
"export def MSG: i32 = 3;\n"));
|
||||
testenv.writefile(strings.concat(td, "/main.ww"), strings.concat(
|
||||
@@ -241,7 +243,8 @@ fn textcount(s: str, sym: str) i32 = {
|
||||
// gate (proves the checker stamps the N_DOT fn rvalue as TY_FN).
|
||||
@test fn modqualfnval() void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/p6aa.ww"), strings.concat(
|
||||
assert(os.mkdir(strings.concat(td, "/p6aa"), 493) == 0);
|
||||
testenv.writefile(strings.concat(td, "/p6aa/p6aa.ww"), strings.concat(
|
||||
"package p6aa;\n",
|
||||
"export fn hit(x: i32) i32 = { return x + 40; };\n"));
|
||||
testenv.writefile(strings.concat(td, "/main.ww"), strings.concat(
|
||||
|
||||
Reference in New Issue
Block a user