[Mlir-commits] [mlir] 78f0447 - [mlir][python] declare `_PyClassMethod_New` undefined at link time (#121597)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jan 3 13:52:11 PST 2025
Author: Maksim Levental
Date: 2025-01-03T13:52:07-08:00
New Revision: 78f04477d658ae3de3cd416947c5bac65262a9ec
URL: https://github.com/llvm/llvm-project/commit/78f04477d658ae3de3cd416947c5bac65262a9ec
DIFF: https://github.com/llvm/llvm-project/commit/78f04477d658ae3de3cd416947c5bac65262a9ec.diff
LOG: [mlir][python] declare `_PyClassMethod_New` undefined at link time (#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`
Added:
Modified:
mlir/cmake/modules/AddMLIRPython.cmake
Removed:
################################################################################
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 9d4e06c7909c81..717a503468a85d 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -683,6 +683,13 @@ function(add_mlir_python_extension libname extname)
${eh_rtti_enable}
)
endif()
+
+ 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()
endif()
target_compile_options(${libname} PRIVATE ${eh_rtti_enable})
More information about the Mlir-commits
mailing list