Skip to content

[nanvix] Wave 5 audit cleanup: drop dead helpers + tidy setup_local + enable inet_pton#21

Closed
esaurez wants to merge 4 commits into
feat/wave5-pr-c-unbundle-group-afrom
feat/wave5-audit-cleanup
Closed

[nanvix] Wave 5 audit cleanup: drop dead helpers + tidy setup_local + enable inet_pton#21
esaurez wants to merge 4 commits into
feat/wave5-pr-c-unbundle-group-afrom
feat/wave5-audit-cleanup

Conversation

@esaurez

@esaurez esaurez commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Three small upstream-alignment cleanups surfaced by the PR #20 audit against upstream cpython Linux's default .so management behavior. All are independent of each other and of the in-flight Wave 5 build chain -- pure dead-code / cosmetic removal.

Stacks on top of #20 (feat/wave5-pr-c-unbundle-group-a). Merge after #20 lands.

1. Makefile.nanvix: drop dead LIBSSL/LIBCRYPTO/LIBZ/LIBSQLITE3 vars

After Wave 5's Group-A unbundling these per-library .a path variables are no longer referenced anywhere -- the build picks up libssl / libcrypto / libz / libsqlite3 via -l<name> against the .so siblings in $(SYSROOT)/lib/. Removing the unused definitions makes it harder to accidentally reintroduce static linking by referencing one of them in a future LIBS rewrite.

2. .nanvix/config: drop dead toolchain_paths / configure_env helpers

Both helpers are unused: the actual cpython build invokes make -f Makefile.nanvix which has its own inline CONFIGURE_ENV authoritative for CC / CFLAGS / LDFLAGS / LIBS. The dead Python copies had drifted to stale pre-Wave-7 link flags (literal -lsqlite3 -lz -lbz2 -llzma in LIBS, no DT_NEEDED awareness) and would have mis-built any caller that picked them up. configure_opts() (still called from build.py) and the toolchain / docker path constants stay.

Closes the cleanup tracked in nanvix-todo/cpython-config-py-dead-configure-env.md.

3. .nanvix/setup_local: split POSIX-wrapper modules into their own section

Previously _asyncio, _datetime, select, _socket, _posixsubprocess, fcntl, and termios sat under the 'Modules with bundled-in-cpython C deps' section header, which is misleading -- none of them bundle a vendored .a; they are thin POSIX/syscall wrappers (plus _asyncio / _datetime) whose libc / libm symbols resolve against python.elf's .dynsym at dlopen time via --export-dynamic.

Move them into a dedicated 'POSIX syscall wrappers + concurrency primitives' section that mirrors upstream Modules/Setup.stdlib.in's 'Modules with some UNIX dependencies' grouping. Purely cosmetic -- no change to the generated Setup.local except entry order within the *shared* block (which makesetup does not depend on; each module name still appears at most once).

Validation

./z lint passes (black + pyright clean) after each commit.

Items NOT in this PR (deferred / blocked)

  • B-1 (libm bundled into _decimal/pyexpat) -- upstream cpython hardcodes literal -lm in configure.ac:3918 and :3834 instead of using $(LIBM). Tracked separately for a future upstream PR against python/cpython.
  • D-2 (unversioned SONAMEs) -- accepted as Nanvix convention.
  • H-1 (ac_cv_func_inet_aton=no / inet_pton=no overrides may be stale) -- needs nm against libposix.a to confirm; tracked for follow-up.
  • J-2 (--allow-multiple-definition on .so builds) -- blocked by B-1; once libm no longer gets bundled, the override can be scoped back to python.elf only.

@esaurez esaurez changed the title [nanvix] Wave 5 audit cleanup: drop dead helpers + tidy setup_local sections [nanvix] Wave 5 audit cleanup: drop dead helpers + tidy setup_local + enable inet_pton Jun 13, 2026
@esaurez

esaurez commented Jun 13, 2026

Copy link
Copy Markdown
Owner Author

Update: added a 4th commit for audit finding H-1.

nm confirmed libposix.a defines inet_pton (T symbol), so the
ac_cv_func_inet_pton=no override in Makefile.nanvix was stale.
Flipped to =yes so cpython's configure sets HAVE_INET_PTON in
pyconfig.h, enabling the IPv6 fast paths and socket.inet_pton /
inet_ntop builtins in _socket.so. Symbol resolves via
python.elf .dynsym (libposix whole-archived + --export-dynamic).

inet_aton stays at =no -- not in libposix.

@esaurez esaurez force-pushed the feat/wave5-pr-c-unbundle-group-a branch from 712e51a to cf8e25c Compare June 13, 2026 01:44
@esaurez esaurez force-pushed the feat/wave5-audit-cleanup branch from 11c1f5c to c3612dc Compare June 13, 2026 01:44
Enrique Saurez and others added 4 commits June 16, 2026 14:21
After Wave 5's Group-A unbundling these per-library .a path
variables are no longer referenced anywhere -- the build now picks
up libssl / libcrypto / libz / libsqlite3 via -l<name> against the
.so siblings in $(SYSROOT)/lib/. Removing the unused definitions
makes it harder to accidentally reintroduce static linking by
referencing one of them in a future LIBS rewrite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Both helpers are unused: the actual cpython build invokes
`make -f Makefile.nanvix` which has its own inline CONFIGURE_ENV
authoritative for CC / CFLAGS / LDFLAGS / LIBS. The dead Python
copies had drifted to stale pre-Wave-7 link flags (literal -lsqlite3
-lz -lbz2 -llzma in LIBS, no DT_NEEDED awareness) and would have
mis-built any caller that picked them up.

Keep configure_opts() (still called from build.py) and the
toolchain / docker path constants (referenced elsewhere).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously _asyncio, _datetime, select, _socket, _posixsubprocess,
fcntl, and termios sat under the 'Modules with bundled-in-cpython
C deps' section header, which is misleading -- none of them bundle
a vendored .a; they are thin POSIX/syscall wrappers (plus _asyncio
/ _datetime) whose libc / libm symbols resolve against python.elf's
.dynsym at dlopen time via --export-dynamic.

Move them into a dedicated 'POSIX syscall wrappers + concurrency
primitives' section that mirrors upstream Setup.stdlib.in's
'Modules with some UNIX dependencies' grouping. Purely cosmetic --
no change to the generated Setup.local except entry order within
the *shared* block (which makesetup does not depend on; each module
name still appears at most once).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verified against the toolchain libposix.a via i686-nanvix-nm:

    $ i686-nanvix-nm $(SYSROOT)/lib/libposix.a | grep "^.* T inet_"
    00000000 T inet_addr
    00000000 T inet_ntoa
    00000000 T inet_ntop
    00000000 T inet_pton

The previous ac_cv_func_inet_pton=no override was stale -- it dates
from before libposix gained inet_pton support. Flipping it to yes
lets cpython's configure define HAVE_INET_PTON in pyconfig.h, which
in turn enables the IPv6 fast paths in socketmodule.c (lines
1226-1268) and registers the socket.inet_pton / inet_ntop builtins
(socketmodule.c:6616+). The symbol resolves at dlopen time from
python.elf's .dynsym (libposix.a is whole-archived into the main
binary, exported via --export-dynamic).

inet_aton stays at =no -- libposix does not provide it (absent from
the nm dump above).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@esaurez

esaurez commented Jun 17, 2026

Copy link
Copy Markdown
Owner Author

Closing in favor of splitting these unrelated cleanups into four focused PRs (each independent, each based on feat/wave5-pr-c-unbundle-group-a):

@esaurez esaurez closed this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant