From 77cc480dad0500f00717a5feec7ac37a4e3ac0a9 Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Tue, 8 Oct 2013 16:57:39 -0700 Subject: [PATCH] Detect libc++ in configure.ac. Summary: - Explicitly detect use of libc++ in configure.ac and reflect this in folly-config.h. Do this rather than looking for to pop up organically _LIBCPP_VERSION since this only exists if we've included some libc++ header files prior to refernce. This isn't always the case, e.g. in Portability.h. Test Plan: - fbconfig -r folly && fbmake runtests - ./configure && make check on Ubuntu/FC/Mac Reviewed By: simpkins@fb.com FB internal diff: D1002958 --- folly/Portability.h | 2 +- folly/configure.ac | 9 +++++++++ folly/test/ScopeGuardTest.cpp | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/folly/Portability.h b/folly/Portability.h index 608c1d9b..d017400e 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -121,7 +121,7 @@ struct MaxAlign { char c; } __attribute__((aligned)); // It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement // the 'std' namespace; the latter uses inline namepsaces. Wrap this decision // up in a macro to make forward-declarations easier. -#ifdef _LIBCPP_VERSION +#if FOLLY_USE_LIBCPP #define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD #else diff --git a/folly/configure.ac b/folly/configure.ac index 2dc854aa..29ae18fd 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -78,6 +78,15 @@ AC_COMPILE_IFELSE( AC_DEFINE([OVERRIDE], [], [Define to "override" if the compiler supports C++11 "override"])] ) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE[ + #include + #if !_LIBCPP_VERSION + #error No libc++ + #endif + void func() {}] + ], + [AC_DEFINE([USE_LIBCPP], [1], [Define to 1 if we're using libc++.])]) # Check for clock_gettime(2). This is not in an AC_CHECK_FUNCS() because we # want to link with librt if necessary. diff --git a/folly/test/ScopeGuardTest.cpp b/folly/test/ScopeGuardTest.cpp index 6e6b65a8..b741e375 100644 --- a/folly/test/ScopeGuardTest.cpp +++ b/folly/test/ScopeGuardTest.cpp @@ -15,6 +15,7 @@ */ #include "folly/ScopeGuard.h" +#include "folly/Portability.h" #include #include @@ -126,7 +127,7 @@ TEST(ScopeGuard, GuardException) { throw std::runtime_error("destructors should never throw!"); }); }, -#ifdef _LIBCPP_VERSION +#if FOLLY_USE_LIBCPP "terminate called throwing an exception" #else "destructors should never throw" -- 2.34.1