Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303kumaraditya303 commented Oct 26, 2025

@kumaraditya303
Copy link
ContributorAuthor

cc @cdce8p

Copy link
Contributor

@cdce8pcdce8p 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

@ZeroIntensityZeroIntensity 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.

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

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

# defineHAVE_THREAD_LOCAL1
# ifdef thread_local
# define_Py_thread_localthread_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

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

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kumaraditya303@cdce8p@ZeroIntensity