[libcxx-commits] [libcxx] r357556 - [CMake] Differentiate between static and shared libc++abi
Petr Hosek via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 2 18:33:15 PDT 2019
Author: phosek
Date: Tue Apr 2 18:33:14 2019
New Revision: 357556
URL: http://llvm.org/viewvc/llvm-project?rev=357556&view=rev
Log:
[CMake] Differentiate between static and shared libc++abi
This addresses the issue introduced in r354212 which broke the case when
static libc++abi is merged into static libc++, but shared libc++ is
linked against shared libc++. There are 4 different possible
combinations which is difficult to capture using a single variable. This
change splits LIBCXX_CXX_ABI_LIBRARY into two:
LIBCXX_CXX_SHARED_ABI_LIBRARY and LIBCXX_CXX_STATIC_ABI_LIBRARY to
handle the shared and static cases. This in turn allows simplification
of some of the logic around merging of static archives.
Differential Revision: https://reviews.llvm.org/D60114
Modified:
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/lib/CMakeLists.txt
Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=357556&r1=357555&r2=357556&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Tue Apr 2 18:33:14 2019
@@ -8,7 +8,8 @@
#
# Parameters:
# abidefines: A list of defines needed to compile libc++ with the ABI library
-# abilib : The ABI library to link against.
+# abishared : The shared ABI library to link against.
+# abistatic : The static ABI library to link against.
# abifiles : A list of files (which may be relative paths) to copy into the
# libc++ build tree for the build. These files will be copied
# twice: once into include/, so the libc++ build itself can find
@@ -19,7 +20,7 @@
# in the libc++ build directory.
#
-macro(setup_abi_lib abidefines abilib abifiles abidirs)
+macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
CACHE PATH
@@ -29,7 +30,8 @@ macro(setup_abi_lib abidefines abilib ab
CACHE PATH
"Paths to C++ ABI library directory"
)
- set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
+ set(LIBCXX_CXX_SHARED_ABI_LIBRARY ${abishared})
+ set(LIBCXX_CXX_STATIC_ABI_LIBRARY ${abistatic})
set(LIBCXX_ABILIB_FILES ${abifiles})
foreach(fpath ${LIBCXX_ABILIB_FILES})
@@ -93,28 +95,30 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL
endif()
setup_abi_lib(
"-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
- "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
+ "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
)
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
if (LIBCXX_CXX_ABI_INTREE)
# Link against just-built "cxxabi" target.
- if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
- set(CXXABI_LIBNAME cxxabi_static)
- else()
- set(CXXABI_LIBNAME cxxabi_shared)
- endif()
+ set(CXXABI_SHARED_LIBNAME cxxabi_shared)
+ set(CXXABI_STATIC_LIBNAME cxxabi_static)
else()
# Assume c++abi is installed in the system, rely on -lc++abi link flag.
- set(CXXABI_LIBNAME "c++abi")
+ set(CXXABI_SHARED_LIBNAME "c++abi")
+ set(CXXABI_STATIC_LIBNAME "c++abi")
endif()
- set(HEADERS "cxxabi.h;__cxxabi_config.h")
if (LIBCXX_CXX_ABI_SYSTEM)
set(HEADERS "")
+ else()
+ set(HEADERS "cxxabi.h;__cxxabi_config.h")
endif()
- setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" ${CXXABI_LIBNAME} "${HEADERS}" "")
+ setup_abi_lib(
+ "-DLIBCXX_BUILDING_LIBCXXABI"
+ "${CXXABI_SHARED_LIBNAME}" "${CXXABI_STATIC_LIBNAME}" "${HEADERS}" "")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
- setup_abi_lib("-DLIBCXXRT"
- "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
+ setup_abi_lib(
+ "-DLIBCXXRT"
+ "cxxrt" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
)
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "vcruntime")
# Nothing TODO
Modified: libcxx/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=357556&r1=357555&r2=357556&view=diff
==============================================================================
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Apr 2 18:33:14 2019
@@ -59,16 +59,16 @@ endif()
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
if (APPLE)
- add_library_flags("-Wl,-force_load" "${LIBCXX_CXX_ABI_LIBRARY}")
+ add_library_flags("-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
else()
add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
- add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+ add_library_flags("${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
endif()
elseif (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
- add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+ add_library_flags("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
else ()
- add_interface_library("${LIBCXX_CXX_ABI_LIBRARY}")
+ add_interface_library("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
endif()
if (APPLE AND LLVM_USE_SANITIZER)
@@ -253,12 +253,11 @@ if (LIBCXX_ENABLE_STATIC)
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
endif()
- if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
- (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
- set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:cxxabi_static>")
+ if (TARGET "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" OR HAVE_LIBCXXABI)
+ set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_STATIC_ABI_LIBRARY}>")
else()
set(MERGE_ARCHIVES_ABI_TARGET
- "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
add_custom_command(TARGET cxx_static POST_BUILD
COMMAND
More information about the libcxx-commits
mailing list