Skip to content

edg: LIB= must precede the mkone include, or the archive never links - #613

Merged
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd
Oct 8, 2026
Merged

staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd

Conversation

@staalmannen

Copy link
Copy Markdown
Owner

-C works: every redefinition:' is gone, and what is underneath is undefined:' on `_ZN3edg...I...E' names -- template instantiations, every one, with no vtable, no typeinfo and no plain C function among them. That is the prediction this file recorded, confirmed.

But _ZnwyPv' -- placement new, the one symbol cpfe needs from libedg.a -- is undefined too, and that is mine. I wrote LIB=' AFTER <$APEXPROOT/sys/src/cmd/mkone'. mkone's rule is $O.out: $OFILES $LIB' and mk binds a rule's prerequisites when it READS the rule, so the assignment expanded to nothing and the archive never reached the link line: the run ends `... types.6 unicode_name_fsm.6' with no archive on it. It fails in the quietest way available -- the link runs, looks right, and reports the archive's symbols as undefined. Every other cmd mkfile here (tclsh, wish, itclsh) sets LIB before the include; moved, with the reason written beside it.

And the remaining fix is a RE-TRANSLATION rather than anything in a mkfile. EDG's own option table, readable in the committed corpus at src/cmd_line.c, gives `--instantiate' with values used/all/local/none and short form -t. -tused emits every used template in every translation unit with external linkage, which produces duplicates -- exactly what -C now discards, so the two go together and neither is sufficient alone. -tlocal would give each unit an internal-linkage copy and need no -C, at the cost of a copy per unit. -tused is the better pair, because -C is needed either way: the non-template duplicates (inline members like edg::skip_typerefs at 41 copies, and 499 function-local statics) are untouched by any instantiation mode.

Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs

-C works: every `redefinition:' is gone, and what is underneath is
`undefined:' on `_ZN3edg...I...E' names -- template instantiations,
every one, with no vtable, no typeinfo and no plain C function among
them.  That is the prediction this file recorded, confirmed.

But `_ZnwyPv' -- placement new, the one symbol cpfe needs from
libedg.a -- is undefined too, and that is mine.  I wrote `LIB=' AFTER
`<$APEXPROOT/sys/src/cmd/mkone'.  mkone's rule is `$O.out: $OFILES
$LIB' and mk binds a rule's prerequisites when it READS the rule, so
the assignment expanded to nothing and the archive never reached the
link line: the run ends `... types.6 unicode_name_fsm.6' with no
archive on it.  It fails in the quietest way available -- the link
runs, looks right, and reports the archive's symbols as undefined.
Every other cmd mkfile here (tclsh, wish, itclsh) sets LIB before the
include; moved, with the reason written beside it.

And the remaining fix is a RE-TRANSLATION rather than anything in a
mkfile.  EDG's own option table, readable in the committed corpus at
src/cmd_line.c, gives `--instantiate' with values used/all/local/none
and short form -t.  -tused emits every used template in every
translation unit with external linkage, which produces duplicates --
exactly what -C now discards, so the two go together and neither is
sufficient alone.  -tlocal would give each unit an internal-linkage
copy and need no -C, at the cost of a copy per unit.  -tused is the
better pair, because -C is needed either way: the non-template
duplicates (inline members like edg::skip_typerefs at 41 copies, and
499 function-local statics) are untouched by any instantiation mode.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen
staalmannen merged commit 568baec into main Oct 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants