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:
@@ -602,9 +602,17 @@ fn cgfn(c: *cgen, fn_: *node) void = {
|
||||
|
||||
// Emit the TEXT label via emitfnname so the def site picks up the
|
||||
// same skip rule (FFI / `main` / empty-module) and the same module
|
||||
// hint (this fn's own module) that the call sites use.
|
||||
// hint (this fn's own module) that the call sites use. M1 #32: the
|
||||
// ROOT-unit main (imported==0) is the bare `_start` entry — emit it
|
||||
// bare directly, mirroring collectmods' skip; without this its
|
||||
// fn_.nmod hint would fall through modlookupforfn's first-leaf match
|
||||
// onto an IMPORTED package's now-registered `pkg.main`.
|
||||
emitline("TEXT ");
|
||||
emitfnname(c, fn_.str, fn_.nmod);
|
||||
if (streq(fn_.str, "main") && fn_.imported == 0) {
|
||||
emitbytes(fn_.str.ptr, fn_.str.len: u64);
|
||||
} else {
|
||||
emitfnname(c, fn_.str, fn_.nmod);
|
||||
};
|
||||
emitline(",$");
|
||||
emitint(frame: i64);
|
||||
emitline("\n");
|
||||
|
||||
Reference in New Issue
Block a user