Skip to content

Claude/upgrade ape c library mm z gd - #610

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

staalmannen merged 2 commits into
mainfrom
claude/upgrade-ape-c-library-mmZGd

Conversation

@staalmannen

Copy link
Copy Markdown
Owner

No description provided.

claude added 2 commits October 8, 2026 03:16
Asked all at once rather than one per round, which is the rule bacon's
missing headers and bacon's missing link symbols both paid for.

CONSTRUCTS.  Swept over all 133 files with comments, string and
character literals and `#line' stripped FIRST, and the stripping is
the measurement rather than a tidying step: a raw grep reports
`alignof' 2343 times, `typeof' 425, `static_assert' 1156 and
`_Complex' 702, and every one of those is ZERO afterwards -- they were
EDG's own diagnostic text and mangled names like
`_ZN3edg27ec_wrong_entity_for_alignasE', the word inside a longer
identifier, never a keyword.  After stripping, every C11/C23
construct kencc lacks is zero except three files:

  lib_src/c99_complex.c   _Float16, __bf16, __float80, __float128
  lib_src/thread_dtor.c   __thread
  lib_src/dtor_list.c     __thread

All three use a feature of the HOST compiler rather than anything of
EDG's design, which is exactly why `gcc -fsyntax-only' reports 0
errors over them: the host compiler is the one that put them there.
Left in OFILES deliberately -- with `mk -k' the other 48 build and the
three failures confirm the sweep named the whole class, where removing
them first would make a clean run say nothing.

SIZE LIMITS asked rather than assumed, because a 315,616-line
translation unit invites them, and none bites: longest line 430 bytes
against cpp's INS 32768, longest identifier 295 against cc's NSYMB
1500, most `case' in a file 7204 where 6c's Case is a linked list.
6c's `NSYM 50' is NOT a cap: swt.c:229 wraps the slot to 1 and
re-emits the ANAME, so it is a cache.

SYMBOLS.  All 133 compiled with gcc (133 of 133), then nm's defined
set subtracted from nm's undefined set: 679 truly external, 558 of
them `_Z'-prefixed and 121 plain C names.  libap defines every plain
name but two -- and the first sweep said two dozen were absent only
because its regex required a character before the name, which a
definition starting in column 0 does not have.  That is the
function-shaped grep of the `reject' round in a new spelling.

  _setjmp         lib_src/eh_util.c, lib_src/newnothrow.c
  __cxa_finalize  lib_src/static_init.c

`_setjmp' is a missed line in kencc_targ.h, not a libap gap: EDG's
TARG_SETJMP_FUNC defaults to "_setjmp" and win64 -- the same
configuration every other value here came from -- says "setjmp".  Set
now, effective at the next translation.  The buffer was checked rather
than assumed: `long [25]' is 100 bytes under kencc's 4-byte long
against jmp_buf's 80 and the 64 amd64 writes, and that is the half
that would have been silent.  Adding `_setjmp' to a public APE header
is the wrong answer and the bare-word sweep says why -- lua/ldo.c:80
uses the name under LUA_USE_POSIX.

`__cxa_finalize' is not a libap question: unconditional in EDG's own
cxxabi.h, defined nowhere in lib_src, and upstream expects the
platform's Itanium-ABI runtime.  One small APExp-owned file in
lib/edg if the link needs it.

THE LINK MODEL IS TWO HALVES AND READING THEM AS ONE WAS WRONG.  556
of the 558 `_Z' names are template function instantiations, and ZERO
are vtables, typeinfo, typeinfo names, guard variables or thunks --
so cpfe emitted them NOWHERE and the output is not self-contained for
templates independently of --one_instantiation_per_object.  The
default output already depends on a prelink step, for exactly the
entities OIPO was being considered for; the next translation needs an
instantiation-mode flag.  Separately the duplicate half is now
measured from objects rather than annotations: 3124 symbols defined in
more than one object and 6410 surplus definitions, against the 3094
counted from COMDAT annotations -- two routes to the same number.

Two confirmations fell out of the same table and both say the staging
really used this tree: `_errnoloc' is undefined in six of src/'s files
and defined in libap's plan9/_envsetup.c, which is APE's `errno' macro
expanded; `isNaN' -- Plan 9's own capitalisation -- is referenced by
src/float_pt.c.  Neither name exists on glibc.  And nine of src/'s
files carry `extern unsigned char _ctype[];' byte for byte as APE's
<ctype.h> declares it, which also pins this generated C to the
`_ctype' bit layout the _ISblank round changed.

Recorded for util/, which has no mkfile and blocks nothing: edg_decode,
edg_munch and edg_prelink each bundle their own `getopt', `optind',
`optarg' and `opterr', so linking them against libap would give
`redefinition: getopt' -- the f2c-supplies-its-own-malloc shape.
Nothing in src/ or lib_src/ is affected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen
staalmannen merged commit 446f7f5 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