[Lldb-commits] [lldb] r319840 - [CMake] Use PRIVATE in target_link_libraries for executables

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 5 14:20:17 PST 2017


Oh come now, we have cross-compilation ;-)

That said, I'd like to try this out locally before you submit, but it might
be tomorrow.

On Tue, Dec 5, 2017 at 2:19 PM Shoaib Meenai <smeenai at fb.com> wrote:

> I didn't, because I didn't have easy access to a Windows LLVM setup (I
> need to get that working again). I don't see a reason for many
> platform-specific differences here, but I am monitoring the bots closely to
> make sure nothing breaks.
>
>
>
> *From: *Zachary Turner <zturner at google.com>
> *Date: *Tuesday, December 5, 2017 at 2:07 PM
> *To: *Shoaib Meenai <smeenai at fb.com>
> *Cc: *"lldb-commits at lists.llvm.org" <lldb-commits at lists.llvm.org>
> *Subject: *Re: [Lldb-commits] [lldb] r319840 - [CMake] Use PRIVATE in
> target_link_libraries for executables
>
>
>
> Can you / did you try this on Windows?  I don't see any reason why it
> wouldn't work, but I remember having difficulty with all this CMake some
> time ago.
>
>
>
> On Tue, Dec 5, 2017 at 1:50 PM Shoaib Meenai via lldb-commits <
> lldb-commits at lists.llvm.org> wrote:
>
> Author: smeenai
> Date: Tue Dec  5 13:49:56 2017
> New Revision: 319840
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319840&view=rev
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D319840-26view-3Drev&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=jgpur1XN4mrubAWTFVwv6eiWiVm-VcjEBApZCdrjLNs&e=>
> Log:
> [CMake] Use PRIVATE in target_link_libraries for executables
>
> We currently use target_link_libraries without an explicit scope
> specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
> Dependencies added in this way apply to both the target and its
> dependencies, i.e. they become part of the executable's link interface
> and are transitive.
>
> Transitive dependencies generally don't make sense for executables,
> since you wouldn't normally be linking against an executable. This also
> causes issues for generating install export files when using
> LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
> library dependencies, which are currently added as interface
> dependencies. If clang is in the distribution components but the LLVM
> libraries it depends on aren't (which is a perfectly legitimate use case
> if the LLVM libraries are being built static and there are therefore no
> run-time dependencies on them), CMake will complain about the LLVM
> libraries not being in export set when attempting to generate the
> install export file for clang. This is reasonable behavior on CMake's
> part, and the right thing is for LLVM's build system to explicitly use
> PRIVATE dependencies for executables.
>
> Unfortunately, CMake doesn't allow you to mix and match the keyword and
> non-keyword target_link_libraries signatures for a single target; i.e.,
> if a single call to target_link_libraries for a particular target uses
> one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
> also be updated to use those keywords. This means we must do this change
> in a single shot. I also fully expect to have missed some instances; I
> tested by enabling all the projects in the monorepo (except dragonegg),
> and configuring both with and without shared libraries, on both Darwin
> and Linux, but I'm planning to rely on the buildbots for other
> configurations (since it should be pretty easy to fix those).
>
> Even after this change, we still have a lot of target_link_libraries
> calls that don't specify a scope keyword, mostly for shared libraries.
> I'm thinking about addressing those in a follow-up, but that's a
> separate change IMO.
>
> Differential Revision: https://reviews.llvm.org/D40823
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D40823&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=F1t4w68fsg6CjlgcP1s0P93A8ScHtutPHn3pgJt9jJo&e=>
>
>
> Modified:
>     lldb/trunk/cmake/modules/AddLLDB.cmake
>     lldb/trunk/unittests/CMakeLists.txt
>     lldb/trunk/unittests/Interpreter/CMakeLists.txt
>
> Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=319840&r1=319839&r2=319840&view=diff
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_cmake_modules_AddLLDB.cmake-3Frev-3D319840-26r1-3D319839-26r2-3D319840-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=VabZwbj9vO8KCXgjqdmhFSGEMTkOFstdqG6pzEV5WpM&e=>
>
> ==============================================================================
> --- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
> +++ lldb/trunk/cmake/modules/AddLLDB.cmake Tue Dec  5 13:49:56 2017
> @@ -92,7 +92,7 @@ function(add_lldb_executable name)
>    list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
>    add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
>
> -  target_link_libraries(${name} ${ARG_LINK_LIBS})
> +  target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
>    set_target_properties(${name} PROPERTIES
>      FOLDER "lldb executables")
>
>
> Modified: lldb/trunk/unittests/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/CMakeLists.txt?rev=319840&r1=319839&r2=319840&view=diff
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_unittests_CMakeLists.txt-3Frev-3D319840-26r1-3D319839-26r2-3D319840-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=QVL5tF9VvVyPWpxaRvlsnKRNuc_JmyIraylLQViPPTs&e=>
>
> ==============================================================================
> --- lldb/trunk/unittests/CMakeLists.txt (original)
> +++ lldb/trunk/unittests/CMakeLists.txt Tue Dec  5 13:49:56 2017
> @@ -44,7 +44,7 @@ function(add_lldb_unittest test_name)
>      POST_BUILD
>      COMMAND "${CMAKE_COMMAND}" -E make_directory
> ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
>
> -  target_link_libraries(${test_name} ${ARG_LINK_LIBS})
> +  target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
>  endfunction()
>
>  function(add_unittest_inputs test_name inputs)
>
> Modified: lldb/trunk/unittests/Interpreter/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/CMakeLists.txt?rev=319840&r1=319839&r2=319840&view=diff
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_unittests_Interpreter_CMakeLists.txt-3Frev-3D319840-26r1-3D319839-26r2-3D319840-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=mKTxMMXxgDo1bn5EEsAyKTP_piQ03SMItebwHr0t4Kk&e=>
>
> ==============================================================================
> --- lldb/trunk/unittests/Interpreter/CMakeLists.txt (original)
> +++ lldb/trunk/unittests/Interpreter/CMakeLists.txt Tue Dec  5 13:49:56
> 2017
> @@ -8,5 +8,6 @@ add_lldb_unittest(InterpreterTests
>    )
>
>  target_link_libraries(InterpreterTests
> +  PRIVATE
>    ${PYTHON_LIBRARY}
>    )
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_lldb-2Dcommits&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=CnV7n6Ko5mCcbjGWZ4ObFe8oScFwBWBh6b5DQozSnxE&s=gDB7hBPs481QNdvPe15aBj56UoMVTKLPURlbXP2pjgQ&e=>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171205/bfa59c04/attachment.html>


More information about the lldb-commits mailing list