iamthebot opened a new issue, #705:
URL: https://github.com/apache/tvm-ffi/issues/705

   ## Description
   I'm one of the maintainers of the conda-forge package for apache-tvm-ffi and 
ran into this. Cross-compiling `apache-tvm-ffi` 0.1.13.post3 against 
free-threaded CPython 3.14 fails during CMake configuration, even though the 
target development headers are installed.
   
   This is reproducible in 
[conda-forge/apache-tvm-ffi-feedstock#20](https://github.com/conda-forge/apache-tvm-ffi-feedstock/pull/20)
 for:
   
   - `linux-64` → `linux-ppc64le`
   - `osx-64` → `osx-arm64`
   
   The corresponding cross-compiled GIL-enabled Python 3.14 builds pass, as do 
native Python 3.14t builds.
   
   ## Error
   
   Both failing jobs report:
   
   ```text
   -- Found Python: ... (found version "3.14.6") found components: Interpreter
   -- Free-threaded Python detected.
   CMake Error ...
     Could NOT find Python (missing: Development.Module)
     (found suitable exact version "3.14.6")
   ...
     CMakeLists.txt:262 (find_package)
   ```
   
   CI logs:
   
   - [Linux PPC64LE Python 
3.14t](https://github.com/conda-forge/apache-tvm-ffi-feedstock/actions/runs/31447767536/job/93645550751)
   - [macOS ARM64 Python 
3.14t](https://dev.azure.com/conda-forge/84710dde-1620-425b-80d0-4cf5baca359d/_build/results?buildId=1565871&view=logs&jobId=0bffcc46-b591-524d-b470-fe7cc095b4e2)
   
   The target packages contain `include/python3.14t/Python.h`; their 
`pyconfig.h` defines `Py_GIL_DISABLED 1`, and their target sysconfig data has 
`ABIFLAGS='t'`.
   
   ## Analysis
   
   The current CMake logic first finds the host interpreter and detects that it 
is free-threaded, then performs a second lookup requesting both `Interpreter` 
and `Development.Module`:
   
   
https://github.com/apache/tvm-ffi/blob/f59eae05349dd77d5de07a1883fe88fabe6bab65/CMakeLists.txt#L241-L266
   
   Two things are needed for the cross-build:
   
   1. `Python_FIND_ABI` must explicitly select the free-threaded ABI. On POSIX, 
CMake defaults it to `ANY;ANY;ANY;OFF`, which excludes the `t` ABI.
   2. The second cross-compilation lookup should request only the target 
`Development.Module`, rather than combining it with the host `Interpreter`.
   
   Using CMake 4.4.2 with the exact PPC64LE and macOS ARM64 target packages:
   
   - The current combined lookup fails.
   - Setting `Python_FIND_ABI` while retaining the combined lookup still fails.
   - Setting `Python_FIND_ABI` and making the second lookup 
`Development.Module`-only succeeds.
   
   This also follows CMake’s documented model of separate host-interpreter and 
target-development searches:
   
   https://cmake.org/cmake/help/v4.4/module/FindPython.html
   
   ## Proposed fix
   
   For free-threaded Python, set:
   
   ```cmake
   set(Python_FIND_ABI "OFF;ANY;ANY;ON")
   ```
   
   When `CMAKE_CROSSCOMPILING` is true, retain the first Interpreter-only 
lookup for version detection and later Cython use, but make the second lookup:
   
   ```cmake
   find_package(
     Python ${_tvm_ffi_python_version} EXACT
     COMPONENTS Development.Module
     REQUIRED
   )
   ```
   
   Native builds can retain the existing combined `Interpreter 
Development.Module` lookup.
   
   This seems easy enough to fix so throwing up a PR and linking it to this 
issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to