Title: Py_GIL_DISABLED not defined in "free-threaded" Windows C-API extensions · Issue #111650 · python/cpython · GitHub
Open Graph Title: Py_GIL_DISABLED not defined in "free-threaded" Windows C-API extensions · Issue #111650 · python/cpython
X Title: Py_GIL_DISABLED not defined in "free-threaded" Windows C-API extensions · Issue #111650 · python/cpython
Description: Bug report On Windows, the Py_GIL_DISABLED macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., --disable-gil). Now that biased reference counting (6dfb8fe) landed, this leads to incorre...
Open Graph Description: Bug report On Windows, the Py_GIL_DISABLED macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., --disable-gil). Now that biased reference counting...
X Description: Bug report On Windows, the Py_GIL_DISABLED macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., --disable-gil). Now that biased reference counting...
Opengraph URL: https://github.com/python/cpython/issues/111650
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Py_GIL_DISABLED not defined in \"free-threaded\" Windows C-API extensions ","articleBody":"# Bug report\r\n\r\nOn Windows, the `Py_GIL_DISABLED` macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., `--disable-gil`). Now that biased reference counting (6dfb8fe) landed, this leads to incorrect/failed compilation of extensions on Windows [^1]. The problem does not occur on Linux/macOS and other `./configure` based builds because that build system defines the `Py_NOGIL` macro as part of `pyconfig.h`. On Windows, `Py_GIL_DISABLED` instead defined as a pre-processor definition in [`pyproject.props`](https://github.com/python/cpython/blob/4fe22c73770fe86b01ef7a4f1f38e7e925c0e090/PCbuild/pyproject.props#L43), but that's used by C-API extensions.\r\n\r\nAmong other problems, this leads to `test_peg_generator` failing on the nogil Windows buildbot ([example failure](https://buildbot.python.org/all/#/builders/1241/builds/331)).\r\n\r\nI can think of two possible approaches to fixing this:\r\n\r\n1) Modify setuptools (maybe setuptools.distutils?) to define `Py_GIL_DISABLED` when invoking the compiler if `sysconfig.get_config_var(\"Py_NOGIL\")` is `True`.\r\n2) In the CPython Windows build, generate a header file defining/undefing `Py_GIL_DISABLED` depending on if the build is invoked with `--disable-gil` or not.\r\n\r\nThe first option seems a little more straightforward to me, but there is a risk that we might encounter this same issue across multiple extension build systems. The second option seems like it would more robustly address this issue.\r\n\r\n[^1]: Modules built as part of the CPython build (i.e., standard library modules) still work\r\n\r\n\u003c!-- gh-linked-prs -->\r\n### Linked PRs\r\n* gh-112179\r\n* gh-112778\r\n\u003c!-- /gh-linked-prs -->\r\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2023-11-02T15:12:33Z","url":"https://github.com/python/cpython/issues/111650"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:ce12d206-8649-6676-5ec2-93b9f9cfdd14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88FC:380435:AD3C00:DA7B0C:6B0222E8 |
| html-safe-nonce | f20c92ec1e3b26e76e969b4133fb56edda806eaeadb538d85da30aa892ecd7e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEZDOjM4MDQzNTpBRDNDMDA6REE3QjBDOjZCMDIyMkU4IiwidmlzaXRvcl9pZCI6IjQwNDQyNTIwNTIyMjQ4NzcyODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7897cf0d20b84e94f3bf4c32cb45b9e6fbcc5de7d792ead78a3510ad847a9723 |
| hovercard-subject-tag | issue:1974474141 |
| 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/111650/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a971c6ef9255ad33faf68cdccc9357193aec4ff3f2a6c3bb6a018d1605b57174/python/cpython/issues/111650 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a971c6ef9255ad33faf68cdccc9357193aec4ff3f2a6c3bb6a018d1605b57174/python/cpython/issues/111650 |
| og:image:alt | Bug report On Windows, the Py_GIL_DISABLED macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., --disable-gil). Now that biased reference counting... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width