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

@@ -265,6 +265,9 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_libprecond_abort \
$(BIN)/test_idxarg_run \
$(BIN)/test_chainidx_run \
$(BIN)/test_m1mangle_run \
$(BIN)/test_m1mangle_sym \
$(BIN)/test_m1union_run \
$(BIN)/test_tupfieldsize_run \
$(BIN)/test_tagtupfieldsize_run \
$(BIN)/test_nestfield_run \
@@ -817,6 +820,35 @@ $(BIN)/test_chainidx_run: test/wcc/989_chainidx_run.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_m1mangle_run / _sym (M1, #22 + #32): path-qualified symbol mangling
# and root-unit entry detection. _run builds+runs a tiny package tree on
# BOTH stages (rule-10); _sym asserts the emitted symbol names + cs.s==ww.s.
$(BIN)/test_m1mangle_run: test/wcc/989_m1mangle_run.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_m1mangle_sym: test/wcc/989_m1mangle_sym.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_m1union_run (M1, #199b): a `match` on a cross-module fn's tagged-union
# return must keep each nominal void-alias variant on a distinct tag. Builds+
# runs the utf8.next 4-arm match per-arm on BOTH stages (rule-10) and pins
# cstage.s==wwstage.s on the all-arms program — the gate-VISIBLE regression
# teeth for the variant-collapse the doc flagged as byte-id-only.
$(BIN)/test_m1union_run: test/wcc/989_m1union_run.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_tupfieldsize_run (F7-c4, #43): a for-range destructure over an array
# of tuples must stride by the tuple's true size (a slice/str/tuple field
# carries its full width). Builds+runs on BOTH driver twins (rule-10), the