Skip to content

APExp release 0.6

Latest

Choose a tag to compare

@staalmannen staalmannen released this 23 Oct 07:33
· 582 commits to main since this release
16eda73

APExp 0.6

APExp is an enhanced ANSI/POSIX compatibility layer for Plan 9 and 9front,
aiming for maximal GNU/POSIX compatibility so that C programs written for
UNIX build on Plan 9 with as little modification as possible.

0.5 replaced the C library's stdio and widened three types. 0.6 is mostly
about what that made possible: GNU coreutils, tar, diff and patch build
and are installed by default, and so do LibreSSL, curl, libzip, pax and
perl. TLS 1.3 works. bash is /bin/sh and builds the tree.

It is also the release in which a long series of compiler bugs were found,
nearly every one of which produced silently wrong values rather than an
error. Several had been corrupting output for as long as they had existed.
That is the reason for the rebuild notice below, and it is not a formality.

The library bugs ran the same way. st_rdev was 0 for every file, so
cmp compared two different files in silence; ino_t was sixteen
bits against a tree of 64799 files; fsync answered failure where the
honest answer was nothing to do, and xz deleted every file it wrote
as a result; and no thread this library ever created reached its start
routine
, because the child half of pthread_create waited on a
rendezvous the parent never answered. Not one of those announced itself
as the thing it was.

APE's struct layout changed. pcc now lays structs out the way every
other C compiler does; see the section on it. That alone means nothing
built before 0.6 can be mixed with anything built after it.

As always, APExp is intentionally unstable between releases. Download the
latest release rather than upgrading in place.

Two ports (go 1.4 and clisp) are deliberately not in the default
build; see Known limitations. Everything else described below is in
the tree, built by default, and measured — and where a thing was
recorded rather than measured, the entry says so in those words.


Rebuild everything — read this first

Anything built before 0.6 is suspect, whether or not it links. This is
not the usual ABI-change warning: the compiler was quietly producing wrong
values in ordinary C, so a binary can link cleanly and still be wrong.

Two of the bugs are the clearest reason:

  • bool was a signed char, so every conversion to it truncated to
    the low byte instead of comparing against zero, as C99 6.3.1.2 requires.
    bool b = 256; was false. (bool)p for any aligned pointer was a coin
    toss on its low byte. The common idiom bool ok = flags & SOME_MASK; is
    false whenever the mask is above bit 7 — there are around 350 of that
    exact shape in the ported packages, and curl alone mentions bool in
    291 files.
  • 6c truncated a live 64-bit value across a 32-bit divide or modulo.
    Every SHA-3 digest was wrong, so ML-KEM was wrong, so every TLS 1.3
    handshake offering X25519MLKEM768 failed. Nothing about that is
    Keccak-specific: a 64-bit value live across a 32-bit % is ordinary C.

Rebuilding the compiler is not enough on its own, and neither is
rebuilding libap. Everything here links statically, so a library fix
reaches only the binaries relinked after it — an old ls keeps the old
hash.c and the old setlocale inside it however many times libap is
rebuilt underneath. That is what "everything" means above.

The order matters, because every architecture compiler consumes y.tab.h
from cc:

cd sys/src/cmd/cc && mk nuke && mk install
cd ../6c && mk nuke && mk install        # and the other ten
cd <repo root> && mk distclean && mk install

Prefer mk distclean to mk nuke at the root. nuke is clean plus
rm -f ... $LIB, and $LIB is $APEXPROOT/$objtype/lib/ape/libap.a —
with $APEXPROOT empty that is an absolute path into the host's own stock
APE rather than into this tree. Every mkfile here assigns APEXPROOT
itself, so it takes a command-line override to get there, but there is no
reason to run into it. distclean loops over a literal architecture list
and touches only ./$arch/bin and ./$arch/lib.

distclean empties those two directories rather than removing them,
and that is load-bearing: apexp-sh binds them, a Plan 9 bind captures a
directory's channel, and rm -rf followed by a fresh mkdir leaves the
running shell looking at a directory that no longer exists. Every lookup
then falls through to the host's own /$objtype/bin, so the next compile
runs stock 9front's 6c and dies on syntax error, last name: bool.
A library that built yesterday stops building and nothing in the message
is about binds. If that shape appears, start a fresh apexp-sh.

There are ABI-visible changes as well:

0.5 0.6
struct tail padding rounded up to 8 the struct's own alignment
nested struct members aligned to 8 their own alignment
bit-field groups reserved a whole 4-byte unit share the container's head and tail
bool / _Bool signed char unsigned char, and converting to it compares against zero
SIZE_MAX 0xffffffff on amd64, beside an 8-byte size_t matches size_t
SSIZE_MAX LONG_MAX, i.e. 32-bit on amd64 matches ssize_t
S_IFSOCK the same value as S_IFIFO 0140000, its own value
struct dirent d_ino/d_type were macros real members
NAME_MAX / PATH_MAX 27 / 1023 255 / 4096

S_IFSOCK is worth calling out: aliasing it to S_IFIFO made
S_ISSOCK() true for every FIFO, and gave duplicate case labels to any
switch over file types.

Source-level changes

<stdio.h> no longer includes <errno.h>, <unistd.h>, <fcntl.h>
and <pthread.h>.
It used to include musl's internal <stdio_impl.h>,
which pulls all of those in, so nearly every translation unit in the tree
saw every O_ and F_ macro by accident. Code that used errno,
open() or pthread_* while including only <stdio.h> compiled by
luck and now needs the right #include — a one-line fix per file, and
each one is a real latent bug.

That leak was not harmless. Portable code guards its fallbacks on whether
a name exists, and libzip's compat.h defines O_CLOEXEC as 0 when it
cannot see one; the definition then collided with the real one arriving
later through <zip.h>.

<features.h> no longer defines hidden or weak_alias. Both are
musl's internal macros and both were in a public header. hidden expands
to nothing, and sqlite3.h:10957 declares unsigned char hidden[48]; —
erased wherever features.h came first, which is a silent struct-layout
change in a public API. Sixteen private libap files carry an #ifndef hidden guard instead, which is the idiom include/libm.h already used.

<stdlib.h> no longer declares uname and getrusage. It defines
neither struct utsname nor struct rusage and includes neither header,
so each struct named in those parameter lists was a new incomplete type
scoped to the declaration — distinct from the real one, and conflicting types for any file that included both. POSIX puts them in
<sys/resource.h> and <sys/utsname.h>, which already declare them
correctly.

<qlock.h> no longer defines Lock a second time. It includes
<lock.h>, which typedefs it, and then carried its own copy behind
#ifndef Lock — and Lock is a typedef, not a macro, so that test was
always true. Two typedef struct { int val; } Lock; define two distinct
anonymous structs sharing a name, which C forbids; kencc tolerated it,
which is why it survived. Sixteen of the public headers could not be
compiled by a standards-strict compiler at all.

Plan9libnet.h is deleted (nothing included it, and two of its three
distinctive declarations named functions that do not exist), and
<libnet.h> — which <sys/socket.h> itself includes — no longer declares
net_accept, net_listen and net_reject, which were defined nowhere
and called nowhere.


Changelog

The sections after this one give the evidence for each line. Where a
thing was recorded rather than measured, the entry says so
— that
distinction is the point of the list, and Known limitations is sorted
by it.

Incompatible changes

  • pcc passes -J: APE structs are laid out the way every other C
    compiler lays them out. Sixteen public structs move — all the sockets
    and locks, plus termios. Native 6c is unchanged.
  • ino_t and dev_t are 64 bits, and struct stat is 104 bytes where
    it was 88.
  • Both of those mean mk distclean before mk install. Nothing
    older can be mixed with anything newer.

New in the default build

  • GNU coreutils, tar, diff, patch, grep, sed, m4, bison, gawk, gettext;
    LibreSSL, curl, libzip, pax; perl 5.42.2 (no XS — Plan 9 has no
    dlopen).
  • bash is /bin/sh and builds the tree. dash is gone.
  • Tcl 9, Tk and itcl, each with its own suite running.
  • EDG's C++ front end, as c++/eccp. It translates, compiles and
    links, templates included, with --instantiate local. There is no
    C++ standard library here and EDG ships none, so the reachable subset
    is the one EDG itself is written in.

Compiler

  • C99/C11/C23 work: VLAs, compound literals, designated initialisers,
    _Generic, bool as a real type, __alignof__, unicode escapes,
    bit-fields.
  • Silent code-generation fixes: hex-float conversion, the 6c spill,
    the sign of zero, mixed-signedness op=, the L-suffix width cap, a
    truncated wide case label, a compound literal not zeroing omitted
    members, and both bit-field layout rules with the static initialiser
    underneath them.

Library, by what the bug did rather than what it was

  • cmp compared two different files in silence — st_rdev was 0
    for every file, so gnulib's same_file() said yes to every pair of
    character specials, and cmp concluded its own stdout was
    /dev/null.
  • Two unrelated files were the same file once a server held more
    than 65536 — ino_t was sixteen bits and a Plan 9 qid is 64. This
    tree alone is 64799 files.
  • xz deleted every file it wrote — fsync answered failure where
    the honest answer was nothing to do.
  • No thread this library ever created reached its start routine —
    pthread_create's child waited on a rendezvous the parent never
    answered. Both archiver hangs were this.
  • Every GNU program in the tree died with a stack fault instead of a
    message
    — gnulib's strerror called itself for ever.
  • Every diff position line was garbage — printf did not know
    %td, and an unrecognised conversion consumes no argument, so every
    conversion after it took the wrong one.
  • Every archive GNU tar wrote was malformed — sizeof(union block)
    was 520.
  • A tab was a word delimiter rather than whitespace —
    isblank('\t') answered false, and bash's syntax table is generated.
  • Plus: getcwd(NULL,n); mktemp's 26 names; fifteen missing
    strftime conversions; 40 wrong strerror entries; dup/dup2/
    F_DUPFD on a buffered descriptor; . and .. in readdir;
    collating symbols in regcomp; umask; poll()'s three POSIX
    violations, two of which can spin a caller; and select() reporting
    a regular file readable, as POSIX requires.

