Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Oct 26, 2025

@kumaraditya303
Copy link
Contributor Author

cc @cdce8p

Copy link
Contributor

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the issue. Thanks @kumaraditya303!

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@kumaraditya303 kumaraditya303 merged commit f5394c2 into python:main Oct 27, 2025
47 checks passed
@kumaraditya303 kumaraditya303 deleted the tls branch October 27, 2025 20:10
@cdce8p
Copy link
Contributor

cdce8p commented Oct 27, 2025

Unfortunately it seems the last change broke it again.

/.../cpython/Include/internal/pycore_pystate.h:93:8: error: unknown type name '_Py_thread_local'
extern _Py_thread_local PyThreadState *_Py_tss_tstate;

/.../cpython/Include/internal/pycore_pystate.h:93:38: error: expected ';' after top level declarator
extern _Py_thread_local PyThreadState *_Py_tss_tstate;
                                     ^
                                     ;

It looks like _Py_thread_local only works for defined(HAVE_THREAD_LOCAL). So 34a2688 should probably be reverted.

cpython/Include/pyport.h

Lines 516 to 528 in f5394c2

# define HAVE_THREAD_LOCAL 1
# ifdef thread_local
# define _Py_thread_local thread_local
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
# define _Py_thread_local _Thread_local
# elif defined(_MSC_VER) /* AKA NT_THREADS */
# define _Py_thread_local __declspec(thread)
# elif defined(__GNUC__) /* includes clang */
# define _Py_thread_local __thread
# else
// fall back to the PyThread_tss_*() API, or ignore.
# undef HAVE_THREAD_LOCAL
# endif

@ZeroIntensity
Copy link
Member

No, this is all just HAVE_THREAD_LOCAL being messy. We should remove that all throughout the codebase and assume that thread locals are always available. mypyc will get some speedups from using the thread local directly. I'll put up a PR.

@cdce8p
Copy link
Contributor

cdce8p commented Oct 27, 2025

Sounds good. Happy to test it, just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants