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"])