Skip to content

Commit b84454c

Browse files
authored
Update AddMLIRPython.cmake
1 parent 97216a6 commit b84454c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mlir/cmake/modules/AddMLIRPython.cmake

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,16 @@ 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})
689-
if(APPLE)
690-
# NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind
691-
# doesn't declare this API as undefined in its linker flags. So we need to declare it as such
692-
# for downstream users that do not do something like -undefined dynamic_lookup
693-
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-U -Wl,_PyClassMethod_New")
694-
endif()
695696

696697
# Configure the output to match python expectations.
697698
set_target_properties(

0 commit comments

Comments
 (0)