Skip to content

gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it#148142

Merged
encukou merged 2 commits intopython:mainfrom
encukou:abi3t-pygildisabled
Apr 7, 2026
Merged

gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it#148142
encukou merged 2 commits intopython:mainfrom
encukou:abi3t-pygildisabled

Conversation

@encukou
Copy link
Copy Markdown
Member

@encukou encukou commented Apr 5, 2026

When compiling for abi3t, define Py_GIL_DISABLED, so that users who check it to enable additional locking aren't broken.

But also add a test that Python headers themselves don't use Py_GIL_DISABLED, since abi3 and abi3t ought to be the same except the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma, which tells the compiler/preprocessor to error if it ever sees the identifier after the pragma.
This did require rewriting some preprocessor conditions -- #if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) needs to be split into two lines, as the poisoning doesn't honour short-circuiting.
For _Py_IsOwnedByCurrentThread & supporting functions I opted to move them to a cpython/ header, as they're rather self-contained.

…se it

When compiling for abi3t, define Py_GIL_DISABLED, so that users who
check it to enable additional locking aren't broken.

But also add a test that Python headers themselves don't use
Py_GIL_DISABLED -- abi3 and abi3t ought to be the same except
the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma.
This did require rewriting some preprocessor conditions, and
moving _Py_IsOwnedByCurrentThread & supporting functions
to a cpython/ header.
@bedevere-app bedevere-app bot mentioned this pull request Apr 5, 2026
8 tasks
@encukou encukou marked this pull request as draft April 5, 2026 21:38
@encukou encukou marked this pull request as ready for review April 6, 2026 08:55
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 6, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit cb3c6fe 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F148142%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 6, 2026
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 7, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 1cd72a7 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F148142%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 7, 2026
@encukou encukou changed the title gh-146636: abi3t: Define Py_GIL_DISABLED but make sure not to use it gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it Apr 7, 2026
@encukou
Copy link
Copy Markdown
Member Author

encukou commented Apr 7, 2026

Some paths still use Py_GIL_DISABLED.
I'd like to merge this for today's alpha without the check; I'll add the check later.

@encukou encukou merged commit fbc1a5b into python:main Apr 7, 2026
77 of 86 checks passed
@encukou encukou deleted the abi3t-pygildisabled branch April 7, 2026 07:06
@bedevere-bot
Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows PGO Tailcall 3.x (tier-1) has failed when building commit fbc1a5b.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1870/builds/329) and take a look at the build logs.
  4. Check if the failure is related to this commit (fbc1a5b) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1870/builds/329

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 13, done.        
remote: Counting objects:  14% (1/7)        
remote: Counting objects:  28% (2/7)        
remote: Counting objects:  42% (3/7)        
remote: Counting objects:  57% (4/7)        
remote: Counting objects:  71% (5/7)        
remote: Counting objects:  85% (6/7)        
remote: Counting objects: 100% (7/7)        
remote: Counting objects: 100% (7/7), done.        
remote: Compressing objects:  16% (1/6)        
remote: Compressing objects:  33% (2/6)        
remote: Compressing objects:  50% (3/6)        
remote: Compressing objects:  66% (4/6)        
remote: Compressing objects:  83% (5/6)        
remote: Compressing objects: 100% (6/6)        
remote: Compressing objects: 100% (6/6), done.        
remote: Total 13 (delta 1), reused 4 (delta 1), pack-reused 6 (from 3)        
From https://github.com/python/cpython
 * branch                    main       -> FETCH_HEAD
Note: switching to 'fbc1a5b0761f4331c7070201fefd5b5deb75ebdd'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at fbc1a5b0761 gh-146636: abi3t: Define Py_GIL_DISABLED but do not use it (GH-148142)
Switched to and reset branch 'main'

Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\PCbuild\*.pgc
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\Lib\*.pyc
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\PCbuild\*.pgc
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\Lib\*.pyc
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\PCbuild\python*.zip

Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find C:\bbarea\3.x.itamaro-win64-srv-22-aws.tailcall.pgo\build\PCbuild\python*.zip

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

Projects

Development

Successfully merging this pull request may close these issues.

2 participants