https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69153
--- Comment #2 from Peter Bergner <bergner at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > You are leaking a target specific configure option to the configure script. > This seems wrong. Can't you set target_header_dir in config.gcc instead? As the code is now, no, since config.gcc is included before the code that sets $target_header_dir and that code unconditionally sets it, but I suppose we could modify things such that the setting of $target_header_dir first tests whether it's set or not before setting it, giving us the ability to set it in config.gcc. How about the following change that does that? Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 231201) +++ gcc/configure.ac (working copy) @@ -1401,6 +1401,7 @@ . ${srcdir}/config.host target_gtfiles= +target_header_dir= # Collect target-machine-specific information. . ${srcdir}/config.gcc @@ -1997,20 +1998,22 @@ SYSTEM_HEADER_DIR=$build_system_header_dir fi -if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then - if test "x$with_headers" != x; then - target_header_dir=$with_headers - elif test "x$with_sysroot" = x; then - target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" - elif test "x$with_build_sysroot" != "x"; then - target_header_dir="${with_build_sysroot}${native_system_header_dir}" - elif test "x$with_sysroot" = xyes; then - target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" +if test "x$target_header_dir" == x; then + if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then + if test "x$with_headers" != x; then + target_header_dir=$with_headers + elif test "x$with_sysroot" = x; then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" + elif test "x$with_build_sysroot" != "x"; then + target_header_dir="${with_build_sysroot}${native_system_header_dir}" + elif test "x$with_sysroot" = xyes; then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" + else + target_header_dir="${with_sysroot}${native_system_header_dir}" + fi else - target_header_dir="${with_sysroot}${native_system_header_dir}" + target_header_dir=${native_system_header_dir} fi -else - target_header_dir=${native_system_header_dir} fi # If this is a cross-compiler that does not Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 231201) +++ gcc/config.gcc (working copy) @@ -4162,6 +4162,7 @@ -d "/opt/$with_advance_toolchain/bin/." -a \ -d "/opt/$with_advance_toolchain/include/."; then + target_header_dir=`find /opt/$with_advance_toolchain/ -path '*/include/features.h' | sed -e 's#/features.h##'` tm_file="$tm_file ./advance-toolchain.h" (at="/opt/$with_advance_toolchain" echo "/* Use Advance Toolchain $at */"