[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library
Petr Hosek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 18 18:46:20 PDT 2018
phosek updated this revision to Diff 156201.
phosek marked 2 inline comments as done.
Repository:
rCXX libc++
https://reviews.llvm.org/D49502
Files:
libcxx/CMakeLists.txt
libcxx/cmake/Modules/HandleLibCXXABI.cmake
libcxx/lib/CMakeLists.txt
libcxxabi/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -155,7 +155,7 @@
# Build the static library.
if (LIBCXXABI_ENABLE_STATIC)
set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
- if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
+ if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY)
if (TARGET unwind_static OR HAVE_LIBUNWIND)
list(APPEND cxxabi_static_sources $<TARGET_OBJECTS:unwind_objects>)
endif()
Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -84,6 +84,13 @@
option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared 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)
# The default terminate handler attempts to demangle uncaught exceptions, which
# causes extra I/O and demangling code to be pulled in.
Index: libcxx/lib/CMakeLists.txt
===================================================================
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -44,7 +44,7 @@
set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
endif()
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
@@ -259,14 +259,14 @@
list(APPEND LIBCXX_TARGETS "cxx_static")
# Attempt to merge the libc++.a archive and the ABI library archive into one.
- if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
set(MERGE_ARCHIVES_SEARCH_PATHS "")
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:${LIBCXX_CXX_ABI_LIBRARY}>")
+ if (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?"
+ AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
+ set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:cxxabi_static>")
else()
set(MERGE_ARCHIVES_ABI_TARGET
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
Index: libcxx/cmake/Modules/HandleLibCXXABI.cmake
===================================================================
--- libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -104,10 +104,10 @@
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)
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+ set(CXXABI_LIBNAME cxxabi_static)
else()
- set(CXXABI_LIBNAME cxxabi_shared)
+ set(CXXABI_LIBNAME cxxabi_shared)
endif()
set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
else()
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -155,6 +155,14 @@
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
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
# 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'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49502.156201.patch
Type: text/x-patch
Size: 4710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180719/fa494cb7/attachment.bin>
More information about the cfe-commits
mailing list