Always link the MLIR python bindings native extension to libMLIR.so
authorMehdi Amini <joker.eph@gmail.com>
Thu, 5 Nov 2020 02:29:40 +0000 (02:29 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Thu, 5 Nov 2020 19:57:11 +0000 (19:57 +0000)
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

mlir/lib/Bindings/Python/CMakeLists.txt

index d4913bb..296b915 100644 (file)
@@ -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