You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Build failure without thread local support #127865
When building environments without thread local support, this build failure occurs:
~/cpython-3.13.1/Python/import.c:750: error: argument of type "PyMutex" is incompatible with parameter of type "PyThread_type_lock"
PyThread_acquire_lock(EXTENSIONS.mutex, WAIT_LOCK);
^
~/cpython-3.13.1/Python/import.c:760: error: argument of type "PyMutex" is incompatible with parameter of type "PyThread_type_lock"
PyThread_release_lock(EXTENSIONS.mutex);
^
~/cpython-3.13.1/Python/import.c:769: error: argument of type "PyMutex" is incompatible with parameter of type "PyThread_type_lock"
PyThread_acquire_lock(EXTENSIONS.mutex, WAIT_LOCK);
^
~/cpython-3.13.1/Python/import.c:774: error: argument of type "PyMutex" is incompatible with parameter of type "PyThread_type_lock"
PyThread_release_lock(EXTENSIONS.mutex);
The issue is caused by incomplete change introduced with the commit 628f6eb from the PR #112207.
I suspect the fix is to just change that to PyMutex_Lock, but which system is this? We explicitly dropped support for systems without multithreading back in 3.7, but I'm not sure if the ability to have thread-locals falls under that umbrella.
Do you think it's worth trying to fix (and test) building Python without thread locals? Using PyThread_tss shouldn't be too difficult for the thread state, but I'm not sure what other cases exist.
C11 (and C23) have thread local as part of the language
We require C11 since Python 3.11
I don't think a PyThread_tss fallback is worth the maintenance effort just to support unnamed hardware from an unnamed company 👁️ 🐝 M.
There was a proposal WG14 N2291 for C23 to make _Thread_local dependent on __STDC_NO_THREADS__. It wasn't accepted. (I bet you can guess the author's company!)
I think the opposite: we should get rid of HAS_THREAD_LOCAL and move the #error message to pyport.h:
* All the [supported platforms](https://peps.python.org/pep-0011/#support-tiers) support thread local variables
* C11 (and C23) have thread local as part of the language
* We require C11 since Python 3.11
I don't think a PyThread_tss fallback is worth the maintenance effort just to support unnamed hardware from an unnamed company 👁️ 🐝 M.
There was a proposal WG14 N2291 for C23 to make _Thread_local dependent on __STDC_NO_THREADS__. It wasn't accepted. (I bet you can guess the author's company!)
It is not 👁️ 🐝 M. The mainframe system was originally developed by Siemens. But I guess all mainframes have their hardships supporting thread locals.
Activity
ZeroIntensity commentedon Dec 12, 2024
I suspect the fix is to just change that to
PyMutex_Lock, but which system is this? We explicitly dropped support for systems without multithreading back in 3.7, but I'm not sure if the ability to have thread-locals falls under that umbrella.velemas commentedon Dec 12, 2024
@ZeroIntensity thread-locals are not necessary for multithreading.
The affected system is a mainframe.
colesbury commentedon Dec 12, 2024
It's good to fix the erroneous calls to
PyThread_acquire_lock, but I think you'll still run into:cpython/Python/pystate.c
Lines 74 to 78 in 487fdbe
colesbury commentedon Dec 12, 2024
@velemas what compiler and system are you using?
_Thread_localis a non-optional part of C11. As far as I can tell it's independent of_STDC_NO_THREADS_. Some relevant discussion on Stack Overflow.That makes me think we should adjust the condition in pyport.h to remove the
_STDC_NO_THREADS_guard:cpython/Include/pyport.h
Lines 508 to 509 in 487fdbe
velemas commentedon Dec 12, 2024
@colesbury It is the local mainframe system compiler based on LLVM with C11 support but all C11 threading features are still missing there.
velemas commentedon Dec 12, 2024
That part is covered with local patching by falling back to PyThread_tss_*() API as the comment suggests.
ZeroIntensity commentedon Dec 12, 2024
What do you mean by "local patching"? The thread state doesn't fall back to
PyThread_tss(it's a TODO comment).velemas commentedon Dec 12, 2024
@ZeroIntensity There is a port of python for the mainframe and that part is covered with the port patches from the mainframe maintainers (incl. me).
This commit fixes the issue pythongh-127865.
This commit fixes the issue pythongh-127865.
gh-127865: Fix build failure for systems without thread local support (…
pythongh-127865: Fix build failure for systems without thread local s…
[3.13] gh-127865: Fix build failure for systems without thread local …
colesbury commentedon Dec 12, 2024
Thanks!
ZeroIntensity commentedon Dec 12, 2024
Do you think it's worth trying to fix (and test) building Python without thread locals? Using
PyThread_tssshouldn't be too difficult for the thread state, but I'm not sure what other cases exist.colesbury commentedon Dec 12, 2024
I think the opposite: we should get rid of
HAS_THREAD_LOCALand move the#errormessage topyport.h:I don't think a
PyThread_tssfallback is worth the maintenance effort just to support unnamed hardware from an unnamed company 👁️ 🐝 M.There was a proposal WG14 N2291 for C23 to make
_Thread_localdependent on__STDC_NO_THREADS__. It wasn't accepted. (I bet you can guess the author's company!)ZeroIntensity commentedon Dec 13, 2024
Now I'm curious what "unnamed company" has against thread locals!
Anyways, removing the macro seems reasonable if everything we support must have thread locals. It might be worth deprecating
PyThread_tsstoo.velemas commentedon Dec 13, 2024
It is not 👁️ 🐝 M. The mainframe system was originally developed by Siemens. But I guess all mainframes have their hardships supporting thread locals.
pythongh-127865: Fix build failure for systems without thread local s…