[llvm-dev] D16945: LLVM overhaul to avoid linking LLVM component libraries with libLLVM

Hans Wennborg via llvm-dev
2016-02-08T17:45:05Z

Chris Bieneman is probably your best bet, and maybe also Dan Liew.

On Sat, Feb 6, 2016 at 10:55 AM, Jack Howarth
<howarth.mailing.lists at gmail.com> wrote:
> Hans,
>       I have posted a complete patch for solving the linkage issues
> with LLVM_LINK_LLVM_DYLIB on Phabricator at
> http://reviews.llvm.org/D16945.  The bulk of the fix the simple
> changes of...
>
> Index: cmake/modules/AddLLVM.cmake
> ==================================================================> ---
cmake/modules/AddLLVM.cmake (revision 259743)
> +++ cmake/modules/AddLLVM.cmake (working copy)
> @@ -475,13 +475,15 @@
>    # property has been set to an empty value.
>    get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
>
> -  if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_STATIC AND NOT
> ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
> -    set(llvm_libs LLVM)
> -  else()
> -    llvm_map_components_to_libnames(llvm_libs
> -      ${ARG_LINK_COMPONENTS}
> -      ${LLVM_LINK_COMPONENTS}
> -      )
> +  if (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS)
> +    if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
> +      set(llvm_libs LLVM)
> +    else()
> +      llvm_map_components_to_libnames(llvm_libs
> +        ${ARG_LINK_COMPONENTS}
> +        ${LLVM_LINK_COMPONENTS}
> +        )
> +    endif()
>    endif()
>
>    if(CMAKE_VERSION VERSION_LESS 2.8.12)
> Index: cmake/modules/LLVM-Config.cmake
> ==================================================================> ---
cmake/modules/LLVM-Config.cmake     (revision 259743)
> +++ cmake/modules/LLVM-Config.cmake     (working copy)
> @@ -40,10 +40,17 @@
>      # done in case libLLVM does not contain all of the components
>      # the target requires.
>      #
> -    # TODO strip LLVM_DYLIB_COMPONENTS out of link_components.
> +    # Strip LLVM_DYLIB_COMPONENTS out of link_components.
>      # To do this, we need special handling for "all", since that
>      # may imply linking to libraries that are not included in
>      # libLLVM.
> +    if (DEFINED link_components AND DEFINED LLVM_DYLIB_COMPONENTS)
> +      if("${LLVM_DYLIB_COMPONENTS}" STREQUAL "all")
> +        set(link_components "")
> +      else()
> +        list(REMOVE_ITEM link_components ${LLVM_DYLIB_COMPONENTS})
> +      endif()
> +    endif()
>      target_link_libraries(${executable} LLVM)
>    endif()
>
> However the avoiding the accidental linkage of libLLVMSupport with
> libLLVM and libgtest for the unittests was really tricky as two
> different mechanisms to pass LLVMSupport are in play.  The underlying
> problem was that the python based llvm-build tool was forcing a
> dependency on LLVMSupport for libgtest according to the
> required_libraries entry for the gtest library in
> utils/unittest/LLVMBuild.txt.  Since the llvm-build tool has no access
> to the cmake defines, I had to solve this problem by adding a new
> --enable-llvm-link-llvm-dylib option in
> utils/llvm-build/llvmbuild/main.py to allow the LLVM_LINK_LLVM_DYLIB
> build to prune 'Support' from the the required library dependencies
of
> the gtest library before the creation of
> tools/llvm-config/LibraryDependencies.inc. Now the
> LLVM_LINK_LLVM_DYLIB build contains...
>
> { "gtest", "libgtest.a", false, { } },
>
> rather than
>
> { "gtest", "libgtest.a", false, { "support" }
},
>
> in that file.  If there are specific maintainers for the llvm-build
> code, please add them to the review.
>           Thanks in advance.
>                Jack