summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-03-03 15:59:51 +0000
committerEric Fiselier <eric@efcs.ca>2015-03-03 15:59:51 +0000
commit0357171f1c2916d353ca328aa006b1e4a22d3efa (patch)
treeed7dbe944f18e2ac5cf57a51cc135fcbe8f91646
parent14dbeaadc124c7fc7c94fff8a70dece1a15c4199 (diff)
downloadbcm5719-llvm-0357171f1c2916d353ca328aa006b1e4a22d3efa.tar.gz
bcm5719-llvm-0357171f1c2916d353ca328aa006b1e4a22d3efa.zip
[libcxx] Add support for linking libc++ against a static ABI library.
Summary: This patch add the CMake option `LIBCXX_ENABLE_STATIC_ABI_LIBRARY` which, when enabled, will link libc++ against the static version of the ABI library. Reviewers: mclow.lists, jroelofs, danalbert Reviewed By: danalbert Subscribers: compnerd, cfe-commits Differential Revision: http://reviews.llvm.org/D8017 llvm-svn: 231076
-rw-r--r--libcxx/CMakeLists.txt9
-rw-r--r--libcxx/cmake/Modules/HandleLibCXXABI.cmake6
-rw-r--r--libcxx/lib/CMakeLists.txt21
-rw-r--r--libcxx/test/CMakeLists.txt5
4 files changed, 35 insertions, 6 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 0d2706644f3..230a3c6ae7d 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -61,6 +61,7 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON)
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
+option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
if (LIBCXX_BUILT_STANDALONE)
@@ -68,6 +69,14 @@ if (LIBCXX_BUILT_STANDALONE)
"Define the sanitizer used to build the library and tests")
endif()
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ if (APPLE)
+ message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
+ else()
+ message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
+ endif()
+endif()
+
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
if (NOT LIBCXX_CXX_ABI)
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
index 131941a078c..960df9ec80e 100644
--- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -78,7 +78,11 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
if (LIBCXX_CXX_ABI_INTREE)
# Link against just-built "cxxabi" target.
- set(CXXABI_LIBNAME cxxabi)
+ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ set(CXXABI_LIBNAME cxxabi_static)
+ else()
+ set(CXXABI_LIBNAME cxxabi_shared)
+ endif()
set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
else()
# Assume c++abi is installed in the system, rely on -lc++abi link flag.
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index fb09c63fa4d..d50b2cc0fd7 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -34,22 +34,33 @@ else()
)
endif()
+#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
+if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
+ target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
+endif()
+
if (DEFINED LIBCXX_CXX_ABI_DEPS)
add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
endif()
+set(libraries "")
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ # TODO(ericwf): Remove these GNU specific linker flags and let CMake do the
+ # configuration. This will be more portable.
+ list(APPEND libraries "-Wl,--whole-archive" "-Wl,-Bstatic")
+ list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
+ list(APPEND libraries "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+else()
+ list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
+endif()
+
# Generate library list.
-set(libraries ${LIBCXX_CXX_ABI_LIBRARY})
append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
append_if(libraries LIBCXX_HAS_C_LIB c)
append_if(libraries LIBCXX_HAS_M_LIB m)
append_if(libraries LIBCXX_HAS_RT_LIB rt)
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
-#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
-if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
- target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
-endif()
target_link_libraries(cxx ${libraries})
# Setup flags.
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 8f928b4a8f1..6af4c98fe4c 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -44,6 +44,11 @@ if (LIT_EXECUTABLE)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_THREADS)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
+ # The tests shouldn't link to any ABI library when it has been linked into
+ # libc++ statically.
+ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ set(LIBCXX_CXX_ABI_LIBNAME "none")
+ endif()
set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
"TargetInfo to use when setting up test environment.")
set(LIBCXX_EXECUTOR "None" CACHE STRING
OpenPOWER on IntegriCloud