From bbe55c07c3840cf9f4ec8bf65521b6d5617beb3e Mon Sep 17 00:00:00 2001 From: Zachary Lund Date: Mon, 16 Nov 2026 10:35:32 -0600 Subject: [PATCH] gh-162243: Fix shared-memory library detection with LIBS An existing -lrt in LIBS lets the shm_open probe succeed without recording librt for _posixshmem. The module is linked separately without LIBS, so its required library is missing on systems where libc does not provide it. Clear LIBS within the saved probe environment to determine the module's own requirements, following the curses fix in GH-156130. The actual module fails to import before the fix and shared-memory operations pass afterward. The full test suite passes, and configure is regenerated with the pinned Autoconf image. --- .../next/Build/2026-11-18-17-18-19.gh-issue-162243.c0081e.rst | 2 ++ configure | 1 + configure.ac | 1 + 3 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2026-11-18-17-18-19.gh-issue-162243.c0081e.rst diff --git a/Misc/NEWS.d/next/Build/2026-11-18-17-18-19.gh-issue-162243.c0081e.rst b/Misc/NEWS.d/next/Build/2026-11-18-17-18-19.gh-issue-162243.c0081e.rst new file mode 100644 index 000000000000000..364fd1900eb1b67 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-18-17-18-19.gh-issue-162243.c0081e.rst @@ -0,0 +1,2 @@ +Fix building Python's POSIX shared-memory module when ``LIBS`` contains +``-lrt`` on systems that require ``librt`` for shared-memory functions. diff --git a/configure b/configure index e033b0217aefad5..c0289cf24c933b0 100755 --- a/configure +++ b/configure @@ -34930,6 +34930,7 @@ save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS + LIBS="" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing shm_open" >&5 printf %s "checking for library containing shm_open... " >&6; } if test ${ac_cv_search_shm_open+y} diff --git a/configure.ac b/configure.ac index d654f680643041c..9ce680fdfb8ca19 100644 --- a/configure.ac +++ b/configure.ac @@ -8106,6 +8106,7 @@ AS_VAR_IF([ac_cv_func_getrandom], [yes], [ # shm_* may only be available if linking against librt POSIXSHMEM_CFLAGS='-I$(srcdir)/Modules/_multiprocessing' WITH_SAVE_ENV([ + LIBS="" AC_SEARCH_LIBS([shm_open], [rt]) AS_VAR_IF([ac_cv_search_shm_open], [-lrt], [POSIXSHMEM_LIBS="-lrt"])