Skip to content

unix: build test extensions as shared libraries; enable _testcapi#1025

Open
indygreg wants to merge 2 commits intogps-depot-larger-runnersfrom
gps-test-extension-shared-libraries
Open

unix: build test extensions as shared libraries; enable _testcapi#1025
indygreg wants to merge 2 commits intogps-depot-larger-runnersfrom
gps-test-extension-shared-libraries

Conversation

@indygreg
Copy link
Collaborator

@indygreg indygreg commented Mar 22, 2026

Way back when we only supported statically linked extension modules. And we had to disable _testcapi and _testlimitedcapi because it wouldn't build statically.

Now that we support building extension modules as shared libraries, we can enable _testcapi and _testlimitedcapi as shared libraries.

This commit makes that change.

By making this change, we eliminate the largest single source of test failures. But this impact is not captured in code or CI since we currently don't run the stdlib tests in CI.

Enabling the new extensions allows tests - including PGO training tests - to exercise new code paths. This resulted in a new segfault appearing in test_bytes. Why, I'm not sure. (My best guess is it has something to do with calling variadic functions via ctypes.) This particular crash was likely a latent issue. We ignore this crashing test during PGO training as a workaround.

In order to get the extensions enabled on musl shared builds - but not static - we had to introduce some new logic to conditionally enable a shared extension on supported targets while automatically disabling on static targets. There may be a cleaner way to express this semantic intent. But the implemented solution does work.

@indygreg indygreg force-pushed the gps-test-extension-shared-libraries branch 8 times, most recently from 9cd0276 to 1c77491 Compare March 22, 2026 03:02
@indygreg indygreg changed the base branch from main to gps-depot-larger-runners March 22, 2026 03:52
@indygreg indygreg force-pushed the gps-test-extension-shared-libraries branch from 1c77491 to 895a59c Compare March 22, 2026 03:57
Way back when we only supported statically linked extension modules. And
we had to disable `_testcapi` because it wouldn't build statically.

Now that we support building extension modules as shared libraries,
it makes sense for extension modules in support of tests to not be
part of libpython and to be shared libraries.

This commit makes that change.

And since `_testcapi` is buildable as a shared library, we enable it.
In doing so, we eliminate the largest single source of test failures.
@indygreg indygreg force-pushed the gps-test-extension-shared-libraries branch from 895a59c to 15c329a Compare March 22, 2026 04:43
@indygreg indygreg marked this pull request as ready for review March 22, 2026 09:54
@indygreg indygreg marked this pull request as draft March 23, 2026 02:11
@indygreg
Copy link
Collaborator Author

I'm going to continue iterating on this to get musl shared builds to behave better.

@indygreg indygreg force-pushed the gps-test-extension-shared-libraries branch from fb5f7c3 to 77b14cd Compare March 23, 2026 03:07
@indygreg indygreg marked this pull request as ready for review March 23, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant