[Mlir-commits] [mlir] a1229c9 - Always link the MLIR python bindings native extension to libMLIR.so

Mehdi Amini llvmlistbot at llvm.org
Thu Nov 5 11:57:41 PST 2020


Author: Mehdi Amini
Date: 2020-11-05T19:57:11Z
New Revision: a1229c9518672cedfe407654145bf7e2614769f7

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

LOG: Always link the MLIR python bindings native extension to libMLIR.so

The Python bindings now require -DLLVM_BUILD_LLVM_DYLIB=ON to build.
This change is needed to be able to build multiple Python native
extension without having each of them embedding a copy of MLIR, which
would make them incompatible with each other. Instead they should all
link to the same copy of MLIR.

Differential Revision: https://reviews.llvm.org/D90813

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/CMakeLists.txt b/mlir/lib/Bindings/Python/CMakeLists.txt
index d4913bb43947..296b915c58cf 100644
--- a/mlir/lib/Bindings/Python/CMakeLists.txt
+++ b/mlir/lib/Bindings/Python/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT LLVM_BUILD_LLVM_DYLIB)
+  message(FATAL_ERROR "Building the MLIR Python bindings require -DLLVM_BUILD_LLVM_DYLIB=ON")
+endif()
+
 ################################################################################
 # Copy python source tree.
 ################################################################################
@@ -102,21 +106,10 @@ set_target_properties(
   MLIRBindingsPythonExtension PROPERTIES CXX_VISIBILITY_PRESET "hidden")
 
 set(PYEXT_DEPS)
-if(LLVM_BUILD_LLVM_DYLIB)
-  list(APPEND PYEXT_DEPS
-    # Depend on libMLIR.so first so that deps primarily come from the shared
-    # library.
-    MLIR
-  )
-endif()
-
-# Full static dependencies are also added and will augment what is in the
-# shared lib if needed (or in fully static builds, will result in mondo-built
-# extension).
 list(APPEND PYEXT_DEPS
-  # Depend only on the MLIR C-API.
-  MLIRCAPIIR
-  MLIRCAPIRegistration
+  # Depend on libMLIR.so first so that deps primarily come from the shared
+  # library.
+  MLIR
 )
 
 target_link_libraries(MLIRBindingsPythonExtension


        


More information about the Mlir-commits mailing list