Re: [Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
On 15 April 2016 at 00:30, Tim Rowleywrote: > --- 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) > +AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) -std=c++11 > > noinst_LTLIBRARIES = libmesaswr.la > > @@ -31,6 +31,7 @@ libmesaswr_la_SOURCES = $(LOADER_SOURCES) > COMMON_CXXFLAGS = \ > $(GALLIUM_DRIVER_CFLAGS) \ > $(LLVM_CFLAGS) \ > + -std=c++11 \ As others have pointed out things will go interesting as we get miss-match between LLVM and SWR. But let's worry about that when we get there. Reviewed-by: Emil Velikov -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
On Fri, Apr 15, 2016 at 12:10 PM, Chuck Atkinswrote: >> > As LLVM_CXXFLAGS / `llvm-config --cxxflags` already includes std=c++11 >> >> Yes, I saw that and considered going that direction, but wasn’t sure if we >> should rely on llvm setting the language version required. > > > Shouldn't you do both? Use LLVM_CXXFLAGS since swr is C++ code including and > using the LLVM C++ API. Add stc=c++11 since swr itself is using C++ 11 > features, regardless of llvm's requirements. This way, each piece is > defining it's own requirements. Just relying on LLVM_CXXFLGS is essentially > assuming that LLVM knows how swr needs to be built. :-/ . The end result > may be a duplicate std=c++11 entry but it's really more coincidence. LLVM > could decide that they want to abandon C++11 and not use it (I know, > extremely unlikely) but swr would still need it regardless. Should be fun when LLVM decides to move to c++14 :) Tim, thanks a lot for taking care of this -- I'm no expert on the mesa build system, so I'll let others do the actual review bit of it. -ilia ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
> > > As LLVM_CXXFLAGS / `llvm-config --cxxflags` already includes std=c++11 > > Yes, I saw that and considered going that direction, but wasn’t sure if we > should rely on llvm setting the language version required. > Shouldn't you do both? Use LLVM_CXXFLAGS since swr is C++ code including and using the LLVM C++ API. Add stc=c++11 since swr itself is using C++ 11 features, regardless of llvm's requirements. This way, each piece is defining it's own requirements. Just relying on LLVM_CXXFLGS is essentially assuming that LLVM knows how swr needs to be built. :-/ . The end result may be a duplicate std=c++11 entry but it's really more coincidence. LLVM could decide that they want to abandon C++11 and not use it (I know, extremely unlikely) but swr would still need it regardless. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
> On Apr 15, 2016, at 10:33 AM, Jose Fonsecawrote: > > On 15/04/16 00:30, Tim Rowley wrote: >> On the philosophy that a driver shouldn't change the compile flags >> for the entire tree, take the clove approach of moving the c++11 flag >> to the swr driver directory. >> --- >> configure.ac| 9 +- >> m4/ax_cxx_compile_stdcxx.m4 | 558 >> >> src/gallium/drivers/swr/Makefile.am | 3 +- >> 3 files changed, 9 insertions(+), 561 deletions(-) >> delete mode 100644 m4/ax_cxx_compile_stdcxx.m4 >> >> diff --git a/configure.ac b/configure.ac >> index 8c82c43..6155942 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -2265,15 +2265,20 @@ if test -n "$with_gallium_drivers"; then >> fi >> ;; >> xswr) >> -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) >> swr_llvm_check "swr" >> >> -AC_MSG_CHECKING([whether $CXX supports AVX/AVX2]) >> +AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2]) >> AVX_CXXFLAGS="-march=core-avx-i" >> AVX2_CXXFLAGS="-march=core-avx2" >> >> 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="$AVX_CXXFLAGS $CXXFLAGS" >> AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], >>[AC_MSG_ERROR([AVX compiler support not >> detected])]) >> diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 >> deleted file mode 100644 >> index 079e17d..000 >> --- a/m4/ax_cxx_compile_stdcxx.m4 >> +++ /dev/null >> @@ -1,558 +0,0 @@ >> -# >> === >> -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html >> -# >> === >> -# >> -# SYNOPSIS >> -# >> -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) >> -# >> -# DESCRIPTION >> -# >> -# Check for baseline language coverage in the compiler for the specified >> -# version of the C++ standard. If necessary, add switches to CXXFLAGS to >> -# enable support. VERSION may be '11' (for the C++11 standard) or '14' >> -# (for the C++14 standard). >> -# >> -# The second argument, if specified, indicates whether you insist on an >> -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. >> -# -std=c++11). If neither is specified, you get whatever works, with >> -# preference for an extended mode. >> -# >> -# The third argument, if specified 'mandatory' or if left unspecified, >> -# indicates that baseline support for the specified C++ standard is >> -# required and that the macro should error out if no mode with that >> -# support is found. If specified 'optional', then configuration proceeds >> -# regardless, after defining HAVE_CXX${VERSION} if and only if a >> -# supporting mode is found. >> -# >> -# LICENSE >> -# >> -# Copyright (c) 2008 Benjamin Kosnik >> -# Copyright (c) 2012 Zack Weinberg >> -# Copyright (c) 2013 Roy Stogner >> -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov >> >> -# Copyright (c) 2015 Paul Norman >> -# Copyright (c) 2015 Moritz Klammler >> -# >> -# Copying and distribution of this file, with or without modification, are >> -# permitted in any medium without royalty provided the copyright notice >> -# and this notice are preserved. This file is offered as-is, without any >> -# warranty. >> - >> -#serial 1 >> - >> -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro >> -dnl (serial version number 13). >> - >> -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl >> - m4_if([$1], [11], [], >> -[$1], [14], [], >> -[$1], [17], [m4_fatal([support for C++17 not yet implemented in >> AX_CXX_COMPILE_STDCXX])], >> -[m4_fatal([invalid first argument `$1' to >> AX_CXX_COMPILE_STDCXX])])dnl >> - m4_if([$2], [], [], >> -[$2], [ext], [], >> -[$2], [noext], [], >> -[m4_fatal([invalid second argument `$2' to >> AX_CXX_COMPILE_STDCXX])])dnl >> - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], >> -[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], >> -[$3], [optional], [ax_cxx_compile_cxx$1_required=false], >> -[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) >> - AC_LANG_PUSH([C++])dnl >> - ac_success=no >> - AC_CACHE_CHECK(whether $CXX supports C++$1 features
Re: [Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
On 15/04/16 00:30, Tim Rowley wrote: On the philosophy that a driver shouldn't change the compile flags for the entire tree, take the clove approach of moving the c++11 flag to the swr driver directory. --- configure.ac| 9 +- m4/ax_cxx_compile_stdcxx.m4 | 558 src/gallium/drivers/swr/Makefile.am | 3 +- 3 files changed, 9 insertions(+), 561 deletions(-) delete mode 100644 m4/ax_cxx_compile_stdcxx.m4 diff --git a/configure.ac b/configure.ac index 8c82c43..6155942 100644 --- a/configure.ac +++ b/configure.ac @@ -2265,15 +2265,20 @@ if test -n "$with_gallium_drivers"; then fi ;; xswr) -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) swr_llvm_check "swr" -AC_MSG_CHECKING([whether $CXX supports AVX/AVX2]) +AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2]) AVX_CXXFLAGS="-march=core-avx-i" AVX2_CXXFLAGS="-march=core-avx2" 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="$AVX_CXXFLAGS $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], [AC_MSG_ERROR([AVX compiler support not detected])]) diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 deleted file mode 100644 index 079e17d..000 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ /dev/null @@ -1,558 +0,0 @@ -# === -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html -# === -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the specified -# version of the C++ standard. If necessary, add switches to CXXFLAGS to -# enable support. VERSION may be '11' (for the C++11 standard) or '14' -# (for the C++14 standard). -# -# The second argument, if specified, indicates whether you insist on an -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -# -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. -# -# The third argument, if specified 'mandatory' or if left unspecified, -# indicates that baseline support for the specified C++ standard is -# required and that the macro should error out if no mode with that -# support is found. If specified 'optional', then configuration proceeds -# regardless, after defining HAVE_CXX${VERSION} if and only if a -# supporting mode is found. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik-# Copyright (c) 2012 Zack Weinberg -# Copyright (c) 2013 Roy Stogner -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov -# Copyright (c) 2015 Paul Norman -# Copyright (c) 2015 Moritz Klammler -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [], -[$1], [14], [], -[$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], -[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], -[$2], [ext], [], -[$2], [noext], [], -[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], -[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], -[$3], [optional], [ax_cxx_compile_cxx$1_required=false], -[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], -[ax_cv_cxx_compile_cxx$1=yes], -[ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then -ac_success=yes - fi - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then -for switch in -std=gnu++$1 -std=gnu++0x; do -
[Mesa-dev] [PATCH] gallium/swr: confine c++11 flag to swr driver
On the philosophy that a driver shouldn't change the compile flags for the entire tree, take the clove approach of moving the c++11 flag to the swr driver directory. --- configure.ac| 9 +- m4/ax_cxx_compile_stdcxx.m4 | 558 src/gallium/drivers/swr/Makefile.am | 3 +- 3 files changed, 9 insertions(+), 561 deletions(-) delete mode 100644 m4/ax_cxx_compile_stdcxx.m4 diff --git a/configure.ac b/configure.ac index 8c82c43..6155942 100644 --- a/configure.ac +++ b/configure.ac @@ -2265,15 +2265,20 @@ if test -n "$with_gallium_drivers"; then fi ;; xswr) -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) swr_llvm_check "swr" -AC_MSG_CHECKING([whether $CXX supports AVX/AVX2]) +AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2]) AVX_CXXFLAGS="-march=core-avx-i" AVX2_CXXFLAGS="-march=core-avx2" 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="$AVX_CXXFLAGS $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], [AC_MSG_ERROR([AVX compiler support not detected])]) diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 deleted file mode 100644 index 079e17d..000 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ /dev/null @@ -1,558 +0,0 @@ -# === -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html -# === -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the specified -# version of the C++ standard. If necessary, add switches to CXXFLAGS to -# enable support. VERSION may be '11' (for the C++11 standard) or '14' -# (for the C++14 standard). -# -# The second argument, if specified, indicates whether you insist on an -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -# -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. -# -# The third argument, if specified 'mandatory' or if left unspecified, -# indicates that baseline support for the specified C++ standard is -# required and that the macro should error out if no mode with that -# support is found. If specified 'optional', then configuration proceeds -# regardless, after defining HAVE_CXX${VERSION} if and only if a -# supporting mode is found. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik-# Copyright (c) 2012 Zack Weinberg -# Copyright (c) 2013 Roy Stogner -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov -# Copyright (c) 2015 Paul Norman -# Copyright (c) 2015 Moritz Klammler -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [], -[$1], [14], [], -[$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], -[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], -[$2], [ext], [], -[$2], [noext], [], -[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], -[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], -[$3], [optional], [ax_cxx_compile_cxx$1_required=false], -[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], -[ax_cv_cxx_compile_cxx$1=yes], -[ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then -ac_success=yes - fi - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then -for switch in -std=gnu++$1 -std=gnu++0x; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) -