[Mesa-dev] [PATCH v3 1/2] configure+mesa/st: unify check for -std=c++11 support and enable accordingly

Gert Wollny gw.fossdev at gmail.com
Tue Oct 3 07:31:04 UTC 2017


Unify the CXX feature tests for C++11 support that is required for SWR,
clover, and mesa/st/tests.

Instead of using a custom made test (SWR) or testing for the gcc version
(clover), use ax_check_compile_flag.m4, to test whether the compiler supports
-std=c++11.

If support for this flag is missing fail configuration if clover or swr is requested,
and disable compiling and running the mesa/st tests.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102665
---
 configure.ac                                  | 18 ++++++++++++------
 src/gallium/drivers/swr/Makefile.am           |  4 ++--
 src/gallium/state_trackers/clover/Makefile.am |  6 +++---
 src/mesa/state_tracker/tests/Makefile.am      |  7 ++++++-
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index cfc97d9f06..aaa363e99f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,8 +301,15 @@ AX_CHECK_COMPILE_FLAG([-Wall],                                 [CXXFLAGS="$CXXFL
 AX_CHECK_COMPILE_FLAG([-fno-math-errno],                       [CXXFLAGS="$CXXFLAGS -fno-math-errno"])
 AX_CHECK_COMPILE_FLAG([-fno-trapping-math],                    [CXXFLAGS="$CXXFLAGS -fno-trapping-math"])
 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],                   [VISIBILITY_CXXFLAGS="-fvisibility=hidden"])
+AX_CHECK_COMPILE_FLAG([-std=c++11],                            [have_cxx11=yes])
 AC_LANG_POP([C++])
 
+if test "x$have_cxx11" = "xyes"; then 
+    CXX11_FLAGS=-std=c++11
+    AC_SUBST([CXX11_FLAGS])
+fi
+AM_CONDITIONAL(HAVE_STD_CXX11, test "x$have_cxx11" = "xyes")
+
 # Flags to help ensure that certain portions of the code -- and only those
 # portions -- can be built with MSVC:
 # - src/util, src/gallium/auxiliary, rc/gallium/drivers/llvmpipe, and
@@ -2248,8 +2255,8 @@ if test "x$enable_opencl" = xyes; then
         AC_MSG_ERROR([cannot enable OpenCL without Gallium])
     fi
 
-    if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 7; then
-        AC_MSG_ERROR([gcc >= 4.7 is required to build clover])
+    if test "x$have_cxx11" != "xyes"; then 
+        AC_MSG_ERROR([A compiler supporting -std=c++11 is required to build clover])  
     fi
 
     if test "x$have_libclc" = xno; then
@@ -2532,10 +2539,9 @@ if test -n "$with_gallium_drivers"; then
         xswr)
             llvm_require_version $LLVM_REQUIRED_SWR "swr"
 
-            swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \
-                ",-std=c++11" \
-                SWR_CXX11_CXXFLAGS
-            AC_SUBST([SWR_CXX11_CXXFLAGS])
+            if test "x$have_cxx11" != "xyes"; then 
+                AC_MSG_ERROR([A compiler supporting -std=c++11 is required to build swr])  
+            fi
 
             swr_require_cxx_feature_flags "AVX" "defined(__AVX__)" \
                 ",-target-cpu=sandybridge,-mavx,-march=core-avx,-tp=sandybridge" \
diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
index b20f128bd2..97a0cfb289 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -22,7 +22,7 @@
 include Makefile.sources
 include $(top_srcdir)/src/gallium/Automake.inc
 
-AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) $(SWR_CXX11_CXXFLAGS)
+AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) $(CXX11_FLAGS)
 
 noinst_LTLIBRARIES = libmesaswr.la
 
@@ -39,7 +39,7 @@ COMMON_CXXFLAGS = \
 	-fno-strict-aliasing \
 	$(GALLIUM_DRIVER_CFLAGS) \
 	$(LLVM_CXXFLAGS) \
-	$(SWR_CXX11_CXXFLAGS) \
+	$(CXX11_FLAGS) \
 	-I$(builddir)/rasterizer/codegen \
 	-I$(builddir)/rasterizer/core \
 	-I$(builddir)/rasterizer/jitter \
diff --git a/src/gallium/state_trackers/clover/Makefile.am b/src/gallium/state_trackers/clover/Makefile.am
index 321393536d..fb70fc0477 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -31,14 +31,14 @@ endif
 noinst_LTLIBRARIES = libclover.la libcltgsi.la libclllvm.la
 
 libcltgsi_la_CXXFLAGS = \
-	-std=c++11 \
+	$(CXX11_FLAGS) \
 	$(CLOVER_STD_OVERRIDE) \
 	$(VISIBILITY_CXXFLAGS)
 
 libcltgsi_la_SOURCES = $(TGSI_SOURCES)
 
 libclllvm_la_CXXFLAGS = \
-	-std=c++11 \
+	$(CXX11_FLAGS) \
 	$(VISIBILITY_CXXFLAGS) \
 	$(LLVM_CXXFLAGS) \
 	$(CLOVER_STD_OVERRIDE) \
@@ -51,7 +51,7 @@ libclllvm_la_CXXFLAGS = \
 libclllvm_la_SOURCES = $(LLVM_SOURCES)
 
 libclover_la_CXXFLAGS = \
-	-std=c++11 \
+	$(CXX11_FLAGS) \
 	$(CLOVER_STD_OVERRIDE) \
 	$(VISIBILITY_CXXFLAGS)
 
diff --git a/src/mesa/state_tracker/tests/Makefile.am b/src/mesa/state_tracker/tests/Makefile.am
index f32957608e..61087c0aca 100644
--- a/src/mesa/state_tracker/tests/Makefile.am
+++ b/src/mesa/state_tracker/tests/Makefile.am
@@ -1,3 +1,6 @@
+# The tests require c++11 support
+if HAVE_STD_CXX11
+
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CFLAGS = \
@@ -5,7 +8,7 @@ AM_CFLAGS = \
 
 AM_CXXFLAGS = \
 	$(GALLIUM_DRIVER_CXXFLAGS) \
-	-std=c++11
+	${CXX11_FLAGS}
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/gtest/include \
@@ -32,3 +35,5 @@ st_renumerate_test_LDADD = \
 	$(top_builddir)/src/gtest/libgtest.la \
 	$(GALLIUM_COMMON_LIB_DEPS) \
 	$(LLVM_LIBS)
+
+endif
-- 
2.13.5



More information about the mesa-dev mailing list