Re: PATCH to run autoconf tests with C++ compiler

2015-05-27 Thread Andreas Schwab
This breaks all checks for supported compiler options:

configure:6382: checking whether gcc supports -Wnarrowing
configure:6399: gcc -c -Wnarrowing  conftest.c 5
cc1: error: unrecognized command line option -Wnarrowing
configure:6399: $? = 1

configure:6485: checking whether gcc supports -Wnarrowing
configure:6502: g++ -std=c++98 -c -g   conftest.cpp 5
configure:6502: $? = 0
configure:6511: result: yes

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
And now for something completely different.


Re: PATCH to run autoconf tests with C++ compiler

2015-05-27 Thread Richard Biener
On Wed, May 27, 2015 at 10:49 AM, Andreas Schwab sch...@suse.de wrote:
 This breaks all checks for supported compiler options:

 configure:6382: checking whether gcc supports -Wnarrowing
 configure:6399: gcc -c -Wnarrowing  conftest.c 5
 cc1: error: unrecognized command line option -Wnarrowing
 configure:6399: $? = 1

 configure:6485: checking whether gcc supports -Wnarrowing
 configure:6502: g++ -std=c++98 -c -g   conftest.cpp 5
 configure:6502: $? = 0
 configure:6511: result: yes

And thus causes PR66304, bootstrap failure with host gcc 4.3 (at least).

Richard.

 Andreas.

 --
 Andreas Schwab, SUSE Labs, sch...@suse.de
 GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
 And now for something completely different.


Re: PATCH to run autoconf tests with C++ compiler

2015-05-27 Thread Jason Merrill

On 05/27/2015 08:54 AM, Richard Biener wrote:

On Wed, May 27, 2015 at 10:49 AM, Andreas Schwab sch...@suse.de wrote:

This breaks all checks for supported compiler options:

configure:6382: checking whether gcc supports -Wnarrowing
configure:6399: gcc -c -Wnarrowing  conftest.c 5
cc1: error: unrecognized command line option -Wnarrowing
configure:6399: $? = 1

configure:6485: checking whether gcc supports -Wnarrowing
configure:6502: g++ -std=c++98 -c -g   conftest.cpp 5
configure:6502: $? = 0
configure:6511: result: yes


And thus causes PR66304, bootstrap failure with host gcc 4.3 (at least).


Fixed thus:


commit 0af5fc110196c2e9421f65c48ac09391bce031e3
Author: Jason Merrill ja...@redhat.com
Date:   Wed May 27 09:49:06 2015 -0400

	PR bootstrap/66304
config/
	* warnings.m4 (ACX_PROG_CXX_WARNING_OPTS)
	(ACX_PROG_CXX_WARNINGS_ARE_ERRORS)
	(ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC): New.
	(ACX_PROG_CC_WARNING_OPTS, ACX_PROG_CC_WARNING_ALMOST_PEDANTIC)
	(ACX_PROG_CC_WARNINGS_ARE_ERRORS): Push into C language context.
gcc/
	* configure.ac: Use ACX_PROG_CXX_WARNING_OPTS,
	ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC, and
	ACX_PROG_CXX_WARNINGS_ARE_ERRORS.
	* configure: Regenerate.

