From bae11add65ad04c6e80bb0b51066ee1fb1d8b407 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 20 May 2015 03:15:01 +0000 Subject: [PATCH] Fix building and testing libc++ with GCC. The changes in src/exception.cpp and cmake/Modules/HandleLibCXXABI.cmake fix a bug when building libc++ with GCC. Because GCC does not support __has_include we need to explicitly tell it that we are building against libc++abi via the preprocessor definition `LIBCXX_BUILDING_LIBCXXABI`. The changes in include/ratio are to work around CWG defect 1712 (constexpr variable template declarations). GCC 4.8 and before has not adopted the resolution to this defect. The changes in include/exception work around an issue where is_final is used without it being defined in type_traits. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@237767 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/HandleLibCXXABI.cmake | 2 +- include/exception | 4 ++-- include/ratio | 7 +++++-- src/exception.cpp | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake index ac426979..73723e35 100644 --- a/cmake/Modules/HandleLibCXXABI.cmake +++ b/cmake/Modules/HandleLibCXXABI.cmake @@ -88,7 +88,7 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") # Assume c++abi is installed in the system, rely on -lc++abi link flag. set(CXXABI_LIBNAME "c++abi") endif() - setup_abi_lib("" + setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" ${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" "" ) elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") diff --git a/include/exception b/include/exception index 2d8c0f54..ef2b969b 100644 --- a/include/exception +++ b/include/exception @@ -193,7 +193,7 @@ void throw_with_nested(_Tp&& __t, typename enable_if< is_class::type>::value && !is_base_of::type>::value -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER > 11 && __has_feature(is_final) && !is_final::type>::value #endif >::type* = 0) @@ -215,7 +215,7 @@ void throw_with_nested(_Tp&& __t, typename enable_if< !is_class::type>::value || is_base_of::type>::value -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER > 11 && __has_feature(is_final) || is_final::type>::value #endif >::type* = 0) diff --git a/include/ratio b/include/ratio index 6ddc19bf..f623a062 100644 --- a/include/ratio +++ b/include/ratio @@ -247,8 +247,11 @@ public: typedef ratio type; }; -template const intmax_t ratio<_Num, _Den>::num; -template const intmax_t ratio<_Num, _Den>::den; +template +_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num; + +template +_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den; template struct __is_ratio : false_type {}; template struct __is_ratio > : true_type {}; diff --git a/src/exception.cpp b/src/exception.cpp index 07983cea..98b7b441 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -29,7 +29,7 @@ #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #endif // _LIBCPPABI_VERSION -#elif defined(LIBCXXRT) || __has_include() +#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include() #include using namespace __cxxabiv1; #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION)