forked from OSchip/llvm-project
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
This commit is contained in:
parent
e772e06686
commit
5d25843f66
|
@ -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)
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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 "")
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue