Skip to content

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

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

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

Conversation

@staalmannen

Copy link
Copy Markdown
Owner

No description provided.

claude added 4 commits October 7, 2026 13:03
cmd/c++lib after removing the seven < 0x200000 guards prints
cpp 26553 / ns_strip 26553 / cfront 5747, the four iostream.h
redeclarations and `two definitions of norm()', exit 5 -- every
number matching the prediction written down before the run. None of
the seven was load-bearing; the garbage pointer they existed for is
gone rather than hidden.

cfront is closed as a question for this tree. What remains is
upstream's own 64-bit unfitness, reproduced character for character
by the host gcc build. The directory stays, off, as an instrument.

Also recorded where the to-do was written: -J largely retires the
archiver padding sweep. The tar bug was Asu2's tail round plus
Ael1's nested-struct alignment, and -J fixes both for every APE
compile, so an all-char on-disk record now gets its natural size.
Running each archiver on a real archive is still worth one round,
but it is a check rather than a hunt. tar's #pragma pack is a no-op
under -J and stays: it documents intent and keeps the file right
under -9.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
Three of the four recorded recommendations, each measured by the
together-case of apehdr-sweep.py rather than argued.

f2c.h -- RECOMMENDATION WITHDRAWN, not done. The installed copy is
byte-identical to external/f2c/lib/f2c.h except for two added lines,
`#pragma lib "/$M/lib/ape/libf2c.a"' and a blank. That is the whole
reason it exists: a user compiling f2c's output gets libf2c linked.
The 149 includers live beside their own copy and never see this one.
Its five together-case errors join regex.h/pcre2posix.h as design
intent. I had reasoned from where the includers live, which is the
wrong question; diffing the installed copy settles it in one command.

Plan9libnet.h -- DELETED, for a better reason than recorded. Nothing
includes it, and it shares the include guard __LIBNET_H with
libnet.h, so the two can never be combined anyway. What decides it is
that two of its three distinctive declarations name functions that do
not exist: there is no Plan 9 accept(int,char*) or listen(char*,char*)
in libap, only POSIX's.

libnet.h -- net_accept, net_listen and net_reject were declared here
and defined nowhere and called nowhere, so every program including
<sys/socket.h> carried three promises libap cannot keep, failing at
the link rather than the call. Removed. reject(int,char*,char*) is
the same defect pointing the other way: plan9/announce.c:139 defines
it and no header declared it. Declared now.

getopt -- bsd.h said (int, char**, char*) where getopt.h has had
POSIX's (int, char * const [], const char *) all along: two installed
headers declaring one name incompatibly. bsd.h and the definition in
misc/getopt.c now match getopt.h. Callers are unaffected, since
char** converts to char * const * (C11 6.5.16.1).

features.h -- `hidden' and `weak_alias' removed from this PUBLIC
header. `hidden' expanded to nothing and sqlite3.h:10957 declares
`unsigned char hidden[48];', erased wherever features.h came first --
a silent struct-layout change in a public API. `weak_alias' had no
victim but was only safe because its parameter names matched
gnulib's libc-config.h token for token. Sixteen private files gain
the `#ifndef hidden' guard and five under network/ the weak_alias
one, which is the idiom include/libm.h and multibyte/internal.c
already used. Nothing outside libap needs either: every external
package using weak_alias ships its own libc-config.h, and bash's
lib/intl is not compiled (ENABLE_NLS undef, and the -I was removed).

Measured: apehdr-sweep 149 -> 148 headers, 0 standalone findings,
together-case 12 -> 10 -> 9 -> 8 across the three fixes, each drop
naming its own error. apdecl-sweep 0. The twelve touched libap
sources give 3 host errors before and the same 3 after -- a
pre-existing `FILE *const stdin' qualifier mismatch, unrelated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
…OMEDIR--

sys/src/cmd/transpilers is included by mkone/mkmany/mklib for every
APE package. NOTHING IN THE TREE TRIGGERS IT today -- there is no .m,
.cpp, .p or .f outside external/, and everything inside is built by
its own package mkfile -- so these were traps for the next person
rather than live bugs. Said plainly in the file, because an
untriggered rule gets no diagnostic from anyone.

The C++ rules were `cfront $stem.cpp > $stem.c', which is both halves
of the bug cmd/c++lib already paid for: a shell redirection creates
the target whatever the command does (the forty zero-byte .c files),
and cfront is one stage of three -- the driver is rc/bin/ape/c++, and
-F is its translate-only mode. `c++ -F -o $target' now, as c++lib has
used since that round.

`%.c: %.m' was wrong twice over, and the driver script says so rather
than any guess: rc/bin/ape/objc defaults to link=y and output=a.out,
so plain `objc foo.m' compiles AND LINKS, and the foo.c it writes on
the way is the .m with a #line on the front, listed in its own junk
and deleted -- the translated C is foo.i. Objective C has no honest
%.c: rule; it stops at the object with -c.

`%.c: %.p' could not run: p2c has no built-in output name,
codefnfmt comes from p2crc, and trans.c:717 exits `Unable to find
required system p2crc file' without one. -H $PCHOME finds
/sys/lib/pascal/p2crc, whose `CodeFileName %Rs.c' is what makes
foo.p answer foo.c.

CXXFLAGS and FFLAGS were declared and used by nothing; wired in, with
PCFLAGS and OBJCFLAGS beside them. f2c and bacon were already right
and are unchanged.

And rc/bin/ape/p2cc carried a LIVE bug found on the way: it passed
`-H --HOMEDIR--'. Upstream substitutes that token when installing the
script (src/Makefile:113 is a sed), APExp installs it by hand, and
$homedir, $incdir and $libdir were filled in while this one was not.
The guard is what made it reachable rather than harmless -- it fires
precisely when $homedir/p2crc EXISTS, so the better configured the
tree, the more certainly p2cc added the broken flag. perl -c passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
…he open list

The header round: 12 together-case errors -> 8, each drop measured by
re-running the sweep. f2c.h's recommendation is WITHDRAWN -- the
installed copy differs from the build's own by exactly a #pragma lib,
which is the whole reason it exists. Plan9libnet.h deleted. libnet.h
was wrong in both directions: three net_ names declared and defined
nowhere, and reject() defined and declared nowhere. getopt had two
incompatible declarations in two installed headers, not one as
recorded. features.h loses `hidden' (which erased sqlite3.h's member)
and `weak_alias' (safe only because its parameter names matched
gnulib's token for token), with the guard moved into the sixteen and
five private users that need it -- the idiom libm.h and
multibyte/internal.c already used.

The transpiler rules: nothing in the tree triggers them, which is why
three of six were wrong. The C++ rules carried both halves of the
c++lib bug; `%.c: %.m' named a target the objc driver deletes, and
that driver links by default; `%.c: %.p' could not run, since p2c
exits without a p2crc. And p2cc passed a literal `-H --HOMEDIR--',
reachable precisely when $homedir/p2crc exists.

Also recorded: an explicit open list -- EDG/muon/go not started,
chicken/bacon/the archivers built but never exercised. A port that
builds and has never run is not a port.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen
staalmannen merged commit 83b7724 into main Oct 7, 2026
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