diff options
| author | Eric Fiselier <eric@efcs.ca> | 2017-01-02 21:58:06 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2017-01-02 21:58:06 +0000 |
| commit | 5d25843f66fbe0bed55bb2ae196e2748d94496c8 (patch) | |
| tree | cefeeaac240751e48baad2a274202f2237542ec4 | |
| parent | e772e066860a6fac1df66dd1bb05629c00a26206 (diff) | |
| download | bcm5719-llvm-5d25843f66fbe0bed55bb2ae196e2748d94496c8.tar.gz bcm5719-llvm-5d25843f66fbe0bed55bb2ae196e2748d94496c8.zip | |
Fix configuring and building libc++ w/o an ABI library.
Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits
of the C++ STL. However we also support building w/o an ABI library entirely.
This patch fixes building libc++ w/o an ABI library (and incorporates the
`~type_info()` fix in D28211).
The main changes in this patch are:
1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default".
2) Fix CMake bits which treated "none" as "default" on OS X.
3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`.
4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined.
Unfortunately this patch doesn't help clean up the macro mess that we use to
configure for different ABI libraries.
llvm-svn: 290839
| -rw-r--r-- | libcxx/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | libcxx/cmake/Modules/HandleLibCXXABI.cmake | 6 | ||||
| -rw-r--r-- | libcxx/lib/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | libcxx/lib/abi/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | libcxx/src/exception.cpp | 6 | ||||
| -rw-r--r-- | libcxx/src/new.cpp | 6 | ||||
| -rw-r--r-- | libcxx/src/stdexcept.cpp | 3 | ||||
| -rw-r--r-- | libcxx/src/typeinfo.cpp | 12 |
8 files changed, 32 insertions, 16 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index f254291b6ec..9c69d4901e4 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -87,13 +87,13 @@ if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC) endif() # ABI Library options --------------------------------------------------------- -set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING - "Specify C++ ABI library to use." FORCE) -set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) +set(LIBCXX_CXX_ABI "default" CACHE STRING + "Specify C++ ABI library to use.") +set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++) set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) # Setup the default options if LIBCXX_CXX_ABI is not specified. -if (NOT LIBCXX_CXX_ABI) +if (LIBCXX_CXX_ABI STREQUAL "default") find_path( LIBCXX_LIBCXXABI_INCLUDES_INTERNAL cxxabi.h @@ -107,7 +107,7 @@ if (NOT LIBCXX_CXX_ABI) set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_INTREE 1) else() - set(LIBCXX_CXX_ABI_LIBNAME "none") + set(LIBCXX_CXX_ABI_LIBNAME "default") endif() else() set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") @@ -125,6 +125,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" + AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" AND PYTHONINTERP_FOUND AND LIBCXX_ENABLE_SHARED) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake index 39f2aa575b4..60f2ca6ac98 100644 --- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -102,7 +102,11 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") setup_abi_lib("-DLIBCXXRT" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" ) -elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") +elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") + list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY") +elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default") + # Nothing TODO +else() message(FATAL_ERROR "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are " "supported for c++ abi." diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt index f37ac68ebc2..4383c07d8d2 100644 --- a/libcxx/lib/CMakeLists.txt +++ b/libcxx/lib/CMakeLists.txt @@ -34,7 +34,7 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}" add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}") if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR - LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) + LIBCXX_CXX_ABI_LIBNAME STREQUAL "default")) set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON) endif() diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt index 223dbdbcb57..e3eb3bf3994 100644 --- a/libcxx/lib/abi/CMakeLists.txt +++ b/libcxx/lib/abi/CMakeLists.txt @@ -5,7 +5,7 @@ if (DEFINED TARGET_TRIPLE AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist" AND TARGET cxx_shared AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR - (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")) + (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")) AND NOT LIBCXX_ABI_UNSTABLE AND LIBCXX_ABI_VERSION EQUAL "1") set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "") diff --git a/libcxx/src/exception.cpp b/libcxx/src/exception.cpp index 96bd7ee59a0..ec8969aaf4c 100644 --- a/libcxx/src/exception.cpp +++ b/libcxx/src/exception.cpp @@ -12,7 +12,8 @@ #include "exception" #include "new" -#if defined(__APPLE__) && !defined(LIBCXXRT) +#if defined(__APPLE__) && !defined(LIBCXXRT) && \ + !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) #include <cxxabi.h> using namespace __cxxabiv1; @@ -106,7 +107,8 @@ bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; } int uncaught_exceptions() _NOEXCEPT { -#if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) +#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ + (defined(__APPLE__) || defined(_LIBCPPABI_VERSION)) // on Darwin, there is a helper function so __cxa_get_globals is private # if _LIBCPPABI_VERSION > 1101 return __cxa_uncaught_exceptions(); diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 3d8b2a9d8a6..734d93136b5 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -13,7 +13,8 @@ #include "new" -#if defined(__APPLE__) && !defined(LIBCXXRT) +#if defined(__APPLE__) && !defined(LIBCXXRT) && \ + !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) #include <cxxabi.h> #ifndef _LIBCPPABI_VERSION @@ -26,7 +27,8 @@ #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) #include <cxxabi.h> #endif // defined(LIBCXX_BUILDING_LIBCXXABI) - #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) + #if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) || \ + (!defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif diff --git a/libcxx/src/stdexcept.cpp b/libcxx/src/stdexcept.cpp index 90d8a34b82d..3f333309dd8 100644 --- a/libcxx/src/stdexcept.cpp +++ b/libcxx/src/stdexcept.cpp @@ -14,7 +14,8 @@ #include "__refstring" /* For _LIBCPPABI_VERSION */ -#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT) +#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ + (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)) #include <cxxabi.h> #endif diff --git a/libcxx/src/typeinfo.cpp b/libcxx/src/typeinfo.cpp index 3033c9800f1..d0a7dae3802 100644 --- a/libcxx/src/typeinfo.cpp +++ b/libcxx/src/typeinfo.cpp @@ -8,13 +8,19 @@ //===----------------------------------------------------------------------===// #include <stdlib.h> -#if defined(__APPLE__) || defined(LIBCXXRT) || \ - defined(LIBCXX_BUILDING_LIBCXXABI) +#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ + (defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)) #include <cxxabi.h> #endif #include "typeinfo" +#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) +std::type_info::~type_info() +{ +} +#endif + #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) std::bad_cast::bad_cast() _NOEXCEPT @@ -47,7 +53,7 @@ std::bad_typeid::what() const _NOEXCEPT return "std::bad_typeid"; } -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) // On Darwin, the cxa_bad_* functions cannot be in the lower level library // because bad_cast and bad_typeid are defined in his higher level library void __cxxabiv1::__cxa_bad_typeid() |

