FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-140544: fix build for including `pycore_pystate.h` when `HAVE_THREAD_LOCAL` is not defined by kumaraditya303 · Pull Request #140623 · python/cpython · GitHub

/ cpython Public

gh-140544: fix build for including pycore_pystate.h when HAVE_THREAD_LOCAL is not defined - #140623

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
kumaraditya303:tls
Oct 27, 2025
Merged

gh-140544: fix build for including pycore_pystate.h when HAVE_THREAD_LOCAL is not defined#140623
kumaraditya303 merged 2 commits into
python:mainfrom
kumaraditya303:tls

Conversation

kumaraditya303 commented Oct 26, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

cc @cdce8p

cdce8p left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This fixes the issue. Thanks @kumaraditya303!

Comment thread Include/internal/pycore_pystate.h Outdated

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks.

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

cdce8p commented Oct 27, 2025

Copy link
Copy Markdown
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

# 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

Copy link
Copy Markdown
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 commented Oct 27, 2025

Copy link
Copy Markdown
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL