On 04/12/17 17:58, Yvan Roux wrote: > Hi, > > On 20 February 2017 at 18:53, Bruce Korb <bk...@gnu.org> wrote: >> On 02/18/17 01:01, Bernd Edlinger wrote: >>> On 02/18/17 00:37, Bruce Korb wrote: >>>> On 02/06/17 10:44, Bernd Edlinger wrote: >>>>> I tested this change with different arm-linux-gnueabihf cross >>>>> compilers, and verified that mkheaders still works on the host system. >>>>> >>>>> Bootstrapped and reg-tested on x86_64-pc-linux-gnu. >>>>> Is it OK for trunk? >>>> >>>> As long as you certify that this is correct for all systems we care about: >>>> >>>> +BUILD_SYSTEM_HEADER_DIR = ` >>>> + echo $(CROSS_SYSTEM_HEADER_DIR) | \ >>>> + sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` >>>> >>>> that is pretty obtuse sed-speak to me. I suggest a comment >>>> explaining what sed is supposed to be doing. What should >>>> "$(CROSS_SYSTEM_HEADER_DIR)" look like? >>>> >>> >>> I took it just from a few lines above, so I thought that comment would >>> sufficiently explain the syntax: >> >> I confess, I didn't pull a new copy of gcc, sorry. >> So it looks good to me. > > > We just noticed that this patch brakes canadian cross builds when > configured with --with-build-sysroot, since headers are searched into > the target sysroot instead of the one specified for builds. > > Maybe there's a cleaner way to fix this and avoid the duplication but > I didn't find another to test if --with-build-sysroot is used. The > attached patch fixes the issue. Tested with a Full canadian cross > build for i686-w64-mingw32 host and arm-linux-gnueabihf. > > Thanks > Yvan > > 2017-04-12 Yvan Roux <yvan.r...@linaro.org> > > * Makefile.in (BUILD_SYSTEM_HEADER_DIR): Set to SYSTEM_HEADER_DIR > when configured with --with-build-sysroot. >
Oops, sorry for the breakage... However I think the patch simply restores the previous behavior, because ifdef SYSROOT_CFLAGS_FOR_TARGET is always true, even if it's empty, but it does still not work correctly. I tried to build a cross with your patch and a --with-build-sysroot but the target compiler does fix the wrong includes for me: ../gcc-trunk/configure --prefix=/home/ed/gnu/arm-linux-gnueabihf-cross --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-languages=c,c++,ada,fortran --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-build-sysroot=/home/ed/gnu/arm-linux-gnueabihf-3 => Fixing headers into /home/ed/gnu/gcc-build-arm-linux-gnueabihf-2/gcc/include-fixed for arm-unknown-linux-gnueabihf target Forbidden identifiers: linux unix Finding directories and links to directories Searching /usr/include/. Searching /usr/include/./c++/4.8.4 Searching /usr/include/./numpy Searching /usr/include/./python2.7/numpy Making symbolic directory links Fixing directory /usr/include into /home/ed/gnu/gcc-build-arm-linux-gnueabihf-2/gcc/include-fixed but it should fix headers in .../arm-linux-gnueabihf-3/usr/include I think it would work if I use --with-sysroot together with --with-build-sysroot in the config above, but why should the target compiler use --with-sysroot ? There is no need for that on the target, just the cross-compiler might need to support that. I tried to fix some possible combinations of --with-sysroot/ --with-build-sysroot, and moved the logic to the configure script. When I did that I noticed also some more glitches when grabbing the TARGET_GLIBC_MAJOR/MINOR defines from sysroot files. This updated patch seems to work for me, could you give it a try? Thanks Bernd.
2017-04-14 Bernd Edlinger <bernd.edlin...@hotmail.de> * configure.ac (SYSTEM_HEADER_DIR, BUILD_SYSTEM_HEADER_DIR, target_header_dir): Set correctly. * configure: Regenerated. * Makefile.in (BUILD_SYSTEM_HEADER_DIR): Use directly. Index: gcc/configure =================================================================== --- gcc/configure (revision 246899) +++ gcc/configure (working copy) @@ -719,6 +719,7 @@ BUILD_CFLAGS CXX_FOR_BUILD CC_FOR_BUILD inhibit_libc +BUILD_SYSTEM_HEADER_DIR SYSTEM_HEADER_DIR ALL CROSS @@ -12214,14 +12215,15 @@ done CROSS= ALL=all.internal SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' +BUILD_SYSTEM_HEADER_DIR=$SYSTEM_HEADER_DIR if test "x$with_build_sysroot" != x; then - build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)' -else + BUILD_SYSTEM_HEADER_DIR=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)' +elif test x$host != x$target; then # This value is used, even on a native system, because # CROSS_SYSTEM_HEADER_DIR is just # $(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR). - build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)' + BUILD_SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' fi if test x$host != x$target @@ -12228,7 +12230,7 @@ if test x$host != x$target then CROSS="-DCROSS_DIRECTORY_STRUCTURE" ALL=all.cross - SYSTEM_HEADER_DIR=$build_system_header_dir + SYSTEM_HEADER_DIR=$BUILD_SYSTEM_HEADER_DIR case $target in *-*-mingw*) if test "x$with_headers" = x; then @@ -12239,16 +12241,17 @@ then ;; esac elif test "x$TARGET_SYSTEM_ROOT" != x; then - SYSTEM_HEADER_DIR=$build_system_header_dir + SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' fi -if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then +if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x || + test x$build != x$host || test "x$with_build_sysroot" != x; then if test "x$with_headers" != x && test "x$with_headers" != xyes; then target_header_dir=$with_headers + elif test "x$with_build_sysroot" != "x"; then + target_header_dir="${with_build_sysroot}${native_system_header_dir}" 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 @@ -18433,7 +18436,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18436 "configure" +#line 18439 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18539,7 +18542,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18542 "configure" +#line 18545 "configure" #include "confdefs.h" #if HAVE_DLFCN_H Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 246899) +++ gcc/configure.ac (working copy) @@ -1998,14 +1998,15 @@ done CROSS= AC_SUBST(CROSS) ALL=all.internal AC_SUBST(ALL) SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' AC_SUBST(SYSTEM_HEADER_DIR) +BUILD_SYSTEM_HEADER_DIR=$SYSTEM_HEADER_DIR AC_SUBST(BUILD_SYSTEM_HEADER_DIR) if test "x$with_build_sysroot" != x; then - build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)' -else + BUILD_SYSTEM_HEADER_DIR=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)' +elif test x$host != x$target; then # This value is used, even on a native system, because # CROSS_SYSTEM_HEADER_DIR is just # $(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR). - build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)' + BUILD_SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' fi if test x$host != x$target @@ -2012,7 +2013,7 @@ if test x$host != x$target then CROSS="-DCROSS_DIRECTORY_STRUCTURE" ALL=all.cross - SYSTEM_HEADER_DIR=$build_system_header_dir + SYSTEM_HEADER_DIR=$BUILD_SYSTEM_HEADER_DIR case $target in *-*-mingw*) if test "x$with_headers" = x; then @@ -2023,16 +2024,17 @@ then ;; esac elif test "x$TARGET_SYSTEM_ROOT" != x; then - SYSTEM_HEADER_DIR=$build_system_header_dir + SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' fi -if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then +if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x || + test x$build != x$host || test "x$with_build_sysroot" != x; then if test "x$with_headers" != x && test "x$with_headers" != xyes; then target_header_dir=$with_headers + elif test "x$with_build_sysroot" != "x"; then + target_header_dir="${with_build_sysroot}${native_system_header_dir}" 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 Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 246899) +++ gcc/Makefile.in (working copy) @@ -518,11 +518,7 @@ CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` # Path to the system headers on the build machine -ifeq ($(build),$(host)) -BUILD_SYSTEM_HEADER_DIR = $(SYSTEM_HEADER_DIR) -else -BUILD_SYSTEM_HEADER_DIR = `echo $(CROSS_SYSTEM_HEADER_DIR) | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` -endif +BUILD_SYSTEM_HEADER_DIR = `echo @BUILD_SYSTEM_HEADER_DIR@ | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` # Control whether to run fixincludes. STMP_FIXINC = @STMP_FIXINC@