[Mlir-commits] [mlir] [mlir][python] Avoid versioned Python DLL with stable ABI on Windows (PR #225794)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 23 07:37:07 PDT 2026
https://github.com/miyanyan updated https://github.com/llvm/llvm-project/pull/225794
>From 1bf379cce68cbcd943e590f52ebc943508cd5cf7 Mon Sep 17 00:00:00 2001
From: miyanyan <1138989048 at qq.com>
Date: Wed, 23 Sep 2026 22:25:06 +0800
Subject: [PATCH] [mlir][python] Avoid versioned Python DLL with stable ABI on
Windows
---
mlir/cmake/modules/AddMLIRPython.cmake | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 1e483116569a06..0511116789fd1a 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -1137,9 +1137,12 @@ function(add_mlir_python_extension libname extname nb_library_target_name)
# python.h, so that the release python library would be used).
# Since mlir uses nanobind, we can leverage their workaround by never directly
# pyconfig.h or python.h and instead relying on the nanobind headers to include the
- # necessary python headers. This results in mlir always linking against the
+ # necessary python headers. For non-stable ABI builds, link against the
# release python library via the (undocumented) cmake property Python3_LIBRARY_RELEASE.
- target_link_libraries(${libname} PRIVATE ${Python3_LIBRARY_RELEASE})
+ # nanobind already links stable ABI targets against Python::SABIModule.
+ if(NOT MLIR_ENABLE_PYTHON_STABLE_ABI OR NB_ABI MATCHES "[0-9]t")
+ target_link_libraries(${libname} PRIVATE ${Python3_LIBRARY_RELEASE})
+ endif()
endif()
################################################################################
More information about the Mlir-commits
mailing list