smeenai added a comment.

In D89177#2325566 <https://reviews.llvm.org/D89177#2325566>, @phosek wrote:

> We've already considered introducing a similar mechanism so thank you for 
> working on this! There's one issue that I haven't figured out how to resolve 
> and I'd be interested in your thoughts: building executables and libraries in 
> the most optimal may require incompatible flags. For example, when building a 
> shared library you have to use `-fPIC` but for executables that's suboptimal; 
> similarly, when building executables you may want to use LTO but if you also 
> want to create a distribution that contains static libraries, that's a 
> problem because those will contain bitcode. So far our solution has been to 
> simply do multiple builds with different flags (in GN this can be done in a 
> single build by leveraging the "toolchain" concept that also allows sharing 
> as much work as possible, but I haven't figured out how to do anything like 
> that in CMake).

Good question. We need something similar as well, where some clients of the 
libraries want them built with RTTI (because their programs rely on RTTI and 
you can get link errors when linking them against non-RTTI LLVM libraries), but 
we don't wanna build the executables with RTTI because of the size increases.

I don't know of any way to do this in CMake other than just configuring 
multiple times with the different flags, like you said. Maybe we could 
implement some logic for that in the build system, but I'm not sure if it's 
worth it. (I'm wondering if the Ninja multi-config generator added in CMake 
3.17 could be useful for this, although I haven't played around with that at 
all yet.) I do recognize it limits the usefulness of this approach quite a bit 
(since if you're doing separate configurations you can just do different 
`LLVM_DISTRIBUTION_COMPONENT` settings), but I'm hoping it can still be 
valuable for simpler scenarios.

Out of curiosity, with GN, how would you specify that you want binaries to be 
built with one toolchain (e.g. LTO and non-PIC) and libraries with another 
(e.g. non-LTO and PIC)?



================
Comment at: llvm/cmake/modules/LLVMDistributionSupport.cmake:39
+    # default (unnamed) distribution.
+    set_property(GLOBAL PROPERTY LLVM_DISTRIBUTION_FOR_${target} " ")
+  endforeach()
----------------
phosek wrote:
> Can we use `EMPTY` or something along those lines to make it more obvious?
Sure, I'll change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89177

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to