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

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


nhaehnle added a comment.

Thank you all for the reviews. I've integrated the suggestions except for:

> A possible alternative solution would be to build clangSupport_sources as an object library, and then link that library into clangSupport and clang-tblgen which could be done unconditionally; the advantage is that you don't need to compile clangSupport_sources twice.

I'm not sure how this would work. It doesn't seem to be something with precedent in the LLVM tree, and seems to require using raw CMake `add_library`, though it's quite likely that I missed something?



================
Comment at: clang/lib/Support/CMakeLists.txt:23
+  # libLLVM-*.so).
+  llvm_add_library(clangSupport_tablegen
+    STATIC
----------------
beanz wrote:
> Unless there is a reason not to you should probably use `add_llvm_library` here probably with the `BUILDTREE_ONLY` option.
That seems to work, thank you.


================
Comment at: clang/lib/Support/CMakeLists.txt:27
+    ${clangSupport_sources})
+endif()
+
----------------
beanz wrote:
> We could add an `else` here that creates the clangSupport_tablegen target as an alias of clangSupport
> ```
> add_library(clangSupport_tablegen ALIAS clangSupport)
> ```
> 
> See: https://cmake.org/cmake/help/v3.13/command/add_library.html#alias-libraries
> 
> This would allow clang-tablegen to always depend on clangSupport_tablegen simplifying the code on that end.
Good idea, done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134637



More information about the cfe-commits mailing list