Re: PATCH to run autoconf tests with C++ compiler
On 05/27/2015 08:54 AM, Richard Biener wrote: On Wed, May 27, 2015 at 10:49 AM, Andreas Schwab 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 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" +CXXFLAGS="-
Re: PATCH to run autoconf tests with C++ compiler
On Wed, May 27, 2015 at 10:49 AM, Andreas Schwab 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
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
On May 25, 2015, Alexandre Oliva 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
Re: PATCH to run autoconf tests with C++ compiler
On May 22, 2015, Jason Merrill 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
PATCH to run autoconf tests with C++ compiler
My earlier patch to compile stage 1 with -std=c++98 ran into trouble on FreeBSD, where that flag suppresses declaration of C99 library functions like strtoull. I was surprised that configure was seeing the declaration, but discovered that this was because configure was using the C compiler rather than the C++ compiler. This patch changes GCC configury to always use C++, and to use the normal AC_CHECK_DECLS for overloaded functions. OK for trunk? Jason commit fc47dba7c20126a51d28c34ac31be8c31ebd1ef5 Author: Jason Merrill Date: Thu May 21 14:05:35 2015 -0400 * configure.ac: Use C++ for all tests. Use AC_CHECK_DECLS for strstr and basename. * configure: Regenerate. diff --git a/gcc/configure.ac b/gcc/configure.ac index 810725c..5f9ed92 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -285,6 +285,9 @@ AC_PROG_CC AC_PROG_CXX ACX_PROG_GNAT([-I"$srcdir"/ada]) +# Do configure tests with the C++ compiler, since that's what we build with. +AC_LANG(C++) + # Remove the -O2: for historical reasons, unless bootstrapping we prefer # optimizations to be activated explicitly by the toplevel. case "$CC" in @@ -321,7 +324,6 @@ if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then fi # check what underlying integer type int64_t uses -AC_LANG_PUSH(C++) AC_CACHE_CHECK(for int64_t underlying type, ac_cv_int64_t_type, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_STDINT_H @@ -344,7 +346,6 @@ template <> struct X { typedef long long t; }; ]], [[X::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])]) fi -AC_LANG_POP(C++) @@ -1050,19 +1051,14 @@ m4_pushdef([AC_MSG_ERROR], m4_defn([AC_MSG_WARN]))[]dnl AC_PROG_CXXCPP m4_popdef([AC_MSG_ERROR])[]dnl -AC_LANG_PUSH(C++) - AC_CHECK_HEADERS(unordered_map) AC_CHECK_HEADERS(tr1/unordered_map) AC_CHECK_HEADERS(ext/hash_map) -AC_LANG_POP(C++) - # # Dependency checking. # -AC_LANG_PUSH(C++) ZW_CREATE_DEPDIR AC_CONFIG_COMMANDS([gccdepdir],[ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR @@ -1072,7 +1068,6 @@ AC_CONFIG_COMMANDS([gccdepdir],[ done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR]) ZW_PROG_COMPILER_DEPENDENCIES([CXX]) -AC_LANG_POP(C++) # # UNSORTED @@ -1192,11 +1187,7 @@ case "${host}" in esac AC_FUNC_FORK -# g++ on Solaris 10+ defines _XOPEN_SOURCE=600, which exposes a different -# iconv() prototype. -AC_LANG_PUSH([C++]) AM_ICONV -AC_LANG_POP([C++]) # Until we have in-tree GNU iconv: LIBICONV_DEP= @@ -1211,11 +1202,22 @@ saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" saved_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" + +# gcc_AC_CHECK_DECLS doesn't support overloaded functions, so use the +# normal autoconf function for these. But force definition of +# HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre +# basename handling in libiberty.h. +AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[ +#undef HAVE_DECL_BASENAME +#define HAVE_DECL_BASENAME 1 +#include "ansidecl.h" +#include "system.h"]) + gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \ - stpcpy strnlen strsignal strstr strverscmp \ + madvise stpcpy strnlen strsignal strverscmp \ strtol strtoul strtoll strtoull \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ - free basename getopt clock getpagesize ffs gcc_UNLOCKED_FUNCS, , ,[ + free getopt clock getpagesize ffs gcc_UNLOCKED_FUNCS, , ,[ #include "ansidecl.h" #include "system.h"]) @@ -1264,15 +1266,6 @@ gcc_AC_CHECK_DECLS(sigaltstack, , ,[ #include ]) -# g++ on Solaris 10+ defines _XOPEN_SOURCE=600, which hides the madvise() -# prototype. -AC_LANG_PUSH([C++]) -gcc_AC_CHECK_DECLS(madvise, , ,[ - #include "ansidecl.h" - #include "system.h" -]) -AC_LANG_POP([C++]) - # More time-related stuff. AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ diff --git a/gcc/configure b/gcc/configure index b99eb6d..6d808be 100755 --- a/gcc/configure +++ b/gcc/configure @@ -740,7 +740,6 @@ COLLECT2_LIBS CXXDEPMODE DEPDIR am__leading_dot -CXXCPP doc_build_sys AR NM @@ -792,9 +791,10 @@ c_strict_warn strict_warn c_loose_warn loose_warn +CPP EGREP GREP -CPP +CXXCPP PICFLAG_FOR_TARGET GNATMAKE GNATBIND @@ -950,8 +950,8 @@ CPPFLAGS CXX CXXFLAGS CCC -CPP CXXCPP +CPP GMPLIBS GMPINC ISLLIBS @@ -1734,8 +1734,8 @@ Some influential environment variables: you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGSC++ compiler flags - CPP C preprocessor CXXCPP C++ preprocessor + CPP C preprocessor GMPLIBS How to link GMP GMPINC How to find GMP include files ISLLIBS How to link ISL @@ -1897,10 +1897,10 @@ fi } # ac_fn_cxx_try_compile -# ac_fn_c_try_cpp LINENO -# --