[PATCH] D134637: clang-tblgen build: avoid duplicate inclusion of libLLVMSupport

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 23:16:53 PDT 2022


nhaehnle updated this revision to Diff 465283.
nhaehnle added a comment.

- define an alias so that clang-tblgen can always link against "clangSupport_tablegen"
- use add_llvm_library(... BUILDTREE_ONLY ...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134637/new/

https://reviews.llvm.org/D134637

Files:
  clang/lib/Support/CMakeLists.txt
  clang/utils/TableGen/CMakeLists.txt


Index: clang/utils/TableGen/CMakeLists.txt
===================================================================
--- clang/utils/TableGen/CMakeLists.txt
+++ clang/utils/TableGen/CMakeLists.txt
@@ -25,6 +25,6 @@
   TableGen.cpp
   )
 
-target_link_libraries(clang-tblgen PRIVATE clangSupport)
+target_link_libraries(clang-tblgen PRIVATE clangSupport_tablegen)
 
 set_target_properties(clang-tblgen PROPERTIES FOLDER "Clang tablegenning")
Index: clang/lib/Support/CMakeLists.txt
===================================================================
--- clang/lib/Support/CMakeLists.txt
+++ clang/lib/Support/CMakeLists.txt
@@ -9,8 +9,22 @@
   Support
   )
 
-add_clang_library(clangSupport
+set(clangSupport_sources
   RISCVVIntrinsicUtils.cpp
   )
 
+add_clang_library(clangSupport ${clangSupport_sources})
+
+if (LLVM_LINK_LLVM_DYLIB)
+  # Build a version of the support library that does not link against
+  # libLLVM-*.so, to be used by clang-tblgen. This is so clang-tblgen doesn't
+  # accidentally link against libLLVMSupport twice (once statically and once via
+  # libLLVM-*.so).
+  add_llvm_library(clangSupport_tablegen
+    BUILDTREE_ONLY STATIC DISABLE_LLVM_LINK_LLVM_DYLIB
+    ${clangSupport_sources})
+else()
+  add_library(clangSupport_tablegen ALIAS clangSupport)
+endif()
+
 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS_OLD})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134637.465283.patch
Type: text/x-patch
Size: 1340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/e7548732/attachment.bin>


More information about the llvm-commits mailing list