Skip to content

Commit 78f0447

Browse files
authored
[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`
1 parent d7acf03 commit 78f0447

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mlir/cmake/modules/AddMLIRPython.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,13 @@ function(add_mlir_python_extension libname extname)
683683
${eh_rtti_enable}
684684
)
685685
endif()
686+
687+
if(APPLE)
688+
# NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind
689+
# doesn't declare this API as undefined in its linker flags. So we need to declare it as such
690+
# for downstream users that do not do something like `-undefined dynamic_lookup`.
691+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-U -Wl,_PyClassMethod_New")
692+
endif()
686693
endif()
687694

688695
target_compile_options(${libname} PRIVATE ${eh_rtti_enable})

0 commit comments

Comments
 (0)