Skip to content

[FIX] Support free-threaded Python cross-builds - #706

Open
iamthebot wants to merge 1 commit into
apache:mainfrom
iamthebot:al/fix-python314t-cross-build
Open

[FIX] Support free-threaded Python cross-builds#706
iamthebot wants to merge 1 commit into
apache:mainfrom
iamthebot:al/fix-python314t-cross-build

Conversation

@iamthebot

@iamthebot iamthebot commented Aug 11, 2026

Copy link
Copy Markdown

Summary

The conda-forge Python 3.14 free-threading migration is blocked for TVM FFI on platforms that rely on cross-compilation. Linux PPC64LE and macOS ARM64 builds fail during CMake's Python development lookup even though the target 3.14t headers are installed, while native 3.14t builds and GIL-enabled Python 3.14 cross-builds succeed.

This PR makes Python discovery distinguish the host interpreter used to run Cython from the target development artifacts used to build the extension. That lets downstream packagers build Python 3.14t wheels for those architectures without changing native builds or GIL-enabled cross-build behavior.

Background

Cross-compiling against Python 3.14t currently finds the host interpreter and detects
Py_GIL_DISABLED, but the second FindPython call combines that host interpreter with target
Development.Module artifacts. CMake 4.4 also enforces the gil_disabled ABI default of OFF,
so it rejects the installed python3.14t target headers and reports
missing: Development.Module.

The failing configurations are visible in
conda-forge/apache-tvm-ffi-feedstock#20:
Linux x86_64 to PPC64LE and macOS x86_64 to ARM64. Native Python 3.14t and cross-built GIL-enabled
Python 3.14 already pass.

This change keeps the first interpreter for free-thread detection and Cython, performs a
development-only target lookup when cross-compiling, and uses SKBUILD_SOABI for the target
extension suffix when available. Native discovery remains unchanged.

Fixes #705.

Testing

  • configured with CMake 4.4.2 against the exact PPC64LE Python 3.14t target headers; generated
    core.cpython-314t-powerpc64le-linux-gnu.so
  • configured with CMake 4.4.2 against the exact macOS ARM64 Python 3.14t target headers; generated
    core.cpython-314t-darwin.so
  • verified the cross path on CMake 3.26.4 and 3.30.5 with developer warnings treated as errors
  • built and imported an editable native Python 3.14t package; verified the extension retained its
    cpython-314t suffix
  • pytest -n0 -vvs tests/python/test_free_threaded_python_helpers.py tests/python/test_build.py::test_build_cpp
  • cmake-format --check CMakeLists.txt
  • cmake-lint CMakeLists.txt
  • ASF header, file-type, and whitespace checks

AI Disclosure

Was AI used in the creation of this PR?

  • No. This was fully written by a human.
  • Limited (uses other than code generation, such as ideation or debugging, or very limited code generation)
  • Moderate (code generated by an LLM with continuous human review and intervention)
  • High (key decisions made by a human with active steering and feedback; final code reviewed by the human)
  • Vibe Coded (generated largely autonomously from an initial prompt with limited human steering or review)

The human identified the failing downstream migration, set the upstream issue and PR scope, and
made the key workflow decisions. OpenAI Codex (GPT-5), including delegated Codex agents,
investigated the CMake behavior, implemented the change, ran the native and cross-build validation
matrix, reviewed the final diff, and prepared this PR. The human reviewed and approved the final
diff; agent review did not replace that review.

Separate host interpreter discovery from target development artifacts when cross-compiling. Select the free-threaded ABI for CMake 4.4+ and preserve scikit-build-core's target SOABI suffix.
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.

Cross-compiling against free-threaded Python 3.14 (3.14t) fails to find Development.Module

1 participant