[libcxx] r237767 - Fix building and testing libc++ with GCC.

Eric Fiselier eric at efcs.ca
Tue May 19 20:15:01 PDT 2015


Author: ericwf
Date: Tue May 19 22:15:01 2015
New Revision: 237767

URL: http://llvm.org/viewvc/llvm-project?rev=237767&view=rev
Log:
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.

Modified:
    libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
    libcxx/trunk/include/exception
    libcxx/trunk/include/ratio
    libcxx/trunk/src/exception.cpp

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=237767&r1=237766&r2=237767&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Tue May 19 22:15:01 2015
@@ -88,7 +88,7 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STRE
     # 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")

Modified: libcxx/trunk/include/exception
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=237767&r1=237766&r2=237767&view=diff
==============================================================================
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue May 19 22:15:01 2015
@@ -193,7 +193,7 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   is_class<typename remove_reference<_Tp>::type>::value &&
                   !is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
                   && !is_final<typename remove_reference<_Tp>::type>::value
 #endif
                                     >::type* = 0)
@@ -215,7 +215,7 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   !is_class<typename remove_reference<_Tp>::type>::value ||
                   is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
                   || is_final<typename remove_reference<_Tp>::type>::value
 #endif
                                     >::type* = 0)

Modified: libcxx/trunk/include/ratio
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ratio?rev=237767&r1=237766&r2=237767&view=diff
==============================================================================
--- libcxx/trunk/include/ratio (original)
+++ libcxx/trunk/include/ratio Tue May 19 22:15:01 2015
@@ -247,8 +247,11 @@ public:
     typedef ratio<num, den> type;
 };
 
-template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num;
-template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den;
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
+
+template <intmax_t _Num, intmax_t _Den>
+_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
 
 template <class _Tp>                    struct __is_ratio                     : false_type {};
 template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type  {};

Modified: libcxx/trunk/src/exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/exception.cpp?rev=237767&r1=237766&r2=237767&view=diff
==============================================================================
--- libcxx/trunk/src/exception.cpp (original)
+++ libcxx/trunk/src/exception.cpp Tue May 19 22:15:01 2015
@@ -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(<cxxabi.h>)
+#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include(<cxxabi.h>)
   #include <cxxabi.h>
   using namespace __cxxabiv1;
   #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION)





More information about the cfe-commits mailing list