Still open and deliberately so

  • go 1.4 and clisp are out of the default build.
  • Two archiver decode failures, on files produced elsewhere, not
    separated
    — see What's next for the two runs that would.
  • pthread_attr_* are no-ops; detachstate is not honoured.
  • The full list, with what each costs, is Known limitations.

Conforming struct layout

pcc passes -J on every compile, and APE structs are laid out the way
every other C compiler lays them out.
Native 6c keeps the 9front rule,
because native code links the host's own libc.a.

Stock kencc rounds every struct's size up to 8 and aligns a nested
struct member to 8 (6c/swt.c's align(), cases Asu2 and Ael1), so
sizeof(struct{char a[500];}) is 504. Field offsets are still right, so a
memcpy into a local is fine — what breaks is sizeof used as a stride
or a length.
That made GNU tar's union block 520 where the format says
512, so every block landed eight bytes late and every archive tar wrote
was malformed; the reader mis-strode identically, so a correctly formed
foreign archive walked into its own payload and reported This does not look like a tar archive. Both symptoms, one cause.

The flag is -J and the global is named conformalign. It is not a
per-package flag and must not be used as one: it changes every struct the
translation unit sees, <stdio.h>'s and <sys/stat.h>'s included, so one
package built with it against a libap built without it disagrees about
FILE, struct stat and DIR — silently, with no link error, because
every symbol still resolves.
The safe unit is all of APE after a
distclean, or nothing.

The cost was measured before it was taken, by compiling a probe twice
and diffing the two acid dumps. -J moves sixteen structs and they are
all sockets and locks — in_addr 8→4, sockaddr_in 24→16,
pthread_mutex_t 56→40, QLock 32→24, plus termios 32→28 — every one
of them becoming the number every other system says. What is absent is
the result
: FILE, struct stat, DIR, jmp_buf, fd_set, tm,
timeval, dirent, passwd, sigaction, regex_t and sigset_t are
all unchanged, and they are the types the flag's own warning had named as
the reason it was all-or-nothing.

Bit fields share the container at both ends. Under -J a bit-field
group no longer reserves a whole tfield unit. Its tail is shared:
the width advances by ceil((shift+nbits)/8), so the next ordinary member
sits in what is left of the container. And its head is shared: a group
that follows an ordinary member starts at the next available bit, in the
tfield-aligned unit containing that bit, moving to the next unit only
where the field would cross a boundary. That is what C compilers do
everywhere else, and it is what EDG's generated C, perl's struct op and
musl's mallocng header are all written expecting.

In the public headers the tail rule moves exactly one struct —
__res_state, whose unused[3] goes from 368 to 365 and whose size goes
456→448 — plus curl.h's HSTS entry. The head rule moves one more, and it
is the one that mattered: fenv_t, whose bit-field group follows an
unsigned short, so __data_offset was at 24 and __mxcsr at 32 where
gcc says 20 and 28 — and 28 is the number arch/amd64/fenv.s hardcodes,
FSTENV (DI) followed by STMXCSR 28(DI), because the struct is a
transcription of the x87 environment image. Latent rather than live:
nothing in the tree read a member by name, and the 32 bytes the assembly
writes fitted inside the 36 the struct had. It would have bitten the first
time anything read env.__mxcsr.

structalign-test section 9 asserts both rules over nine shapes, and
sys/lib/tests/sualign-model.py checks the arithmetic against gcc on the
build host — twelve shapes, 0 disagreements — before the VM compiles a
line, because kencc's own sources need Plan 9's headers.

And the static initialiser had to be narrowed to match. init1
emitted a bit-field group as one DATA of tfield's width at the
container
, which with either end of that container shared writes over
the neighbouring members — 6l answers multiple initialization, and it
is right, since the same bytes really are written twice. GNU make's
struct function_table_entry is what found it. cc/dcl.c's gbitagg()
emits the group's own bytes one at a time (datblk accepts widths 1, 2,
4 and 8, and a group can span three), and the group boundary is a gap in
the bits rather than a change of container offset, since two groups can
now share one container. The tail rule carried the same defect from the
day it landed
and nothing had statically initialised a struct that
would fire it. bitinit-test.c is the regression test and
bitinit-model.py checks the emitted bytes against gcc's own object,
with the replaced code as a control that fires.

All of it is measured on the machine, after a full mk distclean plus
mk install.
structalign-test 0 under pcc and 29 under pcc -9;
edgscope-probe 6 disagreements -> 0, with its no-preceding-member
control still clean in both runs, so the fix is the following rule
specifically and not bit fields in general; edgtuoff-probe and
__res_state unchanged, which was a written-down refutation
condition and did not fire — every group in those is preceded by a
pointer, so the head rule cannot reach them; bitinit-test 0 with its
no-bit-field control passing. The -9 count was predicted as 30 and the
one-line difference is unattributed; every per-name condition held, which
is the half that was about the rule.

pcc -9 asks for the old rule and exists for the instruments only.
Nothing in the tree passes it and nothing should: structalign-test's
control run and the layout probe's two compiles are both differences
between the two rules
, and with no way to ask for the old one neither
measurement could ever be taken again.


New ports

GNU coreutils 9.11 built and installed by default; sbase is cut back to what only it provides
GNU tar 1.35 with the compressor programs wired up
GNU diffutils 3.12 diff, diff3, sdiff, cmp
GNU patch 2.8
LibreSSL 4.3.2 libressl.a plus the openssl command
curl 8.21.0 libcurl.a plus the curl command
libzip 1.11.4 plus zipcmp, zipmerge and ziptool
paxmirabilis 20240817 installed as pax and cpio; GNU tar is the tar
perl 5.42.2 interpreter and the pure-perl module library
itcl 4.2.3 libitcl.a and itclsh; its own suite runs
BaCon 5.0.3 BASIC-to-C converter, installed as basic; self-hosts to a fixpoint — it converts its own 10518 lines and the result emits byte-identical C
CHICKEN Scheme compiler and runtime
muon a meson implementation
EDG C++ front end libedg.a and cpfe, with c++/eccp as the driver; translates, compiles and links

LibreSSL and curl are built by default, and their public headers are
installed into sys/include/ape with #pragma lib, so #include <openssl/ssl.h> or <curl/curl.h> is enough to link.

TLS 1.3 works, including X25519MLKEM768 — openssl s_client completes
a handshake with a verified certificate chain. Getting there took the 6c
fix above; the route was upstream's own ML-KEM and SHA-3 vectors, which
now live in sys/src/ape/lib/libressl/test and run with mk test.

C++: there is a front end, and it is not a C++ toolchain yet

rc/bin/ape/eccp is the driver and c++ is a one-line forwarder to
it
, so CXX=c++ works for autoconf, for GNU make's default and for
sys/src/cmd/transpilers — whose rules did not have to change at all,
which is the whole value of having gone through a driver. The pipeline is
cpfe (C++ -> C) -> cc -c -> link against libedg.a.

Measured, end to end: a toy with a virtual base, an override, a
template and new/delete goes through cpfe, through cc -c, through
the link, and runs. It did not at first — it failed on a template
instantiation, because EDG's default mode expects an edg_prelink pass
this tree has not got and cannot naturally express. eccp passes
--instantiate local, which emits each instantiation inside the
translation unit that needs it with internal linkage, so nothing is
undefined and nothing collides. The cost is that a template's static
data member, or a static local inside a template function, becomes one
object per translation unit instead of one per program
— a program
resting on that identity is silently wrong, and a single translation
unit cannot show it.

What is honestly absent, and it is the big one: there is no C++
standard library here and EDG ships none.
lib_src is the
libsupc++/libc++abi layer — new/delete, vtables, RTTI, static init,
pure-virtual — and include_c++ is the language-support set. There is no
<vector>, no <string>, no <iostream>. The subset that works is
the one EDG itself is written in
: classes, templates, virtual dispatch,
RAII, new/delete, and bad_alloc/type_info/initializer_list.
Static constructors are a recorded gap — nothing calls EDG's
__call_ctors — so a translated program's static initialisers do not
run. Read it as "kencc can now compile a useful subset of C++", not as
"APExp has C++".

perl

The interpreter runs and loads modules; ExtUtils::Miniperl generates
perlmain.c during the build. Two things to know:

  • No XS extensions. Plan 9 has no dlopen, so xs_init is empty and
    only the pure-perl dist/ and cpan/ trees are installed — the
    fourteen with a .xs are deliberately left out, because a .pm that
    dies inside XSLoader is worse than one that is simply absent.
  • Config.pm is hand-maintained, at sys/src/ape/cmd/perl/Config.pm.
    APExp does not run Configure, so there is no config.sh for
    configpm; it is the companion to the hand-answered config.h and has
    to be kept in step with it.

Tcl/Tk/itcl

Tcl's suite finishes with nothing aborting: Total 68118 Passed 62160 Skipped 5916 Failed 42, 167 files, four minutes, clean exit — measured
on the tree that carries this release's whole ABI move. All 42 are listed
by name in docs/notes/tcl-suite.md, beside the 43 of the previous
baseline, which is the first per-name comparison this suite has had: its
absence is what made every earlier one a total, and a total cannot tell
"nine fixed" from "fifteen fixed and six broken"
. Total and
Skipped are identical to the digit across the two runs
, so 43 → 42
is a statement about the same population: one fixed, nothing broken, and
the name is io-52.22.1. It stays unattributed — nothing this round was
aimed at it, and inventing a mechanism to fit a number is how the earlier
rounds went wrong. That an ABI change of this size moved exactly one
test is the result the re-run existed to get.

Tk's suite: Total 10027 Passed 8926 Skipped 924 Failed 177, clean exit.
Most of the remainder is out of reach here — a second wish process, an X
property, a system tray, a scalable font, or a constraint that fails on
Linux too. This number is also a regression that was caught and
reversed
: for one build wish showed a white window and the suite
froze on bell.test, the first of 97 files, and nothing in Tk had
changed — it was select()'s new regular-file arm answering for rio's
/dev/mouse. See libap below. Failed 177 is identical before and
after.

