When build != host, the build compiler obviously isn't the same as the host compiler, but BUILD_CXXFLAGS is currently ALL_CXXFLAGS. ALL_CXXFLAGS contains flags for which we run configure tests on the host compiler, which may not work on the build compiler. I ran into this with -Wno-narrowing. It looks like this problem has been hit before when we used to build gcc with a C compiler and solved, but the solution needs extending now that we build with a C++ compiler.
The second problem is that GMPINC (specifying a host include path) may not be correct for the build compiler. I found this caused a lot of build configure failures when attempting a build=powerpc64-linux, host=powerpc64le-linux, target=powerpc64le-linux toolchain due to mismatches in various function declarations between build and host. The configure problems caused later build failure. (Hint for anyone trying to debug canadian crosses: comment out "rm -rf $tempdir" just a few lines below the first hunk in the patch below to see the build config.log.) The other little tweak here is to omit saving CFLAGS. CFLAGS is set here only in the environment of the called command, not the caller shell. So there is no need to save and restore. Bootstrapped etc. powerpc64-linux. OK mainline and 4.8 branch? * configure.ac (BUILD_CXXFLAGS) Don't use ALL_CXXFLAGS for build != host. <recursive call for build != host>: Clear GMPINC. Don't bother saving CFLAGS. * configure: Regenerate. Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 205341) +++ gcc/configure.ac (working copy) @@ -1529,13 +1529,11 @@ /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};; *) realsrcdir=../${srcdir};; esac - saved_CFLAGS="${CFLAGS}" CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ - LDFLAGS="${LDFLAGS_FOR_BUILD}" \ + LDFLAGS="${LDFLAGS_FOR_BUILD}" GMPINC="" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ --target=$target_alias --host=$build_alias --build=$build_alias - CFLAGS="${saved_CFLAGS}" # We just finished tests for the build machine, so rename # the file auto-build.h in the gcc directory. @@ -1900,6 +1898,7 @@ if test x$build != x$host || test "x$coverage_flags" != x then BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' + BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CXXFLAGS_FOR_BUILD)' BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)' fi -- Alan Modra Australia Development Lab, IBM