forked from OSchip/llvm-project
Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.
This patch re-commits a previous attempt to support building libc++ w/o an ABI library. That patch was originally reverted because: 1) It forgot to teach the test suite about "default" ABI libraries. 2) Some LLVM builders don't clear the CMake cache between builds. The previous patch caused those builders to fail since their old cache entry for LIBCXX_CXX_ABI="" is no longer valid. The updated patch addresses both issues. It works around (2) by adding a hack to force the builders to update their cache entries. The hack will be removed shortly once all LLVM builders have run. Original commit message ----------------------- 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: 290849
This commit is contained in:
parent
1c9867d009
commit
1285e4d60e
|
@ -87,13 +87,22 @@ 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})
|
||||
|
||||
# FIXME: This is a temporary hack to force LLVM buildbots to store
|
||||
# the fixed cache entry instead of the previous cache entry. This is needed
|
||||
# because some LLVM buildbots don't clear their cache. It will be removed
|
||||
# once all LLVM bots have been run.
|
||||
if (LIBCXX_CXX_ABI STREQUAL "")
|
||||
set(LIBCXX_CXX_ABI "default" CACHE STRING
|
||||
"Specify the C++ ABI library to use." FORCE)
|
||||
endif()
|
||||
|
||||
# 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 +116,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 +134,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,9 +102,14 @@ 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."
|
||||
"Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \
|
||||
Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are
|
||||
supported for c++ abi."
|
||||
)
|
||||
endif ()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -604,7 +604,7 @@ class Configuration(object):
|
|||
self.cxx.link_flags += ['-lc++abi']
|
||||
elif cxx_abi == 'libcxxrt':
|
||||
self.cxx.link_flags += ['-lcxxrt']
|
||||
elif cxx_abi == 'none':
|
||||
elif cxx_abi == 'none' or cxx_abi == 'default':
|
||||
pass
|
||||
else:
|
||||
self.lit_config.fatal(
|
||||
|
|
Loading…
Reference in New Issue