itcl builds and runs first try: Total 792 Passed 716 Skipped 66 Failed 10, and the remaining ten are upstream's or Tcl 9's, two of them settled
at source. Nothing uses stubs — Plan 9 has no dlopen, so itcl links
straight into itclsh, and Tcl_StaticLibrary is the load-bearing call
rather than Itcl_Init: without it the commands exist but package require Itcl goes looking for something to load.

Two test binaries were being deleted and never rebuilt.
cmd/tclsh/tcltest and cmd/wish/tktest were V: targets reachable from
nothing while each mkfile's clean rule named them, so mk distclean
removed them and the next suite run used the ordinary shell — where Tcl's
suite skips 5317 extra tests and reports 27 fewer failures. A falling
failure count beside a rising skip count is not an improvement.
Both
harnesses now refuse or warn when the test interpreter is absent.

bash is /bin/sh

dash is gone from the tree. bash serves every sh the build asks for,
and a full mk distclean plus mk install completes with it.

Getting there was five separate bugs, and the one that mattered was
isblank('\t') answering false. bash's syntax.c is generated by its
own mksyntax, whose addblanks() is if (isblank(uc)) lsyntax[uc] |= CBLANK; — so the shipped table gave TAB CSHBRK and no CBLANK, which
made a tab a word delimiter rather than whitespace to skip. The lexer
then returned an endless stream of empty WORD tokens, the parser appended
each to one simple command, and bash died of Killed: Insufficient physical memory after about 17 million 16-byte list nodes. Every
tab-indented script file. The table is corrected by hand, because it is
checked in and the mkfile compiles rather than regenerates it.

bash's own suite now runs to completion: 49 of 86 files pass, and of
the ~1015 differing lines in the rest, roughly 950 are platform limits
with no bug behind them — no tcsetpgrp (job control), no /dev/fd
(process substitution), no dlopen (loadable builtins), no /etc, and
whole-second file times. The harness is rc/bin/bash-runtests, which
exists because three preconditions fail silently: THIS_SH must name a
bash that exists, four helper programs must be built, and stdin must be
redirected (one test runs a command named p, which on 9front is the
pager and blocks for ever).

config.h was wrong in both directions. Fourteen features were
#undef — arrays, ((, [[, extglob, brace expansion, aliases,
programmable completion, help, history expansion, the restricted shell —
every one of them compiled, linked and switched off by a commented-out
line. And two capabilities were claimed and absent: HAVE_DEV_FD (Plan
9 binds the fd device at /fd, and a /fd entry names the descriptor of
the process that opens it, so it is useless for a child) and named pipes.
A hand-maintained capability file is wrong in both directions, and the
two kinds fail differently — a denial costs a feature silently, a claim
costs a crash.

vts

sys/src/cmd2/vts is a VT emulator built on libvterm, served over 9P,
with two front ends: vtwin (a rio window) and vts-attach (a dumb TTY,
for ssh or drawterm). ./apexp-sh -v launches a bash session inside it.

It exists because rio speaks no escape sequences. Under vts, arrow keys
work
, $TERM is vt100 rather than dumb so readline redraws instead
of reprinting, and the session has a real character grid to report as
$COLUMNS. Tab completion works under rio too, but the arrows do not —
rio eats them before bash sees them, and no program can get them back.


Compiler correctness fixes

Nearly all of these produced wrong values with no diagnostic.

Converting to bool truncated instead of comparing (cc/lex.c,
cc.y, com.c). _Bool and bool were mapped onto LCHAR, which the
grammar turns into BCHAR. They now have their own token and their own
Type, marked with Type.isbool — a field rather than the identity of
one object, because copytyp() is a struct copy and a type is copied
whenever it is used for a parameter or a const. The comparison is
applied at all five places a conversion happens: cast, assignment,
return, argument passing, and auto initialisation, which has its own case
in tcomo separate from assignment.

false did not evaluate to 0 (cc/lex.c). itab's third column is a
type index applied as s->type = types[...], and true/false were
written into it as 1 and 0 as though it were a value. Nothing set
yylval.vval, which is what the grammar reads for LCONST, and yylex
had already stored a symbol pointer into the same union member — so both
keywords arrived carrying a pointer.
Every x = false, return true;
and flag == false in every native C23 program had junk in it. APE code
was untouched, because APE's <stdbool.h> defines them as macros — which
is exactly why no test under sys/lib/tests could have caught it, and why
truefalse-test.c is the one native test in that directory.

A fixed register was spilled at the operation's width, not the
register's
(6c/cgen.c). 6c spills AX, CX or DX where the instruction
it is about to emit can only use that register — a divide needs AX and DX,
a variable shift needs CX — and sized the spill slot from the operation.
A 32-bit % therefore saved four bytes of a register holding eight. The
trigger is <expression containing / or %> op <64-bit function call>.
Only 6c has this: 8c is 32-bit, and the RISC back-ends need no fixed
register for division.

Unsigned 64-bit to floating point was wrong in both directions
(cc/scon.c, 6c/txt.c). Constant folding read the value back as signed,
so (double)(uvlong)~0 was -1.0; at run time the top-bit case computed
the right answer and then never stored it. gnulib's hash.c compares
SIZE_MAX against a float, so hash_initialize returned NULL and every
program that hashes — cp, mv, ln, du — died with "memory
exhausted" before looking at its arguments.

A compound literal did not zero the members its initialiser omitted
(cc/dcl.c). C99 6.7.8p21 says an omitted member is initialised as one
with static storage duration would be. compoundlit() lowers a literal to
a hidden auto and calls doinit(), which assigns only the members the
list names — while an ordinary T x = {...} is doinit() followed by
contig()
, which zeroes every byte the initialiser did not cover.
compoundlit() was the one caller of doinit() in the compiler that
never had the second half.
muon crashed before it read an argument,
because tstr_init ends *sb = (struct tstr){.flags=..,.buf=..,.cap=..}
with .len omitted and then uses len as a memset length.
contig() could not simply be called — its bulk arm emits a statement and
everything a compound literal builds has to survive in expression context
— so clitzero() reuses its trims and spells the loop out as
straight-line stores.

A single L capped a constant's width (cc/lex.c). The widening path
was guarded by "no suffix", so convvtox(vv, TLONG) threw away every
significant bit of a constant written 0x0200000000000000L — the normal
spelling on any LP64 system, and the one every upstream header uses. C99
6.4.4.1 says the opposite: L takes the first of long, unsigned long,
long long, unsigned long long in which the value can be represented.
L is a floor on the type, not a ceiling. CHICKEN's fourteen header
tags all became 0.

A 64-bit case type is not a 64-bit case value (cc/pswt.c).
doswit discarded every case whose type was wide, in a switch whose
expression was 32 bits, under the comment "can never match" — a sentence
about a value too wide to appear, applied to a small number with a wide
type. C 6.8.4.2p5 says a label "is converted to the promoted type of the
controlling expression", so a wide label is truncated, not discarded.
Silent: the file compiled and the arm was never reached. The loud half
beside it was that the case count was taken before the drop, so qsort
and the duplicate scan ran over entries that were never written —
duplicate cases in switch 0, naming a case the program does not contain.

A comma expression's type decayed, so sizeof an array compound
literal was the size of a pointer
(cc/com.c). compoundlit() builds
(type){...} as OCOMMA(initialisation, ONAME), and the OCOMMA case
typed its right operand with tcom() — which is tcomo(..., ADDROF), and
so turned the array into a pointer. sizeof types its operand with
tcomo(l, 0) precisely to stop that happening, and the flag was being
thrown away one level down:

sizeof((int[]){1,2,3,4,5,6,7})   /* 8, not 28 */

That is the standard way of counting variadic arguments, so
ARRAY_CARDINALITY over a compound literal answered 1 for any array of
pointers. bison's muscle_kind_new uses it to size a table and aborted.

A designator was resolved in the wrong scope (cc/dcl.c). C99
6.7.8p17 makes a designator relative to the object of the enclosing
brace list; init1() restarted its member walk at whatever level it had
reached. Two members of the same name at different depths were enough, and
when the two have the same type there is no diagnostic at all — the
value simply lands at the wrong offset.

auto size_t x; did not parse (cc.y). autoadlist began with
xdecor, which reaches LNAME | LTYPE, so after LAUTO the parser could
shift a typedef name as the variable being declared — and yacc resolves
shift/reduce in favour of shift, so the C23 deduction path won over the
storage class. -std= would not have fixed it: the conflict is resolved
when yacc builds the table, and there is no dialect disagreement to
arbitrate, since C23 kept auto as a storage-class specifier and its type
inference applies only where auto is the sole type specifier. EDG's
generated C writes auto <type> <name>; for every local — 116,079 of them
across 103 of 133 files.

6l and friends can be asked for COMDAT (cc/, the ten back-ends).
The linkers have always skipped a duplicate ATEXT carrying DUPOK and
suppressed multiple initialization for duplicate DATA — the one
missing piece was a way for C to set the bit.
pcc -C is it. It is
blunt and the mkfiles that use it say so: it marks every TEXT and GLOBL in
the translation unit, not the vague-linkage ones, so two genuinely
different functions of one name become first-wins rather than a
diagnostic. Safe for generated C, where every duplicate is the same entity
by construction; nothing else in the tree passes it.

