The phone's userland is NetBSD's own source built with NetBSD's build
against glibc, and more and more of src/ asks for libc symbols glibc
does not have, so libmxlinux takes them over from the same tree:
db(3) (Berkeley DB 1.85, which glibc dropped), md2/md4/rmd160 and the
*File/*End helpers the hash tools link, glob(3) (renamed __glob30, so
beside glibc's), stringlist, errc/warnc, fmtcheck, shquote, getcap,
strtonum, heapsort/merge/radixsort, base64, stresep, and the
<db.h>/<md2.h>/<ndbm.h>/<stringlist.h> frames that reach over to
src/include.
-mx_cdefs.h: __strong_alias/__weak_alias stay off inside libmxlinux
(-D_MX_LIBMXLINUX). The libc sources it compiles alias their public
names to libc-internal ones in hashhl.c before namespace.h can withdraw
the macro, and those names do not exist outside libc -- every program
linked against the library had undefined _MD2FileChunk. src/tools/compat
builds the same sources without them for the same reason.
-mxlinux.h: the feature set is asked for the way NetBSD's
<sys/featuretest.h> asks for it. A program with -std=c99 alone asks for
no standard, which on NetBSD means _NETBSD_SOURCE (everything);
glibc gives ISO C only, so _DEFAULT_SOURCE and _NETBSD_SOURCE are set
before the first glibc header.
-mobile/conf/mk.conf: the NetBSD subsystems with a NetBSD kernel
underneath are off for a Linux target -- MKAUDIO, MKBLUETOOTH, MKUSB,
MKNFS, MKYP, MKHESIOD, MKSKEY, MKKERBEROS, MKPAM -- and libpthread is
glibc's (LIBDO.pthread=_external), not NetBSD's LWP threads.
-mobile/tools/mxsrc.sh: USE_FILEMON=no on the command line, because
make(1) decides on filemon before bsd.own.mk reads mk.conf and traces
with ktrace(2)/filemon(4), which Linux has neither of.
Measured: make src DIR=lib/libmxlinux -> mxsrc lib/libmxlinux exit=0,
0 errors (mobile/build/logs/mxsrc-libmxlinux-2026-11-12-b.log).
make src DIR=<dir> (mobile/tools/mxsrc.sh) runs the tooldir's
nbmake-evbarm64 in src/<dir> with MAKECONF=mobile/conf/mk.conf and the
sysroot as DESTDIR, objects in build/tools-obj, "obj" first.
libmxlinux grows into what NetBSD's libc and libutil have and glibc
lacks, from NetBSD's own sources reached over by .PATH: vis/unvis,
strmode, setmode, pwcache, reallocarr, strtoi/strtou (BCS_ONLY), fts (its
<fts.h> in front of glibc's; renamed symbols, so the two never meet),
acl(3) (posix1e), extattr(3), and libutil's efun, parsedate,
raise_default_signal, stat_flags, strpct, snprintb. Ours only at the
kernel boundary: extattr onto Linux xattr(7) (user. and trusted.), the
__acl_* calls (EOPNOTSUPP; _PC_ACL_* get values glibc answers EINVAL to),
chflags/undelete (EOPNOTSUPP), lchmod (a link has no mode on Linux),
lpathconf, setpassent, the timezone_t API over TZ (mx_tz.c), sys_siglist.
include/ reaches over <fts.h>, <util.h>, <vis.h>, <tzfile.h>,
<sys/acl.h>, <sys/extattr.h>. stty's mx_termios.h moves here and serves
every program; the old port frame keeps its per-port shims behind
-DMX_PORT_FRAME until they are gone.
libnbcompat is out of the normal build again: its setmode is the host
tools' octal-only stub (src/tools/compat/getmode.c:37), so chmod u+x set
mode 0. mk.conf: NOGCCERROR (28 warnings left in src/bin),
-Wno-system-headers (glibc's fortify headers), MKRUMP=no.
Found on the way: NetBSD's __used macro deleted a member of glibc's
regex_t (<regex.h>:410 pastes "__used") and of posix_spawnattr_t
(<spawn.h>:47); regex_t shrank from 64 to 56 bytes and expr's regexec
read garbage. mxlinux.h now includes both headers before mx_cdefs.h.
Measured: 22 of 34 programs of src/bin build
(mobile/build/logs/mxsrc-bin6-2026-11-12.log); the 18 with a port test
pass all of them under qemu-aarch64 -L build/mxsysroot-hotdogb: cat chmod
cp echo expr hostname kill ln ls mkdir mv pwd rm rmdir sleep stty sync
test. The old frame still builds cat, stty, test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libmxlinux moves from mobile/userland/lib/mxlinux into src/lib/libmxlinux
with a NetBSD library Makefile (LIB=mxlinux, bsd.lib.mk, shlib_version),
so NetBSD's build makes libmxlinux.so.0 for a Linux target like any other
library of src/. mx_cdefs.h carries the <sys/cdefs.h> additions glibc
lacks, namespace.h stands in for libc's (no __weak_alias on glibc),
mx_progname.c gives getprogname/setprogname, mxlinux.h gains _DIAGASSERT.
mobile/conf/mk.conf forces mxlinux.h into every compile and links
-lmxlinux. The old port frame builds the same sources from there
(mobile/build/logs/userland-cat-2026-11-12.log: cat built, mxcheck ok).
The sysroot steps that were done by hand are in the tools now:
- mkmxheaders.sh installs only the kernel headers (the tooldir's gcc needs
nothing else, and nbmtree does not exist yet);
- mkglibc.sh lays down NetBSD's hierarchy with nbmtree from
NetBSD.dist.base + .aarch64 (1480 directories), installs glibc, and links
the dynamic linker as /lib/ld-linux-aarch64.so.1 and /libexec/ld.elf_so,
the interpreter bsd.prog.mk:69,286 writes into every program;
- mktargetlibs.sh installs libgcc_s.so.1 and libstdc++.so.6 into the
sysroot's /usr/lib.
Measured: src/bin/cat built by nbmake-evbarm64 with this mk.conf (NEEDED
libmxlinux.so.0, libgcc_s.so.1, libc.so.6; interpreter /libexec/ld.elf_so)
passes userland/cat/test.sh 5/5 under qemu-aarch64 -L mxsysroot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The toolchain and sysroot are ours now in LFS's order (Makefile: mxheaders
-> tooldir -> sysroot (glibc) -> targetlibs -> toolchain); the Void-made
sysroot (tools/mksysroot.sh, base/void/sysroot-packages) is gone, the
frame points at build/mxsysroot-<dev>.
conf/mk.conf: what NetBSD's build needs to build src/ for a Linux target,
as MAKECONF, nothing changed in src/: the sysroot's library directories
for the -DNETBSD_TOOLS gcc (as src/tools/gcc/Makefile:162 does), and the
start files -- glibc's Scrt1/crti/crtn, gcc's crtbegin/crtend -- through
the ?= of bsd.gcc.mk and bsd.prog.mk. With it, src/lib/libz builds
unchanged with bsd.lib.mk through the tooldir's nbmake-evbarm64:
libz.so.1 (soname as on NetBSD), NEEDED only libc.so.6 and
ld-linux-aarch64.so.1, its symbol check against NetBSD's list empty.
Open: programs (bin/cat) need NetBSD's header additions (cdefs,
setprogname): libmxlinux and libnbcompat through the same mk.conf.
make userland (the port frame) waits for libz in the sysroot: libnbcompat's
configure requires zlib.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>