<div dir="ltr"><div>I can reproduce the not-linking-with-dylib bit, but it doesn't fail during linking for me. That's why I missed this in testing. Sorry!</div><div><br></div><div>Is this serious enough to revert to unbreak you?</div><div><br></div><div>Alternatively there's two quick fixes for this:</div><div>- Make LLVM_LINK_LLVM_DYLIB an option() in LLVMConfig.cmake. Then it'll show up in the GUI and respects configurations.</div><div>- Wrap the set() in an if(). </div><div><br></div><div>I'd prefer going the option() route. Adding a CLANG_LINK_LLVM_DYLIB additionally is worth considering, I'd prefer doing that as a seperate change though.</div><div><br></div><div>Cheers,</div><div>Philip</div><div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 24, 2018 at 1:30 AM Justin Bogner <<a href="mailto:mail@justinbogner.com">mail@justinbogner.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Philip Pfaffe via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
> Author: pfaffe<br>
> Date: Wed Jul 18 01:53:31 2018<br>
> New Revision: 337366<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=337366&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=337366&view=rev</a><br>
> Log:<br>
> [CMake] Export the LLVM_LINK_LLVM_DYLIB setting<br>
><br>
> Summary:<br>
> When building out-of-tree tools, there are several macros available to<br>
> automate linking against llvm. An examples is `add_llvm_executable`, or<br>
> the clang variant of this.<br>
><br>
> These macros use the LLVM_LINK_LLVM_DYLIB option to decide whether to<br>
> link against libraries defined by setting LLVM_LINK_COMPONENTS or to<br>
> link against libLLVM instead. Currently this is problematic in<br>
> out-of-tree targets, because they cannot identify whether this option is<br>
> required or even available. If the option was enabled in LLVM's own<br>
> build, the clang libraries are built against libLLVM, so a client<br>
> linking against those must link against it too. On the other hand the<br>
> client can't just always link against it, because it might not be<br>
> available.<br>
<br>
I'm not sure I understand the problem this is solving, but it breaks the<br>
case where an out-of-tree target tries to link the dylib when the<br>
in-tree build does not. Specifically, if I build llvm with<br>
LLVM_LINK_LLVM_DYLIB=Off (but LLVM_BUILD_LLVM_DYLIB=On), and then I try<br>
to build clang against this with LLVM_LINK_LLVM_DYLIB=On, clang's<br>
setting of the variable seems to be ignored and I get link errors as it<br>
looks for static libraries.<br>
<br>
Can this be made to respect externally setting the variable? Maybe it<br>
should only show up if set, for example? Alternatively, do external<br>
projects need to implement their own version of the variable, like a<br>
CLANG_LINK_LLVM_DYLIB?<br>
<br>
> This is related to D44391, but that change assumed the client knew<br>
> whether they wanted the dylib or not.<br>
><br>
> Reviewers: mgorny, beanz, labath<br>
><br>
> Reviewed By: mgorny<br>
><br>
> Subscribers: bollu, llvm-commits<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D49193" rel="noreferrer" target="_blank">https://reviews.llvm.org/D49193</a><br>
><br>
> Modified:<br>
>     llvm/trunk/cmake/modules/<a href="http://LLVMConfig.cmake.in" rel="noreferrer" target="_blank">LLVMConfig.cmake.in</a><br>
><br>
> Modified: llvm/trunk/cmake/modules/<a href="http://LLVMConfig.cmake.in" rel="noreferrer" target="_blank">LLVMConfig.cmake.in</a><br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake.in?rev=337366&r1=337365&r2=337366&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake.in?rev=337366&r1=337365&r2=337366&view=diff</a><br>
> ==============================================================================<br>
><br>
> --- llvm/trunk/cmake/modules/<a href="http://LLVMConfig.cmake.in" rel="noreferrer" target="_blank">LLVMConfig.cmake.in</a> (original)<br>
> +++ llvm/trunk/cmake/modules/<a href="http://LLVMConfig.cmake.in" rel="noreferrer" target="_blank">LLVMConfig.cmake.in</a> Wed Jul 18 01:53:31 2018<br>
> @@ -13,6 +13,8 @@ set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEP<br>
><br>
>  set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)<br>
><br>
> +set(LLVM_LINK_LLVM_DYLIB @LLVM_LINK_LLVM_DYLIB@)<br>
> +<br>
>  set(LLVM_DYLIB_COMPONENTS @LLVM_DYLIB_COMPONENTS@)<br>
><br>
>  set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@)<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>