Also fixed:

  • Compound assignment chose its opcode from the wrong type
    (cc/com.c). E1 op= E2 with a signed E1 and unsigned E2 did the
    operation signed. Still wrong in a second way, and a larger job: kencc
    performs the operation in the lvalue's own width, so
    long x; x /= (uvlong)y; divides in 32 bits on amd64 where C requires
    64.
  • &(struct S){...} now works; the comma is hoisted out of OADDR.
  • A designator list can walk back out of a nested aggregate.
  • char * against unsigned char * warns rather than refusing. This
    is -Wpointer-sign, which gcc and clang do not treat as an error, and
    portable code is full of it. One level only, and only for the five
    signed/unsigned spellings of the same type.
  • pcc forwards -a and -Z, so a layout can be read out of the
    compiler; -c is required with them, since with -a the compiler
    writes acid to stdout and makes no object.
  • pcc no longer appends -J to every invocation as an
    "old/new decl mixture hack". Stock cc names no -J, so it fell to
    ARGBEGIN's default and set a debug counter nothing reads — a pure no-op
    for its entire life, until the letter was given a meaning.
  • cpp: the #include nesting limit was a bare 20 and is now
    NINCDEPTH, 200, which is what gcc and clang use — LibreSSL reaches 20
    on an ordinary chain with nothing repeated in it. #elif is no longer
    evaluated once a group has been selected, and #if does unsigned
    division without relying on the compound-assignment bug above.

Headers and types

<string.h> reached Plan 9's <u.h>, by way of wchar.h,
time.h, signal.h, pthread.h and lock.h — so asking for strlen
also defined nil, uchar, ushort, ulong and uint. Every link in
that chain existed for a single pointer parameter and is now a forward
declaration; string.h and wchar.h had also been including each
other, so what a file saw depended on which it asked for first.

SIZE_MAX was 32-bit on amd64 while size_t was 8 bytes, and
SSIZE_MAX was LONG_MAX with the same problem. The cause is worth
knowing because it will recur: stock APE keeps float.h, stdarg.h and
stdint.h in the architecture directory, which pcc searches before
/sys/include/ape. APExp's copies were never read on any architecture.
Worse for stdint.h, whose stock copy takes the same include guard as
APExp's arch header, so APExp's compiled to nothing. All three are now
shadowed by a real file in every architecture directory.

The symptom was GNU ls reading off the end of the heap, via a gnulib
line that means "no length given" when it sees SIZE_MAX.

NAME_MAX was 27 and PATH_MAX 1023, set in sys/limits.h, which
<limits.h> includes at its very end and which #undefs and redefines
what the outer file had just set. 255 and 4096 now. That file also carried
two dead values — NGROUPS_MAX 10 and PIPE_BUF _POSIX_PIPE_BUF —
which were never in effect and existed only to break any translation unit
that reached the two headers in the other order.

FLT_MAX was not FLT_MAX. C says FLT_MAX, FLT_MIN and
FLT_EPSILON have type float, and float_arch.h wrote them with no
F suffix
, so each was a double holding the nearest double to a rounded
decimal — 3.4028234999999998e+38 against a true 3.4028234663852886e+38,
about 3.4e30 too big.

Four headers could not be included from C++, every one of them a
parameter name or a keyword and so invisible to a C caller: stdlib.h's
unguarded _Noreturn and its parameter named template, unistd.h's
parameter named new, and signal.h's restrict read as a duplicate
parameter name. restrict becomes __restrict, which costs nothing
because kencc lexes all three spellings to the same token; the two
parameters are renamed, which no caller can see. The obvious fix for two
of them would have been a #define of an unreserved name in a public
header
, which is exactly the mistake that had broken the build one round
earlier — see reject, below.

Other header work:

  • __BYTE_ORDER was never defined on any architecture.
  • O_DIRECTORY was 0, so the whole *at family ignored real directory
    descriptors. The O_ flags Plan 9 lacks are now defined as 0
    deliberately, and documented as such.
  • <float.h> gained the C99/C11 macros; <sys/statvfs.h> and
    <sysexits.h> are new; <locale.h> no longer declares two of musl's
    file-local helpers; <stdint.h> lost the u8/u32/s8/s32
    typedefs that collided with everything.
  • <termios.h> gained TCIFLUSH, TCOFLUSH and TCIOFLUSH, which were
    the only one of POSIX's four groups absent while tcflush(int, int) was
    declared — a function the header promised whose second argument could
    not be named.
  • <netinet/in.h> gained the IPv4 multicast options and struct ip_mreq;
    the IPv6 spellings had all been present and the IPv4 ones had not.
  • <values.h> is new, and every value in it is derived from
    <limits.h>/<float.h> rather than transcribed.
  • getopt was declared incompatibly in two installed headers; bsd.h now
    matches getopt.h and POSIX.
  • Tk's and Tcl's public headers are installed and usable. tcl.h had been
    installed alone while its line 2433 includes tclDecls.h, which was not
    installed at all — so #include <tcl.h> from outside Tcl's own build
    had always been a fatal error on the first line.
  • S_IXUGO is spelled the way everyone else spells it. Macro identity in
    C includes whether there is white space between tokens, so a
    definition differing only in spacing is a redefinition error.

Before adding any name to a public APE header, grep external/ for the
bare word.
Declaring reject in libnet.h — which <sys/socket.h>
includes — broke flex, whose flexdef.h:366 has extern int reject;, a
variable. A function-shaped grep cannot match a variable. A public
header's blast radius is every package in the tree, and no instrument here
measures that: apehdr-sweep compiles the APE headers against each other,
while that collision arrived from a package's own header.


