Title: python.h setting HAVE_THREAD_LOCAL breaks numpy build · Issue #142163 · python/cpython · GitHub
Open Graph Title: python.h setting HAVE_THREAD_LOCAL breaks numpy build · Issue #142163 · python/cpython
X Title: python.h setting HAVE_THREAD_LOCAL breaks numpy build · Issue #142163 · python/cpython
Description: Currently NumPy will fail to build on some systems using CPython main with the following error: FAILED: [code=1] numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.o cc -Inumpy/_core/_multiarray_umath.cpy...
Open Graph Description: Currently NumPy will fail to build on some systems using CPython main with the following error: FAILED: [code=1] numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c....
X Description: Currently NumPy will fail to build on some systems using CPython main with the following error: FAILED: [code=1] numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c....
Opengraph URL: https://github.com/python/cpython/issues/142163
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"python.h setting HAVE_THREAD_LOCAL breaks numpy build","articleBody":"Currently NumPy will fail to build on some systems using CPython `main` with the following error:\n\n```\n FAILED: [code=1] numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.o\n cc -Inumpy/_core/_multiarray_umath.cpython-315-darwin.so.p -Inumpy/_core -I../numpy/_core -Inumpy/_core/include -I../numpy/_core/include -I../numpy/_core/src/common -I../numpy/_core/src/multiarray -I../numpy/_core/src/npymath -I../numpy/_core/src/umath -I../numpy/_core/src/highway -I/Users/goldbaum/.pyenv/versions/3.15-dev/include/python3.15 -I/Users/goldbaum/Documents/numpy/.mesonpy-9trjlyib/meson_cpu -fvisibility=hidden -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c11 -O3 -fno-strict-aliasing -ftrapping-math -DNPY_HAVE_CLANG_FPSTRICT -DNPY_HAVE_NEON_VFPV4 -DNPY_HAVE_NEON_FP16 -DNPY_HAVE_NEON -DNPY_HAVE_ASIMD -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework -idirafter/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Headers -DACCELERATE_NEW_LAPACK -DHAVE_CBLAS '-DBLAS_SYMBOL_SUFFIX=$NEWLAPACK' -DNPY_INTERNAL_BUILD -DHAVE_NPY_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -MD -MQ numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.o -MF numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.o.d -o numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.o -c numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/scalartypes.c\n In file included from ../numpy/_core/src/multiarray/scalartypes.c.src:28:\n ../numpy/_core/src/multiarray/conversion_utils.h:116:22: error: unknown type name 'thread_local'\n 116 | extern NPY_NO_EXPORT NPY_TLS int evil_global_disable_warn_O4O8_flag;\n | ^\n ../numpy/_core/include/numpy/npy_common.h:131:21: note: expanded from macro 'NPY_TLS'\n 131 | #define NPY_TLS thread_local\n | ^\n 1 error generated.\n```\n\nYou can see why that's happening by looking at `npy_common.h` and noting that it depends on `HAVE_THREAD_LOCAL` being set by NumPy's meson build configuration based on a configure-time check:\n\nhttps://github.com/numpy/numpy/blob/fb0578d3973e926eee2e68ce9fd9996459b8534b/numpy/_core/include/numpy/npy_common.h#L128-L140\n\nhttps://github.com/numpy/numpy/blob/fb0578d3973e926eee2e68ce9fd9996459b8534b/numpy/_core/meson.build#L269-L294\n\nSince #140690 was merged, `python.h` now unconditionally sets `HAVE_THREAD_LOCAL`, breaking the logic in `npy_common.h`.\n\nMaybe on the NumPy side we should be prepending macros that depend on configure-time checks with a `NPY_` prefix to avoid issues like this but also numpy might not be the only library where `HAVE_THREAD_LOCAL` is load-bearing. I don't see anything besides Python and NumPy in a github search: https://github.com/search?q=HAVE_THREAD_LOCAL+language%3AC+python.h\u0026type=code\u0026p=2\n\ncc @ZeroIntensity. Also h/t to @tacaswell for originally finding this, reporting it on Discord, and bisecting it.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142164\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ngoldbaum","@type":"Person","name":"ngoldbaum"},"datePublished":"2025-12-01T23:06:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/142163/cpython/issues/142163"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5b7e8262-6632-bcd0-edff-afc4f4daa9e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C984:146FD0:B0D3EA:F6C37B:696A33EC |
| html-safe-nonce | 36d52bc8c862b6a5f7dd98b079a6ed1a28d9521a3a9c18693a492ecfd1e94bea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTg0OjE0NkZEMDpCMEQzRUE6RjZDMzdCOjY5NkEzM0VDIiwidmlzaXRvcl9pZCI6IjI0MTczNTcxODUzNzMzMjAxNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 83aeabd57b2739f51aa4acc7f01e4c4f62013dadd89d8f0db9105ef7edf3c734 |
| hovercard-subject-tag | issue:3683235562 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/142163/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2974ae343a2680f6570c4ee8dfafbdcdf4bbda38c7e317d76b7fcde8e7d910d3/python/cpython/issues/142163 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2974ae343a2680f6570c4ee8dfafbdcdf4bbda38c7e317d76b7fcde8e7d910d3/python/cpython/issues/142163 |
| og:image:alt | Currently NumPy will fail to build on some systems using CPython main with the following error: FAILED: [code=1] numpy/_core/_multiarray_umath.cpython-315-darwin.so.p/meson-generated_scalartypes.c.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ngoldbaum |
| hostname | github.com |
| expected-hostname | github.com |
| None | 321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7a9163cefd1ea4bd06f8eb7c082f43e4e53f626f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width