feat(configure): enable posix_dir for *-nanvix*#13
Open
esaurez wants to merge 1 commit into
Open
Conversation
Sets posix_dir=posix for *-nanvix* and adds the matching opt-out cflags
so the wider compile surface stays clean.
Newly exposed in libc.a (previously missing): regcomp, regerror,
regexec, regfree (fixes the original rpmatch.c link failure), fnmatch,
sleep, isatty, _isatty, creat, alphasort.
Opt-out cflags added alongside posix_dir=posix, using newlib's existing
_NO_* idiom (cf. RTEMS section at configure.host:623):
- _NO_SIGPROCMASK: covered separately, kept here for completeness.
- _NO_POSIX_SPAWN: posix_spawn.c needs fork/execve which nanvix does
not provide; also references sigprocmask unconditionally.
- _NO_POPEN: popen.c needs fork+pipe+execve.
- _NO_WORDEXP: wordexp.c shells out to /bin/sh.
- _NO_GLOB: glob.c / globfree references getpwnam, issetugid, and
getlogin, none of which nanvix's libposix provides today.
- _NO_EXECVE: execl.c, execle.c, execv.c, execve.c, execlp.c, and
execvp.c all reference the SYS_execve syscall wrapper (_execve)
which nanvix's libposix does not provide today.
- HAVE_OPENDIR: nanvix already provides its own opendir/readdir/
closedir/scandir/seekdir/telldir/rewinddir/dirfd via libposix, using
a different struct dirent layout (no d_reclen). HAVE_OPENDIR makes
the newlib libc/posix/{opendir,readdir,closedir,...}.c files empty
so the symbols resolve from libposix instead of the BSD
implementations newlib ships.
All of these are well-established newlib capability macros (already
guarded with #ifndef in the corresponding .c files); no new macro is
introduced.
Real implementations of sigprocmask / posix_spawn / popen / wordexp /
glob / execve on nanvix remain the long-term path; tracked separately.
Verification: nm /opt/nanvix/i686-nanvix/lib/libc.a confirms
- regcomp/regexec/regerror/regfree, fnmatch, sleep, isatty/_isatty,
creat are now defined (T)
- no new U references to sigprocmask, sigfillset, posix_spawn, popen,
wordexp, getpwnam, issetugid, getlogin, or _execve were introduced
- the trivial autoconf conftest 'int main(void) { return 0; }' links
cleanly with the resulting libc.a + libm.a + libposix.a sysroot.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
posix_dir=posixfor*-nanvix*innewlib/configure.hostso the existingnewlib/libc/posix/translation units get compiled intolibc.a, together with the matching set of newlib opt-out capability macros that keep the wider compile surface clean.This is the change that unblocks the original
rpmatch.cundefined-reference chain (regcomp,regexec,regerror,regfree) we hit while statically linking cpython on Nanvix, and adds the rest of the POSIX surface that nanvix-side code (cpython, future.soextensions) expects to find in libc.What gets enabled
After this change,
libc.afor*-nanvix*now defines (previously missing):regcomp,regerror,regexec,regfreefnmatchsleep,isatty/_isatty,creat,alphasortVerified by rebuilding newlib under
ghcr.io/nanvix/toolchain-gccand runningi686-nanvix-nm /opt/nanvix/i686-nanvix/lib/libc.a.Why the opt-out cflags
Setting
posix_dir=posixwould otherwise drag in six translation units that cannot work on Nanvix today. Each one is silenced with a standard newlib capability macro — no new macro introduced. The shape mirrors the RTEMS section atconfigure.host:623which uses the same idiom for a similar capability gap.-D_NO_POSIX_SPAWNposix_spawn.cfork/execve; also referencessigprocmaskunconditionally (same root cause as the prerequisite_NO_SIGPROCMASKchange on this stack's base branch)-D_NO_POPENpopen.cfork+pipe+execve-D_NO_WORDEXPwordexp.c/bin/sh-D_NO_GLOBglob.cglob/globfreereferencegetpwnam,issetugid, andgetlogin, none of which nanvix's libposix provides today-D_NO_EXECVEexecl.c,execle.c,execv.c,execve.c,execlp.c,execvp.cSYS_execvesyscall wrapper (_execve) which nanvix's libposix does not provide today-DHAVE_OPENDIRopendir.c,readdir.c,closedir.c,scandir.c,seekdir.c,telldir.c,rewinddir.c,dirfd.c,ftw.c,nftw.copendir/readdir/closedir/ ... in libposix, using a differentstruct direntlayout (nod_reclen). Newlib's BSD-style versions assumed_reclenand won't even compile against the nanvix<sys/dirent.h>.HAVE_OPENDIRmakes the newlib copies empty so the symbols resolve from libposix at link time.The dirent split is intentional on the nanvix side — see
newlib/libc/sys/nanvix/include/sys/dirent.hwhich definesstruct dirent(POSIX-API surface:d_ino+d_name) separately fromstruct posix_dent(on-disk form withd_reclen+d_type). The conversion happens inside libposix's ownreaddir.How the
_NO_*/HAVE_*macros are usedThese are pre-existing newlib idioms —
posix_spawn.c,popen.c,wordexp.cand the entireopendirfamily already wrap their bodies in#ifndef _NO_FOO/#ifndef HAVE_FOO. We're just turning the knobs the files were already prepared for.The same pattern is used by other newlib targets (RTEMS, several embedded ports) —
git grep _NO_POPEN newlib/configure.hostfor precedent.Verification
Built with this branch on top of the
pr-base-newlib-pr4base branch (which carries the_NO_SIGPROCMASK/hash_pageguard change this PR's diff depends on textually):shows all of them defined.
shows none — the silenced files contribute no new undefined references.
Follow-up work (tracked separately)
sigprocmask/posix_spawn/popen/wordexp/glob/execveon nanvix so these opt-outs can be removed.Dependency
This PR depends textually on the
_NO_SIGPROCMASK/hash_pagechange being applied first (both diffs modify the samenewlib_cflagsline inconfigure.host). The base of this PR is therefore set topr-base-newlib-pr4, a temporary base branch built fromdev+ that prerequisite commit. When the prerequisite PR merges intodev, this PR can be rebased directly ontodev.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com