From a1d0f15abbfdf3fc34bdfcfa6eb771f9ddef55a3 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 2 Nov 2017 16:58:07 -0700 Subject: [PATCH] don't try to run the poly tests on gcc-4.9. they will fail. 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 | 6 +++++- folly/Poly.cpp | 6 ++++++ folly/Poly.h | 4 ++++ folly/configure.ac | 16 ++++++++++++++++ folly/test/Makefile.am | 2 ++ folly/test/PolyTest.cpp | 4 ++++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/folly/Makefile.am b/folly/Makefile.am index c24cd2c0..79bcecb0 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -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 diff --git a/folly/Poly.cpp b/folly/Poly.cpp index 352b1a0f..93829baf 100644 --- a/folly/Poly.cpp +++ b/folly/Poly.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 +#pragma message "Folly.Poly requires gcc-5 or greater" +#else + #include namespace folly { @@ -22,3 +26,5 @@ namespace detail { [[noreturn]] void throwBadPolyCast() { throw BadPolyCast(); } } // namespace detail } // namespace folly + +#endif diff --git a/folly/Poly.h b/folly/Poly.h index 218fbd89..6acac682 100644 --- a/folly/Poly.h +++ b/folly/Poly.h @@ -25,6 +25,10 @@ #pragma once +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 +#error Folly.Poly requires gcc-5 or greater +#endif + #include #include #include diff --git a/folly/configure.ac b/folly/configure.ac index 181f4687..826972e2 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -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 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 \ diff --git a/folly/test/Makefile.am b/folly/test/Makefile.am index dc49c5f8..e5da5010 100644 --- a/folly/test/Makefile.am +++ b/folly/test/Makefile.am @@ -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 diff --git a/folly/test/PolyTest.cpp b/folly/test/PolyTest.cpp index bbd13b8f..7083a464 100644 --- a/folly/test/PolyTest.cpp +++ b/folly/test/PolyTest.cpp @@ -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 #include @@ -560,3 +563,4 @@ TEST(Poly, Addable) { cc = aref + bref; EXPECT_EQ(6, poly_cast(cc)); } +#endif -- 2.34.1