wcc/ww: mangle imported symbols on dotted import path (#22 M1, #32)

Switch symbol mangling from the import leaf clause to the full dotted import path for directory packages; single-file imports keep package-clause mangling (isdir-gate: imported<=>directory-import). The root build unit's fn main stays bare, every other top-level decl mangles, closing #31's duplicate-main hazard by construction (#32). Both stages, byte-identical.

Single commit, not split: the bare rename (f244af3) is red on its own because it unmasks cross-module resolution gaps that do not reproduce pre-M1, so the fixes are intrinsic to making the rename correct. Included: wwstage fnret/fnparamslookupmod map import alias->path (#199b cross-module union-variant scrutinee resolved the wrong fn's union); cstage use_path prefers the referencing module's import for an ambiguous leaf alias (sha256 crypto.math vs strconv math). Tests table-driven: 989_m1mangle_run/_sym, 989_m1union_run (gate-visible per-arm exit codes + cs==ww byte-id).
This commit is contained in:
2026-06-15 17:37:18 +09:00
parent 64d6c15e41
commit f308818b4b
30 changed files with 1851 additions and 241 deletions

View File

@@ -144,7 +144,11 @@ static const struct row rows[] = {
/* Cross-mod: cstage emits the LEAQ via N_DOT TK_AMP (already
* working pre-#180). Wwstage bails asserttyped on the same
* shape — filed as #184; this row stays cstage-only until that
* lifts. */
* lifts. M1 #22: `wcamffn764mod` is a directory package, so its
* exported `somefn` path-mangles to `wcamffn764mod.somefn` (the
* pre-M1 bare `somefn` is gone, mirroring 989_m1mangle_sym); the
* &-of hint routes through use_hint and the LEAQ matches the
* mangled definition. */
{ "cross_module",
"import wcamffn764mod;\n"
"export fn main() i32 = {\n"
@@ -153,7 +157,7 @@ static const struct row rows[] = {
"};\n",
"wcamffn764mod",
"export fn somefn(x: i32) i32 = { return x + 1; };\n",
"LEAQ\tsomefn(SB)",
"LEAQ\twcamffn764mod.somefn(SB)",
STAGE_CS },
};