[Mlir-commits] [mlir] 0368c1d - [MLIR][cmake][NFC] Check for incorrect usage of LLVM components in LINK_LIBS

Stephen Neuendorffer llvmlistbot at llvm.org
Tue May 19 14:51:36 PDT 2020


Author: Stephen Neuendorffer
Date: 2020-05-19T14:50:54-07:00
New Revision: 0368c1de9cdaa944c9d3d8416b2e0079d72a6c9a

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

LOG: [MLIR][cmake][NFC] Check for incorrect usage of LLVM components in LINK_LIBS

Using LLVM components in LINK_LIBS means that the mechanisms for
replacing component dependencies with libLLVM.so break.  Try to catch
this incorrect usage up front, instead of waiting until later when we
get difficult to understand runtime errors from incorrectly linked
libraries.

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

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIR.cmake

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index c6ef46823254..427d8c059ea0 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -108,6 +108,18 @@ function(add_mlir_library name)
 
   # MLIR libraries uniformly depend on LLVMSupport.  Just specify it once here.
   list(APPEND ARG_LINK_COMPONENTS Support)
+
+  # LINK_COMPONENTS is necessary to allow libLLVM.so to be properly
+  # substituted for individual library dependencies if LLVM_LINK_LLVM_DYLIB
+  # Perhaps this should be in llvm_add_library instead?  However, it fails
+  # on libclang-cpp.so
+  get_property(llvm_component_libs GLOBAL PROPERTY LLVM_COMPONENT_LIBS)
+  foreach(lib ${ARG_LINK_LIBS})
+    if(${lib} IN_LIST llvm_component_libs)
+      message(SEND_ERROR "${name} specifies LINK_LIBS ${lib}, but LINK_LIBS cannot be used for LLVM libraries.  Please use LINK_COMPONENTS instead.")
+    endif()
+  endforeach()
+
   list(APPEND ARG_DEPENDS mlir-generic-headers)
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs} DEPENDS ${ARG_DEPENDS} LINK_COMPONENTS ${ARG_LINK_COMPONENTS} LINK_LIBS ${ARG_LINK_LIBS})
 


        


More information about the Mlir-commits mailing list