diff --git a/config/warnings.m4 b/config/warnings.m4
index b64b594..b5a149a 100644
--- a/config/warnings.m4
+++ b/config/warnings.m4
@@ -23,6 +23,7 @@
 #   compiler accepts.
 AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
 [AC_REQUIRE([AC_PROG_CC])dnl
+AC_LANG_PUSH(C)
 m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
 AC_SUBST(acx_Var)dnl
 m4_expand_once([acx_Var=
@@ -48,6 +49,7 @@ for real_option in $1; do
 done
 CFLAGS=$save_CFLAGS
 m4_popdef([acx_Var])dnl
+AC_LANG_POP(C)
 ])# ACX_PROG_CC_WARNING_OPTS
 
 # ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
@@ -55,6 +57,7 @@ m4_popdef([acx_Var])dnl
 #   and accepts all of those options simultaneously, otherwise to nothing.
 AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
 [AC_REQUIRE([AC_PROG_CC])dnl
+AC_LANG_PUSH(C)
 m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
 AC_SUBST(acx_Var)dnl
 m4_expand_once([acx_Var=
@@ -77,6 +80,7 @@ AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
 AS_VAR_POPDEF([acx_Pedantic])dnl
 m4_popdef([acx_Woptions])dnl
 m4_popdef([acx_Var])dnl
+AC_LANG_POP(C)
 ])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
 
 # ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
@@ -88,6 +92,7 @@ m4_popdef([acx_Var])dnl
 #   appeared on the configure command line.
 AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
 [AC_REQUIRE([AC_PROG_CC])dnl
+AC_LANG_PUSH(C)
 m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
 AC_SUBST(acx_Var)dnl
 m4_expand_once([acx_Var=
@@ -114,4 +119,109 @@ AS_IF([test $enable_werror_always = yes],
[acx_Var=$acx_Var${acx_Var:+ }-Werror])
   AS_VAR_POPDEF([acx_GCCvers])])
 m4_popdef([acx_Var])dnl
+AC_LANG_POP(C)
 ])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
+
+# ACX_PROG_CXX_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS)
+#   Sets @VARIABLE@ to the subset of the given options which the
+#   compiler accepts.
+AC_DEFUN([ACX_PROG_CXX_WARNING_OPTS],
+[AC_REQUIRE([AC_PROG_CXX])dnl
+AC_LANG_PUSH(C++)
+m4_pushdef([acx_Var], [m4_default([$2], [WARN_CXXFLAGS])])dnl
+AC_SUBST(acx_Var)dnl
+m4_expand_once([acx_Var=
+],m4_quote(acx_Var=))dnl
+save_CXXFLAGS=$CXXFLAGS
+for real_option in $1; do
+  # Do the check with the no- prefix removed since gcc silently
+  # accepts any -Wno-* option on purpose
+  case $real_option in
+-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
+*) option=$real_option ;;
+  esac
+  AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
+  AC_CACHE_CHECK([whether $CXX supports $option], acx_Woption,
+[CXXFLAGS=$option
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+  [AS_VAR_SET(acx_Woption, yes)],
+  [AS_VAR_SET(acx_Woption, no)])
+  ])
+  AS_IF([test AS_VAR_GET(acx_Woption) = yes],
+[acx_Var=$acx_Var${acx_Var:+ }$real_option])
+  AS_VAR_POPDEF([acx_Woption])dnl
+done
+CXXFLAGS=$save_CXXFLAGS
+m4_popdef([acx_Var])dnl
+AC_LANG_POP(C++)
+])# ACX_PROG_CXX_WARNING_OPTS
+
+# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
+#   Append to VARIABLE -pedantic + the argument, if the compiler is G++
+#   and accepts all of those options simultaneously, otherwise to nothing.
+AC_DEFUN([ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC],
+[AC_REQUIRE([AC_PROG_CXX])dnl
+AC_LANG_PUSH(C++)
+m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
+AC_SUBST(acx_Var)dnl
+m4_expand_once([acx_Var=
+],m4_quote(acx_Var=))dnl
+# Do the check with the no- prefix removed from the warning options
+# since gcc silently accepts any -Wno-* option on purpose
+m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
+AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
+AS_IF([test $GXX = yes],
+[AC_CACHE_CHECK([whether $CXX supports -pedantic ]acx_Woptions, acx_Pedantic,
+[save_CXXFLAGS=$CXXFLAGS

Re: PATCH to run autoconf tests with C++ compiler

2015-05-25 Thread Alexandre Oliva
On May 22, 2015, Jason Merrill ja...@redhat.com wrote:

   * configure.ac: Use C++ for all tests.  Use AC_CHECK_DECLS for
   strstr and basename.
   * configure: Regenerate.

This is ok, thanks.

I have one concern about scenarios in which config.cache is shared by
all builds for the host, but in which stage1 and stage2 compilers might
(and arguably should) get different results because of stage1's
-std=c++98, but with a shared config.cache, they won't.  config.cache is
disabled by default, but I have it enabled and shared, so I might catch
any fallout from this change, so I'll keep my eyes open.  It's not like
we couldn't have run into this before, due to differences between the
system C compiler and stage1, so...  /me crosses fingers ;-)

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


Re: PATCH to run autoconf tests with C++ compiler

2015-05-25 Thread Alexandre Oliva
On May 25, 2015, Alexandre Oliva aol...@redhat.com wrote:

 I have one concern about scenarios in which config.cache is shared by
 all builds for the host, but in which stage1 and stage2 compilers might
 (and arguably should) get different results because of stage1's
 -std=c++98, but with a shared config.cache, they won't.

Nevermind, we don't share config.cache between host builds any more.

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer