forked from OSchip/llvm-project
Revert "[CMake] Support statically linking dependencies only to shared or static library"
This reverts commit r337668: broke the cxxabi build when using Make. llvm-svn: 337670
This commit is contained in:
parent
c50ef8560a
commit
781ee0bc5a
|
@ -155,14 +155,6 @@ endif()
|
||||||
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
|
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
|
||||||
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
||||||
|
|
||||||
cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY
|
|
||||||
"Statically link the ABI library to static library" ON
|
|
||||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
|
|
||||||
|
|
||||||
cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
|
|
||||||
"Statically link the ABI library to shared library" ON
|
|
||||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
|
|
||||||
|
|
||||||
# Generate and install a linker script inplace of libc++.so. The linker script
|
# Generate and install a linker script inplace of libc++.so. The linker script
|
||||||
# will link libc++ to the correct ABI library. This option is on by default
|
# will link libc++ to the correct ABI library. This option is on by default
|
||||||
# on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
|
# on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
|
||||||
|
|
|
@ -96,10 +96,10 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
|
||||||
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
|
||||||
if (LIBCXX_CXX_ABI_INTREE)
|
if (LIBCXX_CXX_ABI_INTREE)
|
||||||
# Link against just-built "cxxabi" target.
|
# Link against just-built "cxxabi" target.
|
||||||
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
||||||
set(CXXABI_LIBNAME cxxabi_static)
|
set(CXXABI_LIBNAME cxxabi_static)
|
||||||
else()
|
else()
|
||||||
set(CXXABI_LIBNAME cxxabi_shared)
|
set(CXXABI_LIBNAME cxxabi_shared)
|
||||||
endif()
|
endif()
|
||||||
set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
|
set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
|
||||||
set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
|
set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
||||||
add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
|
add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
|
||||||
add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
|
add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
|
||||||
add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
|
add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
|
||||||
|
@ -259,14 +259,14 @@ if (LIBCXX_ENABLE_STATIC)
|
||||||
|
|
||||||
list(APPEND LIBCXX_TARGETS "cxx_static")
|
list(APPEND LIBCXX_TARGETS "cxx_static")
|
||||||
# Attempt to merge the libc++.a archive and the ABI library archive into one.
|
# Attempt to merge the libc++.a archive and the ABI library archive into one.
|
||||||
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
||||||
set(MERGE_ARCHIVES_SEARCH_PATHS "")
|
set(MERGE_ARCHIVES_SEARCH_PATHS "")
|
||||||
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
|
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
|
||||||
set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
|
set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
|
||||||
endif()
|
endif()
|
||||||
if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
|
if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
|
||||||
(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
|
(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
|
||||||
set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:cxxabi_static>")
|
set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_ABI_LIBRARY}>")
|
||||||
else()
|
else()
|
||||||
set(MERGE_ARCHIVES_ABI_TARGET
|
set(MERGE_ARCHIVES_ABI_TARGET
|
||||||
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||||
|
|
|
@ -84,13 +84,6 @@ set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
|
||||||
option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
|
option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
|
||||||
option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
|
option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
|
||||||
|
|
||||||
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
|
|
||||||
"Statically link the LLVM unwinder to static library" ON
|
|
||||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)
|
|
||||||
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
|
|
||||||
"Statically link the LLVM unwinder to shared library" ON
|
|
||||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF)
|
|
||||||
|
|
||||||
option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
|
option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
|
||||||
# The default terminate handler attempts to demangle uncaught exceptions, which
|
# The default terminate handler attempts to demangle uncaught exceptions, which
|
||||||
# causes extra I/O and demangling code to be pulled in.
|
# causes extra I/O and demangling code to be pulled in.
|
||||||
|
|
|
@ -61,27 +61,19 @@ if (LIBCXXABI_USE_LLVM_UNWINDER)
|
||||||
# Prefer using the in-tree version of libunwind, either shared or static. If
|
# Prefer using the in-tree version of libunwind, either shared or static. If
|
||||||
# none are found fall back to using -lunwind.
|
# none are found fall back to using -lunwind.
|
||||||
# FIXME: Is it correct to prefer the static version of libunwind?
|
# FIXME: Is it correct to prefer the static version of libunwind?
|
||||||
if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
|
if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
|
||||||
list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared)
|
list(APPEND LIBCXXABI_LIBRARIES unwind_shared)
|
||||||
elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
|
elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
|
||||||
list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static)
|
list(APPEND LIBCXXABI_LIBRARIES unwind_static)
|
||||||
else()
|
else()
|
||||||
list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind)
|
list(APPEND LIBCXXABI_LIBRARIES unwind)
|
||||||
endif()
|
|
||||||
if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
|
|
||||||
list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared)
|
|
||||||
elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
|
|
||||||
# We handle this by directly merging libunwind objects into libc++abi.
|
|
||||||
else()
|
|
||||||
list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind)
|
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s)
|
add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s)
|
||||||
endif()
|
endif()
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# MINGW_LIBRARIES is defined in config-ix.cmake
|
# MINGW_LIBRARIES is defined in config-ix.cmake
|
||||||
list(APPEND LIBCXXABI_SHARED_LIBRARIES ${MINGW_LIBRARIES})
|
list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES})
|
||||||
list(APPEND LIBCXXABI_STATIC_LIBRARIES ${MINGW_LIBRARIES})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Setup flags.
|
# Setup flags.
|
||||||
|
@ -138,7 +130,7 @@ if (LIBCXXABI_ENABLE_SHARED)
|
||||||
if(COMMAND llvm_setup_rpath)
|
if(COMMAND llvm_setup_rpath)
|
||||||
llvm_setup_rpath(cxxabi_shared)
|
llvm_setup_rpath(cxxabi_shared)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(cxxabi_shared ${LIBCXXABI_SHARED_LIBRARIES})
|
target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES})
|
||||||
set_target_properties(cxxabi_shared
|
set_target_properties(cxxabi_shared
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_EXTENSIONS
|
CXX_EXTENSIONS
|
||||||
|
@ -163,13 +155,13 @@ endif()
|
||||||
# Build the static library.
|
# Build the static library.
|
||||||
if (LIBCXXABI_ENABLE_STATIC)
|
if (LIBCXXABI_ENABLE_STATIC)
|
||||||
set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
|
set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
|
||||||
if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY)
|
if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
|
||||||
if (TARGET unwind_static OR HAVE_LIBUNWIND)
|
if (TARGET unwind_static OR HAVE_LIBUNWIND)
|
||||||
list(APPEND cxxabi_static_sources $<TARGET_OBJECTS:unwind_objects>)
|
list(APPEND cxxabi_static_sources $<TARGET_OBJECTS:unwind_objects>)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
add_library(cxxabi_static STATIC ${cxxabi_static_sources})
|
add_library(cxxabi_static STATIC ${cxxabi_static_sources})
|
||||||
target_link_libraries(cxxabi_static ${LIBCXXABI_STATIC_LIBRARIES})
|
target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES})
|
||||||
set_target_properties(cxxabi_static
|
set_target_properties(cxxabi_static
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_EXTENSIONS
|
CXX_EXTENSIONS
|
||||||
|
|
Loading…
Reference in New Issue