libap

  • posix_spawn honours file actions and attributes. It was fork+exec
    with everything discarded, so posix_spawn_file_actions_adddup2()
    returned 0 and did nothing. Undetectable by the caller, and gnulib's
    spawn-pipe.c wires its pipe to the child entirely through adddup2.
  • vsnprintf left the buffer untouched when it formatted nothing,
    and reported a truncated length when it ran out of room. It was built
    on fmemopen, whose write hook only lays down the terminating NUL
    after a write, so snprintf(buf, n, "%s", "") returned whatever the
    buffer held before; and the same hook's short write at the end of the
    buffer made the return value the length written rather than the length
    that would have been (C99 7.19.6.5p2 and p3), which quietly breaks
    measure-allocate-format-again. musl's own implementation replaces it.
    GNU m4's format() is what found it, and every parser bison generated
    had a doubled comma after each token as a result.
  • printf did not know %td, %jd, %hhd or %F. An unrecognised
    conversion prints the letter and consumes no argument, so
    printf("%td", n) printed the literal text td and left n in the
    va_list — every conversion after it in that format string took the
    wrong argument.
    diffutils has #define pI "t" and prints every line
    number through it, so every diff position line on this system had
    always been garbage
    : 1,2d0 came out td\x01tddtd. %g with a
    precision of 0 and the 0 flag beside a precision were wrong too; a
    precision of zero is a specified precision, and the test read
    precision <= 0.
    vfscanf has handled all three length modifiers since it was
    written.
    The library knew these on the input side and not the output
    side.
  • strftime was missing fifteen conversions — C D e F G g h n r R s t T u V — with the same silent failure mode: the default: arm writes
    the conversion character out as a literal, so %F printed F. And %c
    and %x were wrong rather than missing, against POSIX's fixed C-locale
    definitions.
  • strerror was wrong in 40 of 76 entries, and two named the wrong
    error.
    The table said EACCES "Access denied" and EPERM "Permission denied" — and Permission denied is what every other system prints for
    EACCES. So the one message a reader is most likely to recognise
    named the wrong errno, and anything matching on it drew the opposite
    conclusion. The other 38 were merely terse. The table is generated
    from errno.h and glibc rather than transcribed, and every row now
    carries its name.
  • strtod is Gay's now, and correct. The file it replaced was wrong
    on 148018 of 199887 round-trips (74%) and said so in its own first line
    for as long as it existed. Four of the six bugs were in the shared Bigint
    kit, and all four are one sentence: Gay's arithmetic needs a 32-bit word
    and spells it long
    — true under kencc and false under gcc, so the code
    was correct on Plan 9 by accident. One of those four also broke _dtoa
    in the shipping printf path, where subnormals printed as ?.
    strtof needed more than (float)strtod: rounding to 53 bits and then
    to 24 is not rounding to 24, and 12709 of 39694 decimals built to sit on
    a float midpoint came out wrong.
  • scalbn had 2^1023 where musl writes 0x1p1023 — an integer
    exclusive-or, 1021. scalbnf.c had the same with 127. Every subnormal
    any program reached through ldexp was wrong, some with the wrong
    sign
    , and the host cross-check that had passed scalbn used an
    exponent window that never entered the broken branch.
  • mktemp could produce 26 names per process, ever. It wrote
    getpid() % 100000 into five of the six X's and tried one trailing
    letter a..z. mkstemp's twenty retries re-derived the same
    twenty-six, since nothing in them varied — a retry is only a retry if
    something varies between the tries.
    The right generator, musl's
    __randname, was already in the same directory and already in OFILES.
  • getcwd(NULL, n) killed the process. It passed its argument
    straight to _FD2PATH with no null check, so the POSIX.1-2008
    "allocate it for me" form — which a great deal of GNU code uses — handed
    the kernel address zero. bash had already detected this and shipped its
    own fix, and the link order threw it away.
  • umask() discarded its argument and always answered 0. libap is the
    code that chooses the permission it hands _CREATE, at exactly two
    user-facing sites, so storing it is not inventing semantics — and it
    composes with the file server rather than fighting it, since Plan 9
    already hands out perm & (dirperm | ~0666) and a umask may only ever
    remove bits. The initial mask is 0, not 022: a conformance fix should
    not also be a default change.
  • dup() and dup2() refused any descriptor that had been
    select()ed.
    Both are one line of fcntl(.., F_DUPFD, ..), whose
    buffered-descriptor arm answered EGREG. A descriptor becomes buffered
    the first time anything selects it, so any program with an event loop
    had lost the ability to dup the descriptors it was watching
    — select
    being how an event loop works and dup being how a shell redirects.
  • readdir returns . and ... Plan 9 directories contain neither,
    so glob .* was missing them and two independent suites said so. The
    inodes are real rather than 0 — . from the stream's own descriptor,
    .. through fd2path — because find's loop detection, the classic
    getcwd and du's hard-link check all read d_ino. No new field, so
    sizeof(DIR) does not move.
  • regcomp accepts [[.x.]] and [[=x=]]. There is no collation
    table anywhere in TRE — the engine compares encoded values — so the C
    locale is what every comparison already implements, every equivalence
    class is a singleton, and a collating symbol naming one character is
    that character. A multi-character element still answers REG_ECOLLATE,
    and an equivalence class is refused as a range endpoint, because it
    names a set and so has no position in the order.
  • random, srandom, initstate and setstate exist, bit-compatible
    with glibc and 4.4BSD deliberately: a seeded sequence is something
    programs reproduce across machines, so "a generator with the right
    distribution" is not the specification — the numbers are.
  • isblank('\t') is true, and isprint is a function. isprint's
    mask was (graph bits | _ISblank) and used _ISblank as a stand-in for
    "space", correct only while space was the sole character carrying it.
  • strtoull's overflow threshold was effectively disabled
    (1LL<<63 is LLONG_MIN, and the signed division that followed gave a
    negative quotient), strtoll(LLONG_MIN) answered ERANGE for a value
    that is exactly representable, and strtoX("0x") with no hex digit
    reported no conversion where C says the subject sequence is the longest
    initial subsequence of the expected form.
  • close() on a listening socket freed nothing. listen() replaces
    the descriptor with a pipe and forks a child holding the real network
    fd, so close() shut a pipe while the announcement lived in another
    process. This was the hundred leaked listenproc processes. The pid
    is recorded keyed on dev/ino rather than on the descriptor number,
    because dup2() and raw _CLOSE() retire a number without clearing —
    and a stale entry SIGKILLed the wrong process and froze a suite.
  • socket -async has never worked, and now does: connect() on an
    O_NONBLOCK descriptor forks to do the ctl write and returns
    EINPROGRESS, the child reports its errno down a pipe, and
    getsockopt(SO_ERROR) — which returned a hard-coded 0 — gives the real
    answer.
  • A failed execve() destroyed the caller. POSIX: "If the exec
    function returns to the calling process image, an error has occurred;
    the process image is unchanged." libap's did the opposite — _RFORK,
    then /env/_fdinfo and /env/_sighdlr rewritten, then every
    FD_CLOEXEC descriptor closed, all before _EXEC was tried. It now
    opens the file OEXEC first, which is the same question Plan 9's own
    exec asks, and the closes moved to immediately before the exec.
  • A descriptor arrived poisoned from an exec. FD_BUFFERED becomes
    FD_BUFFEREDX in a forked child, and execve wrote the flags word
    verbatim into /env/_fdinfo where the new image applied it verbatim —
    so any program started by an APE parent that had ever selected on a
    descriptor inherited it unreadable. FD_BUFFERED/FD_BUFFEREDX are
    facts about a process image, not about a descriptor.
  • The select copy process was a keystroke thief. libap's select()
    does not poll: it forks a process that reads continuously for the life
    of the caller, so an interactive bash permanently read its window's
    /dev/cons and partitioned the input with its own parent. For a tty the
    copy process now sleeps unless a read has been asked for.
  • tcsetattr on a real /dev/cons returned 0 and changed nothing,
    while tcgetattr reported a hardcoded ICANON|ECHO whatever the
    console was doing — so readline asked for raw, was told it got it, and
    waited for keystrokes the driver was holding until Enter. Both halves
    silent. plan9/tty.c now owns the one switch Plan 9 offers
    (rawon/rawoff on /dev/consctl) and termios drives it.
  • $TZ reached nothing. tzset() parsed getenv("timezone"), Plan
    9's spelling, while localtime_r separately read /env/timezone once
    per process into a static of its own, and neither had heard of TZ.
    Nothing set tm_gmtoff/tm_zone either, so strftime's %Z was a
    hardcoded {"EST","EDT"} under a comment reading "hack for now: assume
    eastern time zone", and %z did not exist. time/tzone.c is the single
    engine now — POSIX TZ strings with DST rules, /env/timezone as the
    fallback, UTC with an empty name when neither parses.
  • rename() of a directory into a different directory always failed
    (the cross-directory copy path opened the destination for writing, and a
    directory cannot be), and a directory moved into itself is now detected
    by qid up the tree rather than by string.
  • Three more stdio bugs, all found by flex. objc's scanner is the
    only thing in the tree that runs flex, so it had never worked here,
    and it uses all three within twenty lines. fseek set the error
    indicator when the seek failed
    — C99 7.19.9.2 says it returns
    nonzero and nothing more, and a stream you cannot seek is not a stream
    that has failed; a pipe is unseekable, so probing one poisoned it for
    good. freopen returned a new stream instead of reopening the one
    it was given
    (7.19.5.4), which on a permanent stream did nothing at
    all, leaving stdout on the terminal. fclose did not close the
    standard streams
    — F_PERM means the FILE is static, not that the
    file stays open (7.19.5.1), so closing stdout to signal end of input
    to a pipeline silently didn't.
  • ungetc refused a stream that had not been read from yet, against
    C99 7.19.7.11's guarantee of one character of pushback.
  • isatty followed a stale flag, not the descriptor, so a descriptor
    that was the console in the parent and a pipe in the child still claimed
    to be a terminal.
  • sigset_t held three signals. sigaddset/sigdelset were gated on
    a mask built by ORing signal numbers together, so only 0, 1 and 2 were
    accepted; sigfillset() produced a set naming SIGHUP and SIGINT alone.
  • signal() is prototyped. It had been the unprototyped
    void (*)() so that libap's three-argument Plan 9 dispatch stayed
    reachable — a public declaration that turned off argument checking for
    every caller in the tree. The extension is unchanged and still
    dispatched; the cast lives at the one place that calls a handler.
  • execvp searches PATH. It prepended /bin/ and gave up.
  • setlocale reports the locale it set. It ignored the name and
    answered "C.UTF-8" to everything.
  • getprogname() returned argv0 — lib9's global, filled from
    ARGBEGIN, an rc idiom no APE program executes. So it was NULL unless
    the program happened to call getopt_long, which set it as a side
    effect, and gnulib's error() is #define program_name getprogname().
    Every GNU program in the tree printed its diagnostics with no program
    name.
    argv0 is set in plan9/callmain.c now, the one path every APE
    program takes.
  • O_NONBLOCK on a regular file sent reads into the buffered copy-process
    path
    , so a regular file reported "would block" and an empty one said
    fblocked 1, eof 0 for ever. POSIX: O_NONBLOCK does nothing to a
    regular file.
  • i/o on hungup channel mapped to ESHUTDOWN where POSIX wants
    EPIPE.
  • The _unlocked family is real. It existed only as four macros in
    musl's internal header, visible by accident through the <stdio.h>
    leak. All fifteen are functions in libap now.
  • New: timespec_get, fdopendir, initgroups, arc4random_uniform,
    __fpurge, strerrorname_np, ESTALE, EDQUOT and the tail of
    sys_errlist, IFTODT/DTTOIF, DT_WHT.

st_rdev was 0 for every file, and it made cmp silent. gnulib's
same_file treats two character specials with equal st_rdev as the
same device and therefore the same contents, so with a constant every
char special matched every other. cmp asks whether its own stdout is
/dev/null in order to skip describing a difference nobody will read —
and under a terminal stdout is /dev/cons, a char special, so cmp
compared two plainly different files and printed nothing
, with only
the exit status still correct. diff -r had the same fault at
diff.c:1300, reporting every pair of special files identical without
reading them. _dirtostat now sets st_rdev to the qid for the
character and block cases and leaves it 0 elsewhere, which POSIX permits
and which is true of Plan 9: two char specials are the same device if
and only if they are the same file. rdev-test.c is the regression
test.

ino_t and dev_t were 16 bits, and struct stat is now 104 bytes
rather than 88.
_dirtostat assigns st_ino = d->qid.path, so every
inode was a 64-bit qid truncated to sixteen bits and two unrelated files
compared as the same file once a server held more than 65536 of them —
the APExp tree alone is 64799. Everything that identifies a file by
dev+ino was exposed: same_file in diffutils, find's loop detection,
du's hard-link accounting, fts, tar, and libap's own listener
table. This is the release's second ABI change and the mk distclean that -J already required covers it. Two things it corrects
without being touched: musl's <sys/sysmacros.h>, whose
major/minor/makedev already assumed a 64-bit dev_t, and perl's
config.h, which already declared ST_INO_SIZE 8.

poll() obeys three POSIX rules it did not. It returned select()'s
count of ready bits across three fd_sets where POSIX wants the number
of pollfd structures with nonzero revents; it skipped a negative fd
when building the sets and not when reading them, so FD_ISSET(-1, ...)
read out of bounds and the result became a revents the caller
believed; and it had no POLLNVAL, so one closed descriptor failed the
whole call instead of marking that entry. The first two can make a
caller spin rather than merely get an odd answer
— a loop of the shape
while(true){ if(poll(...)==0) break; if(pfd[0].revents) break; } never
sleeps when poll returns positive without marking the entry watched.
poll-test.c is the regression test.

select() reports a regular file readable, as POSIX requires — and
the predicate for "regular" is _selregular(), not S_ISREG(), which
is a whole bug on its own. libap's select buffers every watched
descriptor through a copy process and answers from what that process
has collected, so a regular file came back not readable until the
first read completed, though POSIX says one is always ready and cannot
block. The fast arm reports it ready without buffering it — which is
sound only for a file that genuinely cannot block, and on Plan 9
S_IFREG does not say that.
_dirtostat has no device-type bit to
read, so it takes Dir.type: a directory, then | and s for pipes
and sockets, then anything that is not M is a character special, and
everything left, meaning every file reached through a 9P mount, is
called regular.
rio serves /dev/cons, /dev/mouse, /dev/winname
and /dev/snarf that way. The first version of this fix used
S_ISREG() and left wish showing a white window, frozen on the first
of Tk's 97 test files
, because Tk polls the mouse with a zero timeout
and then does a blocking read of whatever select marks. _selregular
adds a positive length, which no Plan 9 device file has and no file
whose readiness matters lacks; an empty regular file falls back to the
buffered path, whose bug is a race and not a wrong answer.
sys/lib/tests/devreg-probe.c measures it, and Tk's suite is back to
Failed 177, identical to the pre-regression run.

