[Mlir-commits] [mlir] 6fc1deb - [mlir][python] handle more undefined symbols not covered by nanobind (#153861)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Aug 16 06:25:18 PDT 2025


Author: Maksim Levental
Date: 2025-08-16T09:25:15-04:00
New Revision: 6fc1deb8b7497c36c946fa468f53d797ad54f24c

URL: https://github.com/llvm/llvm-project/commit/6fc1deb8b7497c36c946fa468f53d797ad54f24c
DIFF: https://github.com/llvm/llvm-project/commit/6fc1deb8b7497c36c946fa468f53d797ad54f24c.diff

LOG: [mlir][python] handle more undefined symbols not covered by nanobind (#153861)

Introduced (but omitted from this CMake) in
https://github.com/llvm/llvm-project/pull/151246.

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIRPython.cmake
    mlir/lib/Bindings/Python/IRCore.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index c14e614ed7d92..2b883558d33c6 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -704,7 +704,12 @@ function(add_mlir_python_extension libname extname)
       # 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`.
-      target_link_options(${libname} PUBLIC "LINKER:-U,_PyClassMethod_New")
+      # Same for the rest.
+      target_link_options(${libname} PUBLIC
+        "LINKER:-U,_PyClassMethod_New"
+        "LINKER:-U,_PyCode_Addr2Location"
+        "LINKER:-U,_PyFrame_GetLasti"
+      )
     endif()
   endif()
 

diff  --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 390cdc5429beb..4b3a06cbce854 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2810,7 +2810,7 @@ class PyOpAttributeMap {
 
 // bpo-42262 added Py_XNewRef()
 #if !defined(Py_XNewRef)
-PyObject *_Py_XNewRef(PyObject *obj) {
+[[maybe_unused]] PyObject *_Py_XNewRef(PyObject *obj) {
   Py_XINCREF(obj);
   return obj;
 }
@@ -2819,7 +2819,7 @@ PyObject *_Py_XNewRef(PyObject *obj) {
 
 // bpo-42262 added Py_NewRef()
 #if !defined(Py_NewRef)
-PyObject *_Py_NewRef(PyObject *obj) {
+[[maybe_unused]] PyObject *_Py_NewRef(PyObject *obj) {
   Py_INCREF(obj);
   return obj;
 }


        


More information about the Mlir-commits mailing list