From bb6d95fc3a74eab118b622e4c779d0b9edc53f54 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Sat, 5 Sep 2015 08:27:33 +0000 Subject: [cmake] rework LLVM_LINK_LLVM_DYLIB option handling Summary: This diff attempts to address the concerns raised in http://reviews.llvm.org/D12488. We introduce a new USE_SHARED option to llvm_config, which, if set, causes the target to be linked against libLLVM. add_llvm_utility now uniformly disables linking against libLLVM. These utilities are not intended for distribution, and this keeps the option handling more centralised. llvm-shlib is now processes before any other "tools" subdirectories, ensuring the libLLVM target is defined before its dependents. One main difference from what was requested: llvm_config does not prune LLVM_DYLIB_COMPONENTS from the components passed into explicit_llvm_config. This is because the "all" component does something special, adding additional libraries (namely libLTO). Adding the component libraries after libLLVM should not be a problem, as symbols will be resolved in libLLVM first. Finally, I'm not really happy with the DISABLE_LLVM_LINK_LLVM option, but I'm not sure of a better way to get the following: - link all tools and shared libraries to libLLVM if LLVM_LINK_LLVM_DYLIB is set - some way of explicitly *not* doing so for utilities and libLLVM itself Suggestions for improvement here are particularly welcome. Reviewers: beanz Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12590 llvm-svn: 246918 --- llvm/tools/llvm-shlib/CMakeLists.txt | 51 +++--------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'llvm/tools/llvm-shlib') diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt index 7415722d3f6..d9bd15f7624 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -2,53 +2,6 @@ # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake # commandline. By default the shared library only exports the LLVM C API. -if(LLVM_LINK_LLVM_DYLIB) - if(DEFINED LLVM_DYLIB_COMPONENTS) - # To avoid inscrutable link errors, just disallow setting - # LLVM_DYLIB_COMPONENTS when we're intending to link tools - # and shared libraries with the dylib. - message(FATAL_ERROR "LLVM_DYLIB_COMPONENTS must not be set when LLVM_LINK_LLVM_DYLIB is ON") - endif() - if(NOT LLVM_DYLIB_EXPORT_ALL) - message(FATAL_ERROR "LLVM_DYLIB_EXPORT_ALL must be ON when LLVM_LINK_LLVM_DYLIB is ON") - endif() - set(LLVM_DYLIB_COMPONENTS all) -endif() - -# If LLVM_LINK_LLVM_DYLIB is not OFF, you can configure which libraries from -# LLVM you want to include in the shared library by setting -# LLVM_DYLIB_COMPONENTS to a semi-colon delimited list of LLVM components. -# All component names handled by llvm-config are valid. -if(NOT DEFINED LLVM_DYLIB_COMPONENTS) - set(LLVM_DYLIB_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - Analysis - BitReader - BitWriter - CodeGen - Core - DebugInfoDWARF - DebugInfoPDB - ExecutionEngine - IPO - IRReader - InstCombine - Instrumentation - Interpreter - Linker - MCDisassembler - MCJIT - ObjCARCOpts - Object - ScalarOpts - Support - Target - TransformUtils - Vectorize - native - ) -endif() - add_definitions( -DLLVM_VERSION_INFO=\"${PACKAGE_VERSION}\" ) set(SOURCES @@ -58,6 +11,10 @@ set(SOURCES llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS}) if(LLVM_LINK_LLVM_DYLIB) + if(NOT LLVM_DYLIB_EXPORT_ALL) + message(FATAL_ERROR "LLVM_DYLIB_EXPORT_ALL must be ON when LLVM_LINK_LLVM_DYLIB is ON") + endif() + # libLLVM.so should not have any dependencies on any other LLVM # shared libraries. When using the "all" pseudo-component, # LLVM_AVAILABLE_LIBS is added to the dependencies, which may -- cgit v1.2.3