[Mesa-dev] [PATCH] clover: Work around build failure with AltiVec.

Matt Turner mattst88 at gmail.com
Thu Mar 2 05:57:49 UTC 2017


Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=587210
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68504
---
A similar patch was sent three and a half years ago. [1]

Curro expressed a concern about changing to a GNU C++ dialect and suggested
disabling AltiVec code generation for Clover, as it shouldn't improve anything.
Unfortunately, user-specified CFLAGS appear *after* CFLAGS the build system
adds, so appending -mno-altivec doesn't work if the user's CFLAGS contain
-maltivec.

Instead, perform a compile test to see if AltiVec is enabled, and if so add
-std=gnu++11 to the flags. In this way, no GNU C++ extensions will leak into
the code, and Clover will build on ppc/altivec.

Perhaps some or all of this should be in the commit summary...

[1] https://lists.freedesktop.org/archives/mesa-dev/2013-August/043890.html

 configure.ac                                  | 14 ++++++++++++++
 src/gallium/state_trackers/clover/Makefile.am |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/configure.ac b/configure.ac
index a3d1a00..57c4b1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2033,6 +2033,20 @@ if test "x$enable_opencl" = xyes; then
        AC_MSG_ERROR([Clover requires libelf])
     fi
 
+    if test "x${ac_cv_cxx_compiler_gnu}" = xyes; then
+        altivec_enabled=no
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+        #if !defined(__VEC__) || !defined(__ALTIVEC__)
+        #error "AltiVec not enabled"
+        #endif
+        ])], altivec_enabled=yes)
+
+        if test "$altivec_enabled" = yes; then
+            CLOVER_STD_OVERRIDE="-std=gnu++11"
+        fi
+        AC_SUBST([CLOVER_STD_OVERRIDE])
+    fi
+
     llvm_require_version $LLVM_REQUIRED_OPENCL "opencl"
 
     llvm_add_default_components "opencl"
diff --git a/src/gallium/state_trackers/clover/Makefile.am b/src/gallium/state_trackers/clover/Makefile.am
index a657e5b..3213935 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -32,6 +32,7 @@ noinst_LTLIBRARIES = libclover.la libcltgsi.la libclllvm.la
 
 libcltgsi_la_CXXFLAGS = \
 	-std=c++11 \
+	$(CLOVER_STD_OVERRIDE) \
 	$(VISIBILITY_CXXFLAGS)
 
 libcltgsi_la_SOURCES = $(TGSI_SOURCES)
@@ -40,6 +41,7 @@ libclllvm_la_CXXFLAGS = \
 	-std=c++11 \
 	$(VISIBILITY_CXXFLAGS) \
 	$(LLVM_CXXFLAGS) \
+	$(CLOVER_STD_OVERRIDE) \
 	$(DEFINES) \
 	$(LIBELF_CFLAGS) \
 	-DLIBCLC_INCLUDEDIR=\"$(LIBCLC_INCLUDEDIR)/\" \
@@ -50,6 +52,7 @@ libclllvm_la_SOURCES = $(LLVM_SOURCES)
 
 libclover_la_CXXFLAGS = \
 	-std=c++11 \
+	$(CLOVER_STD_OVERRIDE) \
 	$(VISIBILITY_CXXFLAGS)
 
 libclover_la_LIBADD = \
-- 
2.10.2



More information about the mesa-dev mailing list