don't try to run the poly tests on gcc-4.9. they will fail.
authorEric Niebler <eniebler@fb.com>
Thu, 2 Nov 2017 23:58:07 +0000 (16:58 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 3 Nov 2017 00:16:39 +0000 (17:16 -0700)
Summary: gcc-4.9 does not support features that Poly needs. Disable the tests on that platform.

Reviewed By: meyering

Differential Revision: D6211674

fbshipit-source-id: 289f029122a45b0f9ec740c62b1faaafb51dcab5

folly/Makefile.am
folly/Poly.cpp
folly/Poly.h
folly/configure.ac
folly/test/Makefile.am
folly/test/PolyTest.cpp

index c24cd2c..79bcecb 100644 (file)
@@ -571,7 +571,6 @@ libfolly_la_SOURCES = \
        detail/SocketFastOpen.cpp \
        MacAddress.cpp \
        memory/ThreadCachedArena.cpp \
-       Poly.cpp \
        portability/Dirent.cpp \
        portability/Fcntl.cpp \
        portability/Libgen.cpp \
@@ -713,6 +712,11 @@ libfolly_la_SOURCES += \
        experimental/symbolizer/Symbolizer.cpp
 endif
 
+if HAVE_VARIABLE_TEMPLATES
+libfolly_la_SOURCES += \
+       Poly.cpp
+endif
+
 libfollybasesse42_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LT_VERSION)
 libfollybasesse42_la_CXXFLAGS = -msse4.2 -mpclmul
 
index 352b1a0..93829ba 100644 (file)
  * limitations under the License.
  */
 
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
+#pragma message "Folly.Poly requires gcc-5 or greater"
+#else
+
 #include <folly/Poly.h>
 
 namespace folly {
@@ -22,3 +26,5 @@ namespace detail {
 [[noreturn]] void throwBadPolyCast() { throw BadPolyCast(); }
 } // namespace detail
 } // namespace folly
+
+#endif
index 218fbd8..6acac68 100644 (file)
 
 #pragma once
 
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
+#error Folly.Poly requires gcc-5 or greater
+#endif
+
 #include <cassert>
 #include <new>
 #include <type_traits>
index 181f468..826972e 100644 (file)
@@ -525,6 +525,22 @@ AC_DEFINE_UNQUOTED(
   [Define to 1 if the compiler has VLA (variable-length array) support,
    otherwise define to 0])
 
+AC_CACHE_CHECK(
+  [for variable template support],
+  [folly_cv_prog_cc_have_variable_templates],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE[
+      template <class> constexpr bool g = true;
+      int main() {}
+    ]],
+    [folly_cv_prog_cc_have_variable_templates=yes],
+    [folly_cv_prog_cc_have_variable_templates=no])])
+
+AM_CONDITIONAL(
+  [HAVE_VARIABLE_TEMPLATES],
+  [test "x${folly_cv_prog_cc_have_variable_templates}" = "xyes"],
+  [Define to 1 if the compiler supports variable templates])
+
 # Checks for library functions.
 AC_CHECK_FUNCS([malloc_size \
                 malloc_usable_size \
index dc49c5f..e5da501 100644 (file)
@@ -223,9 +223,11 @@ fingerprint_test_SOURCES = FingerprintTest.cpp
 fingerprint_test_LDADD = libfollytestmain.la $(top_builddir)/libfollybenchmark.la
 TESTS += fingerprint_test
 
+if HAVE_VARIABLE_TEMPLATES
 poly_test_SOURCES = PolyTest.cpp
 poly_test_LDADD = libfollytestmain.la
 TESTS += poly_test
+endif
 
 portability_test_SOURCES = PortabilityTest.cpp
 portability_test_LDADD = libfollytestmain.la
index bbd13b8..7083a46 100644 (file)
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
+#pragma message "Folly.Poly requires gcc-5 or greater"
+#else
 #include <folly/Poly.h>
 
 #include <folly/Conv.h>
@@ -560,3 +563,4 @@ TEST(Poly, Addable) {
   cc = aref + bref;
   EXPECT_EQ(6, poly_cast<int>(cc));
 }
+#endif