Skip to content

Fix build failure on Python 3.14t without --enable-shared#1487

Open
leveretconey wants to merge 1 commit into
meta-pytorch:mainfrom
leveretconey:build
Open

Fix build failure on Python 3.14t without --enable-shared#1487
leveretconey wants to merge 1 commit into
meta-pytorch:mainfrom
leveretconey:build

Conversation

@leveretconey

Copy link
Copy Markdown

Free-threaded Python (3.13t+) uses mimalloc, whose initial-exec TLS is incompatible with shared libraries loaded via dlopen(). When Python is built without --enable-shared (the default), linking ${Python3_LIBRARIES} pulls in the static libpython3.14t.a and triggers a link error.

On Linux/macOS, extension modules don't need to link libpython — symbols resolve from the interpreter at runtime. Only Windows requires it (DLL import library).

This is consistent with how PyTorch handles it in torch/CMakeLists.txt (only links Python libraries on MSVC), and also consistent with pybind_ops in this repo which already avoids linking ${Python3_LIBRARIES}.

@pytorch-bot

pytorch-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1487

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 2 Cancelled Jobs

As of commit 01aafaa with merge base 8bbce65 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 16, 2026
@leveretconey

Copy link
Copy Markdown
Author

rebased latest main because new commits fixed ci failures

@NicolasHug

Copy link
Copy Markdown
Contributor

Thanks for the PR @leveretconey , I pulled this in #1485 but there seem to still be build issues for the free-threaded builds on windows.

Did you try to confirm the build was working on your side? And can you share about your needs for free-threaded wheels on Windows specifically?

@leveretconey

Copy link
Copy Markdown
Author

Thanks @NicolasHug! Yes, I confirmed the build works on Linux with Python 3.14.5t (free-threaded, without --enable-shared). Our use case is Linux wheels only — no specific need for Windows.

This PR preserves ${Python3_LIBRARIES}` linking underif(WIN32), so it shouldn't change Windows behavior. I don't have a Windows environment to investigate further, but happy to adjust if needed.

@NicolasHug

NicolasHug commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

I see, I got the context wrong, sorry.

So in that case my question becomes: in what context do you need this? We can build linux 3.14t wheels on our CI, e.g. here: https://github.com/meta-pytorch/torchcodec/actions/runs/26814497648/job/79052728683?pr=1477

@leveretconey

Copy link
Copy Markdown
Author

@NicolasHug Your CI Python is likely built with --enable-shared. In our environment (and many others like pyenv, system Python, official python.org builds), --enable-shared is not enabled by default. Linking ${Python3_LIBRARIES}` then pulls in the static libpython3.14t.a and fails. Since extension modules don't need to link libpython on Linux anyway, this fix is correct regardless.

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

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants