From 314b584cef019fb569c676a93e1e469a680244a7 Mon Sep 17 00:00:00 2001 From: ada Date: Wed, 29 Apr 2026 11:48:09 -0500 Subject: [PATCH 1/3] Enable mmap Empirical enablement per .vault/designs/stdlib-modules-enablement/design.md. Drop [mmap] from the Nanvix arm of PY_STDLIB_MOD_SET_NA in configure.ac and the matching py_cv_module_mmap=n/a in configure. Closes #301 (pending verification). --- configure | 1 - configure.ac | 1 - 2 files changed, 2 deletions(-) diff --git a/configure b/configure index 36793a809578bb..417d3a1842d7b8 100755 --- a/configure +++ b/configure @@ -28622,7 +28622,6 @@ case $ac_sys_system in #( py_cv_module__lsprof=n/a py_cv_module__multiprocessing=n/a py_cv_module_audioop=n/a - py_cv_module_mmap=n/a py_cv_module__posixshmem=n/a py_cv_module_fcntl=n/a py_cv_module_grp=n/a diff --git a/configure.ac b/configure.ac index 95a47ba57cec8e..416d77b6dc265d 100644 --- a/configure.ac +++ b/configure.ac @@ -7270,7 +7270,6 @@ AS_CASE([$ac_sys_system], [_lsprof], [_multiprocessing], [audioop], - [mmap], [_posixshmem], [fcntl], [grp], From 1b2f873e5f99d7ea01d158996abf20c47e6c71a2 Mon Sep 17 00:00:00 2001 From: ada Date: Wed, 29 Apr 2026 11:53:01 -0500 Subject: [PATCH 2/3] mmap: gate msync() on HAVE_MSYNC Cycle 2 of the empirical enablement of issue #301. Cycle 1 (commit 8dd17c2fde3) flipped the configure switch and confirmed that Modules/mmapmodule.c:683 calls msync() unconditionally inside mmap.flush(), and that nanvix's libposix.a does not export msync (see .vault/designs/stdlib-modules-enablement/findings.md). This commit: - adds msync to the AC_CHECK_FUNCS list in configure.ac (alongside the existing mmap/mremap entries) and mirrors the change in the generated configure script (no autoreconf, per port convention). - adds HAVE_MSYNC to pyconfig.h.in so the autoconf substitution has a target. - guards the UNIX msync() branch in mmap_flush_method() with defined(HAVE_MSYNC); platforms without msync fall through to the existing 'flush not supported on this system' ValueError path. On any platform that has msync (every existing in-tree target), HAVE_MSYNC will be defined and behaviour is unchanged. On nanvix, mmap.flush() will raise ValueError instead of failing to link. --- Modules/mmapmodule.c | 2 +- configure | 7 +++++++ configure.ac | 2 +- pyconfig.h.in | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 827f619e6eb8b6..22524f8f632b52 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -678,7 +678,7 @@ mmap_flush_method(mmap_object *self, PyObject *args) return NULL; } Py_RETURN_NONE; -#elif defined(UNIX) +#elif defined(UNIX) && defined(HAVE_MSYNC) /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, MS_SYNC)) { PyErr_SetFromErrno(PyExc_OSError); diff --git a/configure b/configure index 417d3a1842d7b8..0eb5dd4e1c1534 100755 --- a/configure +++ b/configure @@ -18042,6 +18042,12 @@ if test "x$ac_cv_func_mremap" = xyes then : printf "%s\n" "#define HAVE_MREMAP 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "msync" "ac_cv_func_msync" +if test "x$ac_cv_func_msync" = xyes +then : + printf "%s\n" "#define HAVE_MSYNC 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "nice" "ac_cv_func_nice" if test "x$ac_cv_func_nice" = xyes @@ -28656,6 +28662,7 @@ case $ac_sys_system in #( py_cv_module__testmultiphase=n/a py_cv_module__testsinglephase=n/a py_cv_module__testclinic=n/a + py_cv_module_=n/a ;; #( Emscripten|WASI) : diff --git a/configure.ac b/configure.ac index 416d77b6dc265d..a9aa01a5347c96 100644 --- a/configure.ac +++ b/configure.ac @@ -4908,7 +4908,7 @@ AC_CHECK_FUNCS([ \ getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \ getspnam getuid getwd if_nameindex initgroups kill killpg lchown linkat \ lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \ - mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \ + mknod mknodat mktime mmap mremap msync nice openat opendir pathconf pause pipe \ pipe2 plock poll posix_fadvise posix_fallocate posix_spawn posix_spawnp \ pread preadv preadv2 pthread_condattr_setclock pthread_init pthread_kill \ pwrite pwritev pwritev2 readlink readlinkat readv realpath renameat \ diff --git a/pyconfig.h.in b/pyconfig.h.in index 6d370f6664c10c..002b619d798b74 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -823,6 +823,9 @@ /* Define to 1 if you have the `mremap' function. */ #undef HAVE_MREMAP +/* Define to 1 if you have the `msync' function. */ +#undef HAVE_MSYNC + /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP From 6845007d356ceefd8445639e01a06bb6ad47e5d2 Mon Sep 17 00:00:00 2001 From: ada Date: Wed, 29 Apr 2026 15:14:53 -0500 Subject: [PATCH 3/3] revert configure change --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index 0eb5dd4e1c1534..2b29d7d8e80805 100755 --- a/configure +++ b/configure @@ -28662,7 +28662,6 @@ case $ac_sys_system in #( py_cv_module__testmultiphase=n/a py_cv_module__testsinglephase=n/a py_cv_module__testclinic=n/a - py_cv_module_=n/a ;; #( Emscripten|WASI) :