[Mlir-commits] [mlir] [MLIR] Fix nanobind linker args on macOS (PR #125733)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 4 10:09:39 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Nikhil Kalra (nikalra)

<details>
<summary>Changes</summary>

Set the "-U,_PyClassMethod_New" linker flag on the Python library itself isntead of on the CMAKE_MODULE_LINKER_FLAGS property.

---
Full diff: https://github.com/llvm/llvm-project/pull/125733.diff


1 Files Affected:

- (modified) mlir/cmake/modules/AddMLIRPython.cmake (+1-1) 


``````````diff
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index a23de004eb014ff..a21688213339b05 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -709,7 +709,7 @@ 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`.
-      set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-U -Wl,_PyClassMethod_New")
+      target_link_options(${libname} PRIVATE "LINKER:-U,_PyClassMethod_New")
     endif()
   endif()
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/125733


More information about the Mlir-commits mailing list