Skip to content

Commit

Permalink
pythongh-109740: Use 't' in --disable-gil SOABI (python#109922)
Browse files Browse the repository at this point in the history
Shared libraries for CPython 3.13 are now marked with a 't' for
threading. For example, `binascii.cpython-313t-darwin.so`.
  • Loading branch information
colesbury authored and Glyphack committed Jan 27, 2024
1 parent e233cb4 commit 292ac4f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 48 deletions.
2 changes: 2 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ always available.

.. versionadded:: 3.2

.. availability:: Unix.


.. function:: addaudithook(hook)

Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,13 @@ def test_pystats(self):
sys._stats_clear()
sys._stats_dump()

@test.support.cpython_only
@unittest.skipUnless(hasattr(sys, 'abiflags'), 'need sys.abiflags')
def test_disable_gil_abi(self):
abi_threaded = 't' in sys.abiflags
py_nogil = (sysconfig.get_config_var('Py_NOGIL') == 1)
self.assertEqual(py_nogil, abi_threaded)


@test.support.cpython_only
class UnraisableHookTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The experimental ``--disable-gil`` configure flag now includes "t" (for "threaded") in
extension ABI tags.
10 changes: 8 additions & 2 deletions Python/dynload_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
#define PYD_DEBUG_SUFFIX ""
#endif

#ifdef Py_NOGIL
# define PYD_THREADING_TAG "t"
#else
# define PYD_THREADING_TAG ""
#endif

#ifdef PYD_PLATFORM_TAG
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) "-" PYD_PLATFORM_TAG ".pyd"
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG "-" PYD_PLATFORM_TAG ".pyd"
#else
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) ".pyd"
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG ".pyd"
#endif

#define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd"
Expand Down
65 changes: 34 additions & 31 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,23 @@ fi
AC_SUBST([ABIFLAGS])
ABIFLAGS=""

# Check for --disable-gil
# --disable-gil
AC_MSG_CHECKING([for --disable-gil])
AC_ARG_ENABLE([gil],
[AS_HELP_STRING([--disable-gil], [enable experimental support for running without the GIL (default is no)])],
[AS_VAR_IF([enable_gil], [yes], [disable_gil=no], [disable_gil=yes])], [disable_gil=no]
)
AC_MSG_RESULT([$disable_gil])

if test "$disable_gil" = "yes"
then
AC_DEFINE([Py_NOGIL], [1],
[Define if you want to disable the GIL])
# Add "t" for "threaded"
ABIFLAGS="${ABIFLAGS}t"
fi

# Check for --with-pydebug
AC_MSG_CHECKING([for --with-pydebug])
AC_ARG_WITH([pydebug],
Expand Down Expand Up @@ -5669,6 +5686,7 @@ AC_C_BIGENDIAN
#
# * The Python implementation (always 'cpython-' for us)
# * The major and minor version numbers
# * --disable-gil (adds a 't')
# * --with-pydebug (adds a 'd')
#
# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Expand Down Expand Up @@ -6947,21 +6965,6 @@ AC_ARG_ENABLE([test-modules],
AC_MSG_RESULT([$TEST_MODULES])
AC_SUBST([TEST_MODULES])

# Check for --disable-gil
# --disable-gil
AC_MSG_CHECKING([for --disable-gil])
AC_ARG_ENABLE([gil],
[AS_HELP_STRING([--disable-gil], [enable experimental support for running without the GIL (default is no)])],
[AS_VAR_IF([enable_gil], [yes], [disable_gil=no], [disable_gil=yes])], [disable_gil=no]
)
AC_MSG_RESULT([$disable_gil])

if test "$disable_gil" = "yes"
then
AC_DEFINE([Py_NOGIL], [1],
[Define if you want to disable the GIL])
fi

# gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
# On Linux aarch64, GCC may require programs and libraries to be linked
# explicitly to libatomic. Call _Py_atomic_or_uint64() which may require
Expand Down

0 comments on commit 292ac4f

Please sign in to comment.