[Mlir-commits] [mlir] [mlir][python] declare `_PyClassMethod_New` undefined at link time (PR #121597)
Maksim Levental
llvmlistbot at llvm.org
Fri Jan 3 12:04:20 PST 2025
https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/121597
`NanobindAdaptors.h` uses `PyClassMethod_New` to build `pure_subclass`es but nanobind doesn't declare this API as undefined in its linker flags. so we need to declare it as such for downstream users that do not do something like `-undefined dynamic_lookup`
See https://github.com/iree-org/iree/issues/19591#issuecomment-2569591755.
>From ba6ee7b4c77826a3563ae5d985f4e41cc6b402d2 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Fri, 3 Jan 2025 12:02:52 -0800
Subject: [PATCH] Update AddMLIRPython.cmake
---
mlir/cmake/modules/AddMLIRPython.cmake | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 9d4e06c7909c81..2bcabab6f9c5e3 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -686,6 +686,12 @@ function(add_mlir_python_extension libname extname)
endif()
target_compile_options(${libname} PRIVATE ${eh_rtti_enable})
+ if(APPLE)
+ # NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind
+ # doesn't declare this API as undefined in its linker flags. so we need to declare it as such
+ # for downstream users that do not do something like -undefined dynamic_lookup
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-U -Wl,_PyClassMethod_New")
+ endif()
# Configure the output to match python expectations.
set_target_properties(
More information about the Mlir-commits
mailing list