[Mlir-commits] [mlir] Added free-threading CPython mode support in MLIR Python bindings (PR #107103)
Scott Todd
llvmlistbot at llvm.org
Wed Jan 22 11:30:53 PST 2025
================
@@ -668,12 +668,31 @@ function(add_mlir_python_extension libname extname)
elseif(ARG_PYTHON_BINDINGS_LIBRARY STREQUAL "nanobind")
nanobind_add_module(${libname}
NB_DOMAIN mlir
+ FREE_THREADED
${ARG_SOURCES}
)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)
# Avoids warnings from upstream nanobind.
- target_compile_options(nanobind-static
+ set(nanobind_target "nanobind-static")
+ if (NOT TARGET ${nanobind_target})
+ # Get correct nanobind target name: nanobind-static-ft or something else
+ # It is set by nanobind_add_module function according to the passed options
+ get_property(all_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
----------------
ScottTodd wrote:
My downstream project is also setting `MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES` to take control over the Python dependency setup. Another solution is to only modify the target options if `MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES` is not set.
https://github.com/llvm/llvm-project/pull/107103
More information about the Mlir-commits
mailing list