From 21d8670b6a2597f0aa1bf40709f76ebab8e08f99 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 20 Jul 2026 18:41:09 +0300 Subject: [PATCH 1/2] gh-154271: Define _XOPEN_SOURCE=600 on Solaris to enable socket ancillary data and forkserver Solaris declares the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) only under _XOPEN_SOURCE >= 600. __EXTENSIONS__ keeps the other platform features. This enables the forkserver start method. Co-Authored-By: Claude Opus 4.8 (1M context) --- ...6-07-20-20-30-00.gh-issue-154271.solxopen.rst | 4 ++++ configure | 16 +++++++++++----- configure.ac | 15 ++++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst diff --git a/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst b/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst new file mode 100644 index 000000000000000..b1a73966ccd68b1 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst @@ -0,0 +1,4 @@ +Define ``_XOPEN_SOURCE=600`` on Solaris and illumos, so that the socket +module is built with :meth:`~socket.socket.sendmsg`, +:meth:`~socket.socket.recvmsg` and the ``CMSG_*`` helpers. This also +enables the ``forkserver`` :mod:`multiprocessing` start method. diff --git a/configure b/configure index 71fa0b435d16505..576d8f5280a84e2 100755 --- a/configure +++ b/configure @@ -4742,11 +4742,8 @@ printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h # Marc Recht NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S]) define_xopen_source=no;; - # From the perspective of Solaris, _XOPEN_SOURCE is not so much a - # request to enable features supported by the standard as a request - # to disable features not supported by the standard. The best way - # for Python to use Solaris is simply to leave _XOPEN_SOURCE out - # entirely and define __EXTENSIONS__ instead. + # On Solaris, _XOPEN_SOURCE disables features unless __EXTENSIONS__ is + # also defined; a dedicated _XOPEN_SOURCE=600 is set for it below. SunOS/*) define_xopen_source=no;; # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, @@ -4818,6 +4815,15 @@ printf "%s\n" "#define _ISOC23_SOURCE 1" >>confdefs.h fi +# On Solaris the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) +# needs _XOPEN_SOURCE >= 600; __EXTENSIONS__ keeps the other platform +# features. This enables the forkserver start method. See gh-57208. +if test "$ac_sys_system" = "SunOS"; then + +printf "%s\n" "#define _XOPEN_SOURCE 600" >>confdefs.h + +fi + # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE case $ac_sys_system in hp*|HP*) diff --git a/configure.ac b/configure.ac index 5fcf406087cbe5e..b3d58cfd224b81f 100644 --- a/configure.ac +++ b/configure.ac @@ -871,11 +871,8 @@ case $ac_sys_system/$ac_sys_release in # Marc Recht NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) define_xopen_source=no;; - # From the perspective of Solaris, _XOPEN_SOURCE is not so much a - # request to enable features supported by the standard as a request - # to disable features not supported by the standard. The best way - # for Python to use Solaris is simply to leave _XOPEN_SOURCE out - # entirely and define __EXTENSIONS__ instead. + # On Solaris, _XOPEN_SOURCE disables features unless __EXTENSIONS__ is + # also defined; a dedicated _XOPEN_SOURCE=600 is set for it below. SunOS/*) define_xopen_source=no;; # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, @@ -943,6 +940,14 @@ then [Define to activate ISO C23 library declarations]) fi +# On Solaris the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) +# needs _XOPEN_SOURCE >= 600; __EXTENSIONS__ keeps the other platform +# features. This enables the forkserver start method. See gh-57208. +if test "$ac_sys_system" = "SunOS"; then + AC_DEFINE([_XOPEN_SOURCE], [600], + [Define to the level of X/Open that your system supports]) +fi + # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE case $ac_sys_system in hp*|HP*) From 3b3e48054e35828f0e33deb2c72ce93388c1c088 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 22 Jul 2026 13:47:47 +0300 Subject: [PATCH 2/2] Define _XOPEN_SOURCE in a single place and mention illumos Move the Solaris definition into the same conditional as the general one, so that all _XOPEN_SOURCE decisions are together. The socket ancillary data API is gated on _XOPEN_SOURCE only on illumos; Solaris declares it anyway. Co-Authored-By: Claude Opus 4.8 --- ...6-07-20-20-30-00.gh-issue-154271.solxopen.rst | 4 ++-- configure | 16 ++++++++-------- configure.ac | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst b/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst index b1a73966ccd68b1..7f1744b797015a9 100644 --- a/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst +++ b/Misc/NEWS.d/next/Build/2026-07-20-20-30-00.gh-issue-154271.solxopen.rst @@ -1,4 +1,4 @@ -Define ``_XOPEN_SOURCE=600`` on Solaris and illumos, so that the socket -module is built with :meth:`~socket.socket.sendmsg`, +Define ``_XOPEN_SOURCE=600`` on Solaris and illumos, so that on illumos the +socket module is built with :meth:`~socket.socket.sendmsg`, :meth:`~socket.socket.recvmsg` and the ``CMSG_*`` helpers. This also enables the ``forkserver`` :mod:`multiprocessing` start method. diff --git a/configure b/configure index 444524fd0c14682..7e729832a8e76c3 100755 --- a/configure +++ b/configure @@ -4742,8 +4742,8 @@ printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h # Marc Recht NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S]) define_xopen_source=no;; - # On Solaris, _XOPEN_SOURCE disables features unless __EXTENSIONS__ is - # also defined; a dedicated _XOPEN_SOURCE=600 is set for it below. + # On Solaris, _XOPEN_SOURCE=800 hides platform specific features. + # A lower level is defined below. SunOS/*) define_xopen_source=no;; # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, @@ -4813,12 +4813,12 @@ printf "%s\n" "#define _POSIX_C_SOURCE 202405L" >>confdefs.h printf "%s\n" "#define _ISOC23_SOURCE 1" >>confdefs.h -fi - -# On Solaris the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) -# needs _XOPEN_SOURCE >= 600; __EXTENSIONS__ keeps the other platform -# features. This enables the forkserver start method. See gh-57208. -if test "$ac_sys_system" = "SunOS"; then +elif test "$ac_sys_system" = "SunOS" +then + # On illumos the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) + # is declared only with _XOPEN_SOURCE >= 600; Solaris declares it anyway. + # __EXTENSIONS__ keeps the platform specific features which _XOPEN_SOURCE + # would otherwise hide. See gh-57208. printf "%s\n" "#define _XOPEN_SOURCE 600" >>confdefs.h diff --git a/configure.ac b/configure.ac index 3e541bfc1585f84..d41223aff51565d 100644 --- a/configure.ac +++ b/configure.ac @@ -871,8 +871,8 @@ case $ac_sys_system/$ac_sys_release in # Marc Recht NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) define_xopen_source=no;; - # On Solaris, _XOPEN_SOURCE disables features unless __EXTENSIONS__ is - # also defined; a dedicated _XOPEN_SOURCE=600 is set for it below. + # On Solaris, _XOPEN_SOURCE=800 hides platform specific features. + # A lower level is defined below. SunOS/*) define_xopen_source=no;; # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, @@ -938,12 +938,12 @@ then # with -std=c11. Defining _ISOC23_SOURCE makes them visible again. AC_DEFINE([_ISOC23_SOURCE], [1], [Define to activate ISO C23 library declarations]) -fi - -# On Solaris the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) -# needs _XOPEN_SOURCE >= 600; __EXTENSIONS__ keeps the other platform -# features. This enables the forkserver start method. See gh-57208. -if test "$ac_sys_system" = "SunOS"; then +elif test "$ac_sys_system" = "SunOS" +then + # On illumos the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) + # is declared only with _XOPEN_SOURCE >= 600; Solaris declares it anyway. + # __EXTENSIONS__ keeps the platform specific features which _XOPEN_SOURCE + # would otherwise hide. See gh-57208. AC_DEFINE([_XOPEN_SOURCE], [600], [Define to the level of X/Open that your system supports]) fi