pthread_create never ran the thread, and three bugs said so at
once.
Nothing in the tree had exercised it until xz, which is
multithreaded (liblzma/common/stream_encoder_mt.c).

  • The child half did _RENDEZVOUS(tag, 0) and the parent never
    answered
    — that was the only _RENDEZVOUS in the whole thread
    directory. So every thread ever created blocked before reaching its
    start routine
    , while its creator was told the call had succeeded.
    The handshake is not decoration: pthread_exit asserts
    _pthreadget(pthread_self()) and pthread_join looks the thread up
    the same way, so the parent has to register the child's pid first —
    and _pthreadsetpid already existed with no callers anywhere.
  • *t was never written, so every caller handed whatever was on
    its stack to pthread_join.
  • attr != NULL returned EINVAL, and libap's own
    pthread_cond_timedwait always passes one
    , so it returned EAGAIN
    without ever waiting, on every call, for its whole existence. A
    caller that loops on it — xz's wait_for_work — becomes a busy-wait
    made of clock_gettime syscalls, which on Plan 9 is a _PREAD.
    That is why the system figure sat at the maximum while the user
    figure did not.

All three are fixed. Every pthread_attr_* remains a no-op and
detachstate in particular is not honoured
— accepting the struct
says only that; rejecting it never made detachstate work, it only made
the call fail. sys/lib/tests/pthread-test.c is the regression test and
is the first here that can hang, so the first that arms a SIGALRM.

fsync() answered failure, and xz deleted every file it wrote. It
was errno = EINVAL; return -1. xz's io_sync_dest turns a nonzero
fsync into success = false and io_close_dest(pair, false) then
removes the destination; opt_synchronous is on by default, so
this was every xz and unxz on a named file, every time — the bytes
correct, written, and thrown away on the way out. Nothing in
"Synchronizing the file failed" says "your output is gone".
This is
the stub-answers-failure family, and libap already held the right
answer in a second place that disagreed with the first:
plan9/__p9_syscall.c reads case SYS_fsync: /* Plan9 writes are synchronous; no-op is correct */ return 0;. Plan 9 has no fsync
because a write to a file server is already acknowledged when write
returns; there is no local cache to flush. It answers 0 for an open
descriptor and EBADF otherwise — a function that cannot fail is its
own kind of lie
, which is why fsync-test.c has a section for a
closed descriptor as well as an open one.

gnulib

One shared libgnu.a now serves coreutils, tar, diff, patch, grep, sed,
m4 and bison, with a config-common.h plus a per-package config.h.
Roughly forty modules were added over the release for the new packages,
and a dozen dropped because libap supersedes them.

The rule that matters when adding one: gnulib's replacement system
headers are not used — they shadow APE's — so a module that needs a
declaration needs it in the real header.

