diff options
-rw-r--r-- | configure.ac | 73 | ||||
-rw-r--r-- | src/gallium/drivers/swr/Makefile.am | 4 |
2 files changed, 52 insertions, 25 deletions
diff --git a/configure.ac b/configure.ac index cc9bc4758b8..8321e8eb21d 100644 --- a/configure.ac +++ b/configure.ac @@ -2330,6 +2330,45 @@ swr_llvm_check() { fi } +swr_require_cxx_feature_flags() { + feature_name="$1" + preprocessor_test="$2" + option_list="$3" + output_var="$4" + + AC_MSG_CHECKING([whether $CXX supports $feature_name]) + AC_LANG_PUSH([C++]) + save_CXXFLAGS="$CXXFLAGS" + save_IFS="$IFS" + IFS="," + found=0 + for opts in $option_list + do + unset IFS + CXXFLAGS="$opts $save_CXXFLAGS" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [ #if !($preprocessor_test) + #error + #endif + ])], + [found=1; break], + []) + IFS="," + done + IFS="$save_IFS" + CXXFLAGS="$save_CXXFLAGS" + AC_LANG_POP([C++]) + if test $found -eq 1; then + AC_MSG_RESULT([$opts]) + eval "$output_var=\$opts" + return 0 + fi + AC_MSG_RESULT([no]) + AC_MSG_ERROR([swr requires $feature_name support]) + return 1 +} + dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block if test -n "$with_gallium_drivers"; then gallium_drivers=`IFS=', '; echo $with_gallium_drivers` @@ -2399,31 +2438,19 @@ if test -n "$with_gallium_drivers"; then xswr) swr_llvm_check "swr" - AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2]) - SWR_AVX_CXXFLAGS="-mavx" - SWR_AVX2_CXXFLAGS="-mavx2 -mfma -mbmi2 -mf16c" - - AC_LANG_PUSH([C++]) - save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="-std=c++11 $CXXFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], - [AC_MSG_ERROR([c++11 compiler support not detected])]) - CXXFLAGS="$save_CXXFLAGS" - - save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$SWR_AVX_CXXFLAGS $CXXFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], - [AC_MSG_ERROR([AVX compiler support not detected])]) - CXXFLAGS="$save_CXXFLAGS" - - save_CFLAGS="$CXXFLAGS" - CXXFLAGS="$SWR_AVX2_CXXFLAGS $CXXFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], - [AC_MSG_ERROR([AVX2 compiler support not detected])]) - CXXFLAGS="$save_CXXFLAGS" - AC_LANG_POP([C++]) + swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \ + ",-std=c++11" \ + SWR_CXX11_CXXFLAGS + AC_SUBST([SWR_CXX11_CXXFLAGS]) + swr_require_cxx_feature_flags "AVX" "defined(__AVX__)" \ + ",-mavx,-march=core-avx" \ + SWR_AVX_CXXFLAGS AC_SUBST([SWR_AVX_CXXFLAGS]) + + swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \ + ",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \ + SWR_AVX2_CXXFLAGS AC_SUBST([SWR_AVX2_CXXFLAGS]) HAVE_GALLIUM_SWR=yes diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index d8961541bea..210b2035a49 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) -std=c++11 +AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) $(SWR_CXX11_CXXFLAGS) noinst_LTLIBRARIES = libmesaswr.la @@ -31,7 +31,7 @@ libmesaswr_la_SOURCES = $(LOADER_SOURCES) COMMON_CXXFLAGS = \ $(GALLIUM_DRIVER_CFLAGS) \ $(LLVM_CXXFLAGS) \ - -std=c++11 \ + $(SWR_CXX11_CXXFLAGS) \ -I$(builddir)/rasterizer/scripts \ -I$(builddir)/rasterizer/jitter \ -I$(srcdir)/rasterizer \ |