[Mlir-commits] [mlir] [mlir][python] declare `_PyClassMethod_New` undefined at link time (PR #121597)
Maksim Levental
llvmlistbot at llvm.org
Fri Jan 3 13:29:03 PST 2025
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/121597
>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 1/3] 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(
>From 97216a6db58364cf78407adc8e11c71a4a93868c Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Fri, 3 Jan 2025 12:05:23 -0800
Subject: [PATCH 2/3] Update mlir/cmake/modules/AddMLIRPython.cmake
---
mlir/cmake/modules/AddMLIRPython.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 2bcabab6f9c5e3..58643f1aa3177f 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -688,7 +688,7 @@ function(add_mlir_python_extension libname extname)
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
+ # 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()
>From b84454cc5f02fd0fd24fdef72c35965ca6dc873d Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Fri, 3 Jan 2025 13:28:55 -0800
Subject: [PATCH 3/3] Update AddMLIRPython.cmake
---
mlir/cmake/modules/AddMLIRPython.cmake | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 58643f1aa3177f..20254d903fdc08 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -683,15 +683,16 @@ 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})
- 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