[PATCH] D80103: [cmake][NFC] Check for incorrect usage of LLVM components in LINK_LIBS

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 17 23:24:54 PDT 2020


stephenneuendorffer created this revision.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
stephenneuendorffer added reviewers: mehdi_amini, tstellar.

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.

Depends on D80102 <https://reviews.llvm.org/D80102>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80103

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -495,6 +495,15 @@
     endif()
   endif()
 
+  # LINK_COMPONENTS is necessary to allow libLLVM.so to be properly
+  # substituted for individual library dependencies if LLVM_LINK_LLVM_DYLIB
+  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()
+
   if(ARG_SHARED AND ARG_STATIC)
     # static
     set(name_static "${name}_static")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80103.264541.patch
Type: text/x-patch
Size: 793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/3b6b70d8/attachment.bin>


More information about the llvm-commits mailing list