And a module libap already provides is a problem whether or not ar
says so.
strerror.$O was in libgnu.a, and gnulib's strerror.c
defines the plain name and then calls strerror expecting to reach the
system's — an arrangement that works only because gnulib's generated
string.h carries #define strerror rpl_strerror. Nothing generates
those headers here, so the function called itself for ever and every GNU
program in the tree died with a stack fault instead of a message
, reading
as a different bug every time. The idiom (a definition of NAME followed by
#undef NAME) is in 34 places across 24 files in that tree, and exactly
one of them was in OFILES; the sweep for it is rule 6 of the directory's
README so that it can be repeated when OFILES grows.


Testing

The tests in sys/lib/tests are standalone programs. Each prints
PASS/FAIL per case, exits with the number of failures, and opens with
a comment recording which bug it came from and what that bug cost:

cd sys/lib/tests && pcc -o bool-test bool-test.c && ./bool-test

Anything testing a language or library rule should also be correct on
gcc, and checking a new test against gcc first is how you find out
whether the test or the tree is wrong. It has caught both.

Five kinds of thing live in that directory and they are not
interchangeable:

  • Tests assert and exit with a failure count.
  • Probes report and assert nothing — anything asking about one
    operating system's own behaviour is a probe, not a library rule.
    devreg-probe is the one with no host form at all: its subject is
    what rio serves, so a Linux build would measure a machine that has
    neither rio nor /dev/mouse.
  • Sweeps ask one question of the whole tree, and each one's header
    says whether it gates the build.
  • Models transcribe a function that cannot be compiled here and
    check its arithmetic on the host — they exist because kencc's own
    sources need Plan 9's <u.h>, so the first build of any compiler
    change is the VM's.
  • Cross-checks are host programs, run on Linux rather than on the
    VM. The strongest pattern here is to link the unit under test into a
    glibc program beside the reference implementation: tz-xcheck.c
    swept 1.4 million instants against localtime_r and found two bugs
    with no VM round at all. It applies to anything that is a pure
    function of its input, and it is how strtod, strtof, _dtoa,
    strftime, strtoll, random, regcomp's collation, ctype and
    strerror were all settled.

A control is part of an instrument, not an optional extra. A check
that cannot fail is not a check, and several here passed for the wrong
reason before anyone looked: poll-test's section 1 originally used a
pipe, whose read end is never writable, so the defect it was written for
was unreachable. The habit that catches it is to replicate the replaced
code beside the new and confirm the instrument notices —
poll-test reports 4 that way, pthread-test 3, fsync-test 1,
bitinit-model --old 6 of 7.

And no output is not a pass. A fault, a kill and a clean finish all
just give the shell prompt back. pthread-test and fsync-test set
line buffering and print a marker before their first real call for that
reason, and pthread-test arms a SIGALRM that names the section it
died in — it is the one test here that can legitimately hang.

Several carry a version marker — _sock_listenmark(), _execmark(),
_ttymark(), _getcwdmark(), _printfmark(), _dupmark(),
_dotdirmark(), _tempmark(), _fdinfomark(), _umaskmark(),
_bufmark(), _rdevmark(), _selregmark(), _pthreadmark(),
_syncmark(). pcc -o x x.c relinks against the installed libap, so
a test built from a fresh pull can run days-old library code and say
nothing. A marker makes that a link error instead. The idiom has paid
eleven times, and it matters most where the bug's whole symptom is that
nothing is printed.

sys/src/ape/lib/libressl/test is separate: upstream's own ML-KEM and
SHA-3 known-answer vectors, run with mk test.


Known limitations

Everything here is recorded and not fixed. Where something has been
measured, the number is given; where it has not, it says so. That
distinction is the point of the list.

Platform limits — not bugs, and not fixable here

  • No dynamic loading anywhere. Plan 9 has no dlopen. perl has no XS
    extensions, bash has no enable -f and no loadable builtins, and
    anything that probes for shared-library support gets a truthful no.
  • No job control. libap has no tcsetpgrp and no tcgetpgrp — absent
    rather than stubbed — and Plan 9 has no controlling-terminal foreground
    process group to give them meaning (setpgid answers ESRCH, setsid
    returns getpgrp()). bash is built with JOB_CONTROL_MISSING defined,
    which says which kind of off it is.
  • No symbolic links (9front has none), so symlink() is ENOSYS. Do
    not emulate it with a copy.
  • No hard links: link() answers EMLINK, which is correct, because
    <sys/limits.h> declares LINK_MAX 1 and POSIX says EMLINK is what a
    link past LINK_MAX gives.
  • No FIFOs: mkfifo() is ENOSYS.
  • No /dev/fd. Plan 9 binds the fd device at /fd, and a /fd entry
    names the descriptor of the process that opens it — so handing the
    name to a child, which is the whole point of <(...), names the child's
    own descriptor. Process substitution is off for that reason and should
    stay off. Do not invent semantics to make a feature compile.
  • File times are whole seconds. 9P's Dir.mtime has no nanoseconds
    and dirtostat.c sets every tv_nsec to 0. Anything sorting files by
    a sub-second timestamp cannot be made to work here.
  • No O_APPEND. 9P's Twrite carries an explicit offset and there is
    no write-at-end request, so libap emulates it with a seek in open()
    and another in write() — two calls with a window between them.
    Measured: four processes appending flat out lose 1280 of 2050 bytes;
    one writer in the same loop is exact. Plan 9's one atomic append is
    DMAPPEND, a permanent mode bit on the file, which is not what
    O_APPEND means for a descriptor.
  • No loopback unless ip/ipconfig loopback /dev/null 127.1 has been
    run, and that belongs in the machine's startup rather than in
    apexp-sh.
  • No password database, so ~USER cannot be expanded.
  • unixFCmd-1.1-shaped: walking through a mode-0 directory answers
    "does not exist" where POSIX wants EACCES. The file server's choice.

Compiler

  • static bool b = 256; still truncates. A file-scope initialiser is
    folded in dcl.c without going through the conversion path. An auto
    bool b = expr; is correct.
  • Compound assignment is still performed in the lvalue's width. Fixing
    it means rewriting E1 op= E2 as E1 = (T1)(E1 op E2).
  • typeof_unqual does not strip qualifiers, _Alignas has no layout
    effect, and _Atomic is dropped as a qualifier.
  • __thread is silently dropped (cc/lex.c has a swallow list; Plan 9
    has no TLS). That is right for single-threaded programs and a live
    hazard for anything else: EDG's __thread_needed_destruction_head
    becomes one process-wide global shared by every thread.
  • 9l declares dupok and never reads it — zero hits in its .c
    where every other linker has two — and 1l/2l have no such field at
    all. A pre-existing gap, found by the COMDAT change and not closed by
    it; on those three targets the back end now diagnoses instead of setting
    a bit the linker ignores, because a flag that silently does nothing
    produces a link failure that looks like a different bug.
  • pcc -C is blunt, as above: first-wins for two genuinely different
    functions of one name. The precise version is cc learning
    __attribute__((__weak__)).
  • %a/%A do not exist in printf, and _dtoa hands back
    "Infinity" and "NaN" where C wants inf and nan — which is also
    why %F does not upper-case them, since that would turn one wrong
    spelling into another.

libap

  • S_ISREG on Plan 9 is a fallback, and one place still relies on it
    being more.
    _dirtostat has no device-type bit to read, so it takes
    Dir.type: a directory, then | and s for pipes and sockets, then
    anything that is not M is a character special — and everything
    left, meaning every file reached through a 9P mount, is called
    regular.
    rio serves /dev/cons, /dev/mouse, /dev/winname and
    /dev/snarf that way, so all four answer S_ISREG.
    This release's select() fix reported a regular file readable
    without arranging for anything to read it, which is sound only for
    a file that cannot block — and it left wish showing a white window,
    frozen on the first of Tk's 97 test files
    , because PollP9Events
    polls the mouse with a zero timeout and then reads it. _selregular
    narrows the predicate by length (a Plan 9 device file reports 0; an
    empty regular file falls back to the buffered path, whose bug is a
    race and not a wrong answer). Believed fixed and NOT yet measured;
    MEASURED AND CLOSED: devreg-probe reports /dev/mouse and
    /dev/cons as REG size 0 and not ready, while /dev/winname and
    /dev/snarf -- also REG size 0 -- come back READABLE, which is the
    copy process answering truthfully for the two that have data and the
    two that block. Tk's suite is back at Total 10027 Passed 8926 Skipped 924 Failed 177, Failed identical to the pre-regression
    run. The mechanism was confirmed from both ends: the prediction that
    /dev/mouse would answer S_ISREG held, and the window draws again.

    What remains recorded rather than fixed is that /dev/cons answers
    REG too
    -- FD_ISTTY is not set on a freshly opened one -- so
    GNU grep's SAME_INODE-against-stdout check now runs against the
    terminal instead of being skipped. Not measured.
  • pthread_attr_* are no-ops, and detachstate is not honoured.
    pthread_create accepts a non-null attr now -- it used to answer
    EINVAL, which meant pthread_cond_timedwait, the one caller in
    libap, never waited at all -- but accepting the struct is all it
    does. A thread created PTHREAD_CREATE_DETACHED still leaves a
    Waitmsg for somebody to collect. Rejecting the attr never made
    detachstate work; it only made the call fail.
  • posix_spawnp discards the envp it is handed. spawn() tests
    usepath first and the child calls execvp, which passes environ.
    POSIX says envp is the child's environment either way. Tcl's exec is
    the caller. Not measured.
  • wait4's WNOHANG path can block. When _dirstat returns nil it
    falls through to the blocking _WAIT() with WNOHANG set, and the same
    happens when the pending message belongs to a different pid — which is
    what a bare wait and wait -n do.
  • ioctl(FIONREAD) stores *(long*)arg where every caller passes an
    int *, writing eight bytes and smashing four of the caller's frame.
  • _startbuf never checks its _RFORK. A failed fork leaves the
    parent waiting for ever on a rendezvous with a process that does not
    exist.
  • A lost wakeup in select()'s rendezvous — a copy process reaching
    EOF before the parent sets selwait. Recorded, never reproduced.
  • A reader competes with the copy process. select() forks a process
    that reads the same open file, so after a fork or an exec the parent's
    copy process may already hold bytes the child asks for;
    bufexec-test measures EWOULDBLOCK where glibc reads all six seeded
    bytes. Inherent in select() being a copy process.
  • A dup of a buffered descriptor does not share a read position.
    Bytes already drained into the Muxbuf are not visible through the new
    descriptor, where POSIX says two dups of one open file description
    share everything. There is nowhere to put them, and the dominant use of
    dup — a shell saving a descriptor to restore later — never reads it.
  • umask does not survive exec. The mask lives in the process image;
    carrying it over means another /env/ variable beside _fdinfo and
    _sighdlr. umask-test section 4 is a probe that measures the gap
    rather than asserting it.
  • mktime never writes tm_zone, tm_gmtoff or tm_isdst back.
    glibc and the BSDs set all three, and gnulib's mktime_z is written
    around that. A conformance gap, recorded as one.
  • date crashes after printing the right answer. The fault is in
    strftime's %s arm, and lstk() named the pointer:
    zone = 0x834383635, whose bytes are the ASCII text 4865 — a char *
    holding digit text
    , the third time in this tree a pointer has contained
    characters. Open, and the mktime gap above sits directly under it
    without closing the chain.
  • strtol/strtoul have the same one-limit-for-both-signs shape
    strtoll had, so strtol(LONG_MIN) is likely ERANGE too. They cannot
    be swept by cross-check — kencc's long is 32-bit and the host's is 64,
    so the two sides disagree about the right answer by construction — and
    they are untouched for exactly that reason.
  • unlink() of a directory reports EPLAN9 where POSIX allows
    EPERM or EISDIR.
  • tcflush accepts its argument and does nothing. That is right for
    the kernel and questionable for this library, whose select() copy
    process does hold unread bytes a conforming TCIFLUSH would discard.
    Nothing has measured it.
  • EGREG reads Unknown error, which is also what the fallback
    returns for an errno out of range — so the two are indistinguishable
    from outside. It is APE's own error (Plan 9's "ken has left the
    building") and glibc has no counterpart to copy a wording from.
  • fts.c:600 computes nlinks = fts_nlink - 2, assuming a directory's
    link count includes . and .., while dirtostat.c sets st_nlink = 1
    always — so that arithmetic has been giving −1 here all along. Found on
    the way to the readdir change and independent of it.
  • lib.h declares _notehandler(void *, char *) and signal.c defines
    it (Ureg *, char *).
    Both sides are right: the declaration matches
    _NOTIFY, which is Plan 9's own void *, and the definition matches
    what the body does. Whichever side changes, one needs a cast.
  • glob cannot produce . and .. from a pattern that names them
    literally
    — fixed for .*, but filename-14.9-style literal cases
    were never the question.
  • ${#GROUPS[@]} is 0 while ${GROUPS[0]} has a value in bash, which
    is bash's dynamic getter rather than ours. Noted because it looks like a
    libap getgroups bug and is not.

Headers

  • <stdio_impl.h> is musl's internal stdio header, installed public,
    reached by six stdio/*.c. Same shape as features.h's hidden, and
    moved only when a victim is found — none has been.
  • <stddef.h> typedefs wchar_t, which is a built-in type in C++. The
    one surviving error when the public headers are included from C++; the
    same unit compiled as C is clean.
  • <regex.h> and <pcre2posix.h> both define regex_t, and
    <f2c.h> defines min/max/abs/complex. Both are design
    intent
    : the first pair are alternatives no program includes together,
    and f2c.h is installed public solely so that a user compiling f2c's
    output gets #pragma lib "libf2c.a". They are the eight errors
    apehdr-sweep's together-case still reports, and it deliberately does
    not gate on them — failing on an untriaged list makes a sweep cry
    wolf.
  • Header dependencies are not tracked in libap. No mkfile under
    sys/src/ape/lib/ap sets HFILES, so editing a header rebuilds
    nothing; mk clean first. (Thirteen packages under external/ had
    the same gap for their own config.h and were fixed; libap was not.)
  • Four headers the C standards require are absent, found by sweeping
    the list of 31 against both include directories rather than one at a
    time. <iso646.h> was a fifth and is written now — EDG's whole
    include_c99 directory is that one file, which is how it was noticed,
    and it is C95 rather than C99 despite where it lives. What remains:
    <stdalign.h> and <threads.h> (C11), <stdbit.h> and
    <stdckdint.h> (C23). They are not one item. <threads.h> is a
    library question — C11 threads over the pthread layer, which is itself
    under development — while the other three are compiler-coupled:
    alignas/alignof need _Alignas to have a layout effect, which it
    does not here, and the C23 pair need __builtin-level support. Nothing
    in the tree includes any of the four; recorded rather than stubbed,
    because a header that declares what the compiler cannot do is the
    capability-present-and-not-declared bug with the sign reversed.
  • sys/include/ape/c++ is EDG's language-support set, sixteen files
    plus experimental/meta.stdh, committed copies of
    external/edg/include_c++ — which is the arrangement
    sys/include/ape/X11, tcl.h, tk.h and f2c.h already use, and it
    means the headers reach the VM through git alone. There is still no
    C++ standard library
    ; these are the headers that need front-end magic
    (<new>, <typeinfo>, <exception>, <stdexcept>,
    <initializer_list>, <compare>, <coroutine>, <source_location>,
    <stdfloat>, cxxabi.h), and libedg.a is the matching ABI runtime.
    Most are .stdh, which only cpfe resolves — include_file_suffixes is
    "::stdh:" — so no other compiler reads them and apehdr-sweep, being
    top-level only, never sees them. Two copies of a header can drift, so
    sys/include/ape/c++/README carries the one-command check, with empty
    output as the pass.
    Cfront's seventeen pre-standard headers used to be here, and two
    names collided — new.h and stdexcept.h, the first under the same
    include guard __NEW_H
    — so order alone decided which a program got.
    That is why the two sets could never have shared the directory.

xz HANGS, AND THE CAUSE IS NAMED: libap's pthread_create.
xz -c on a seven-byte text file went to high load and never returned.
Two rounds went to poll, select and O_NONBLOCK — xz uses all
three and none was the fault — and the select() regular-file fix was
offered as a candidate with a refutation condition attached, which
fired. The one fact that survived was the shape of the load: the l
figure lower but s pinned at the maximum, and a pinned system
figure is a syscall loop. That reading was right, and ps plus two
acid stacks then named the cause outright.

xz is multithreaded (liblzma/common/stream_encoder_mt.c), and the
pthread layer had three bugs:

  • the child half of pthread_create did a _RENDEZVOUS the parent
    never answered
    — that was the only _RENDEZVOUS in the whole
    thread directory — so every thread ever created blocked before
    reaching its start routine
    , while its creator was told the call had
    succeeded;
  • *t was never written, so every caller handed rubbish to
    pthread_join;
  • attr != NULL returned EINVAL, and libap's own
    pthread_cond_timedwait always passes one
    , so it returned EAGAIN
    without ever waiting — and wait_for_work is a loop, which makes
    each turn a clock_gettime, which on Plan 9 is a _PREAD. A spin
    made of syscalls, which is exactly the pinned s figure.

All three are fixed. sys/lib/tests/pthread-test.c is the instrument —
the first test in this tree that can hang, so the first that arms a
SIGALRM — 0 failures on gcc and 3 on the replaced code,
reproducing xz's spin on the build host.

AND THE CLAIM THAT lz4 AND xz SHARE NO MECHANISM IS WITHDRAWN. That
grep asked about poll, select and O_NONBLOCK; it was true and it
answered the wrong question. lz4 has programs/threadpool.c, is
compiled -DLZ4IO_MULTITHREAD, and links threadpool.$O.
A worker
that never reaches its start routine is exactly "froze and left an
empty output". A grep that finds nothing has ruled out what you
grepped for and nothing else.

BOTH ARE MEASURED NOW AND THE REFUTATION CONDITION DID NOT FIRE.
xz -c <sample.txt >/tmp/t.xz returns and writes 72 bytes; unlz4
returns with an error instead of freezing. lz4 was wedged on the same
mechanism, so the two hangs were one bug after all.

And then fsync deleted the output. unxz /tmp/t.xz decompressed
correctly and printed Synchronizing the file failed: Invalid argument. libap's fsync was errno = EINVAL; return -1 -- the
stub-answers-FAILURE family, with the right answer already written in a
second libap file that disagreed (plan9/__p9_syscall.c:594, "Plan9
writes are synchronous; no-op is correct"
). xz turns a nonzero fsync
into success = false and io_close_dest(pair, false) removes the
destination
, and opt_synchronous is on by default, so this was
every xz/unxz on a named file, every time. Fixed; fsync-test is 0
on gcc and 1 on the replaced line. Not yet measured on the VM.

What remains is two decode failures, and neither is separated.
unxz xz_sample_file_1MB.xz answers Compressed data is corrupt;
unlz4 sample.txt.lz4 answers Error 26 : LZ4F frame decoding could not complete: invalid frame, Decompressed : 0 MiB. Both files came
from elsewhere
, so each has two explanations -- a bad download, or a
path only those files reach -- and nothing local has been round-tripped
to tell them apart.

The positive result is hidden inside the sync error: unxz /tmp/t.xz reached io_sync_dest, which runs after decoding, so
encoder and decoder already agree on a small file. The two
discriminators are a local round trip at 1MB, and -T1 against the
default -T0, since the threaded encoder is ground nothing in this
tree has ever covered -- a fix that makes a process reach code it
never reached before can expose anything on that path.
Deferred to
0.7 either way; zstd is untested (lib/common/pool.c puts it in the
same position), unarj lists a 1MB archive correctly, and unrar, unace
and clzip are untried. pcc -9 is not available as an A/B, since one
package under the old layout rule against a -J libap is a silent ABI
split.

One instrument note worth keeping: ratrace -c "cmd args >file"
does not run the command. It execs the whole string as a single
argv[0] and answers file does not exist: '/bin/xz -c <sample.txt >',
so a session that reports "cannot reproduce" from that line has
measured nothing. ps and acid on the pid are what worked.

Ports not in the default build

  • go 1.4 does not build. Three walls have been cleared, each one file
    further in — bool as a kencc keyword, a missing -c in the mkfile,
    and Makefile backslash escaping that mk does not share — and the fourth
    is structural: cmd/dist is compiled with -DPLAN9, which selects
    plan9.c and its <u.h>/<libc.h>, under a compiler that has neither.
    The portable arm is already written: unix.c is 843 lines of POSIX
    and every one of its nine includes exists in this tree. The macro is
    doing two unrelated jobs — choosing the portability file at compile
    time, and standing for gohostos == "plan9" at run time in six places
    in build.c — and only the first is wrong. The change is one #elif
    arm in unix.c's compile-time chain plus a new -D in place of
    -DPLAN9. Not started.
  • clisp does not build, and the obstacle is configure rather than
    the compiler. Its configure prints 5: Bad file descriptor on
    hundreds of lines — autoconf keeps config.log on fd 5 — so the closing
    C compiler cannot create executables is the verdict of a configure
    that could not write its own log, and is not a statement about pcc.
    The construct itself is cleared: execfd-test.sh reports 0 failures
    across all eleven sections on 9front, including a forked-and-exec'd
    child, the shell re-execing itself (which is configure's own first act)
    and fd 5 held across 300 forks. The plan is to stop running configure
    at all — a hand-answered config.h plus an mkfile, as perl and bash
    already have. The honest size of that: lisp.run is the tractable half,
    and the memory image is a second half, since CLISP compiles its own Lisp
    sources with the interpreter it has just built. Not started.
  • cfront is removed. It was a 1980s front end that cannot tell two
    overloads apart on a 64-bit target, reproduced character for character
    by a host gcc build — a fault both compilers reproduce is upstream's,
    not this tree's
    — and once the struct-layout work had extracted the
    last kencc bug from it, it stopped being a bug-finder. cmd/cfront,
    cmd/c++lib, the seventeen pre-standard headers in
    sys/include/ape/c++, cfrontsz-probe.py and two committed x86-64
    Linux binaries under external/cfront-C4 all went with it. The C++
    front end is EDG's, and c++ is its driver.
    It had been kept for three reasons and all three expired before it
    went
    : the layout rule now has structalign-test's nine shapes plus
    two straddles and edgscope-probe/edgtuoff-probe on EDG's own
    structs; cfrontsz-probe.py's input stopped being tracked; and the EDG
    driver turned out to want none of cfront's pipeline — <values.h> was
    always perl's, p2c's and Devel-PPPort's rather than cfront's. The
    comments that name it in pcc.c, callmain.c and three instruments
    stay: each explains why code is as it is, and pcc.c's is still the
    reason -J is unconditional rather than inside if(!Aflag).
  • EDG builds and cpfe runs; translation is open.
    sys/src/external/edg holds 133 generated C files, ~2.90M lines, and
    all of them compile. cpfe links, starts, parses a translation unit
    and builds IL for it; under --target win64 it then faults, fault read addr=0x10, in IL pruning at the end of a function body — where
    the same commit's host cpfe, same flags, exits 0 and writes correct
    C. Both struct-layout rules it was first blamed on are now in and
    neither explains it
    : the whole corpus bakes exactly two folded
    offsetof constants, and the tail rule put both back to the numbers
    EDG computed. rc/bin/ape/eccp is the driver and c++ is a one-line
    forwarder to it
    , so CXX=c++ works for autoconf, for GNU make and for
    the shared transpiler rules — which did not have to change, because they
    were written against the driver rather than against cfront. It carries
    the target flags, the three --sys_include directories in order and the
    $status discipline, so the long hand-written command in the NOTE is
    history. The remaining three are open. The link model: 556 of 558
    mangled names are template instantiations emitted nowhere, with no
    vtable, typeinfo or guard variable among them, so the output is not
    self-contained for templates and needs a prelink phase mk cannot
    naturally express. Static initialisation: nothing calls
    _Z12__call_ctorsv, so a C++ program cpfe translates would not run its
    static constructors. cpfe itself does not need it — the whole corpus
    holds one __sti__ routine and its body assigns 0 to members a BSS
    global already has — but that is a different claim, and any gtest-shaped
    suite registering tests from static initialisers would report zero tests
    and read exactly like a translation bug.
  • No C++ standard library. EDG ships none: lib_src is the
    libsupc++/libc++abi layer — new/delete, vtables, RTTI, static init,
    pure-virtual — and include_c++ is the language-support set, its own
    README saying "only those headers that require specific magic". What
    works with no library at all is the subset EDG itself is written in.
    The exception model decides what could fill the gap: EDG's
    exceptions are setjmp/longjmp with its own regions and there are zero
    _Unwind_ references in all 51 files — which is good, since there is
    no libgcc, no libunwind and no .eh_frame here, and bad, since
    libc++'s EH assumes the Itanium ABI. And the axis that disqualifies a
    candidate is the namespace: code written against std::vector does
    not compile against etl:: or eastl:: however good they are. A
    renamed STL serves new code; only a std:: one serves a port.

What's next

  • go 1.4 — the unix.c arm above.
  • clisp — a hand-answered config.h and a native mkfile.
  • EDG — the link model's prelink phase, static initialisation, and a
    re-translation with kencc_targ.h actually in effect for target.c,
    which would fix wchar_t, the field alignments, pointer-to-member and
    jmp_buf in one go.
  • The archivers. The hangs are gone — both were pthread_create —
    and what is left is two decode failures on files produced elsewhere:
    unxz on a 1MB download says Compressed data is corrupt, and
    unlz4 says invalid frame. Neither is separated, because each
    has two explanations (a bad download, or a path only those files
    reach) and nothing local has been round-tripped to tell them apart.
    The two discriminators are a local round trip at 1MB and -T1
    against the default -T0 — the threaded encoder is ground nothing
    in this tree has ever covered
    , since until this release no thread
    ever reached its start routine. zstd is untested, in the same
    position; unrar, unace and clzip are untried.
  • pthread_attr_* are still no-ops, detachstate included. A
    detached thread leaves a Waitmsg for somebody to collect.
  • The remaining bash list — about seven files and ~65 lines not yet
    attributed, named in CLAUDE.md.
  • select() learning about a pending connect, which is the last
    approximation in async connect.
  • FD_ISTTY on a freshly opened /dev/cons. devreg-probe reports
    it as S_ISREG, which means GNU grep's "am I writing to the file I am
    reading" check now runs against the terminal instead of being skipped
    as a non-regular file. Recorded, not measured.