From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Yvan Roux <yvan.roux@linaro.org>, Bruce Korb <bkorb@gnu.org>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Richard Biener <rguenther@suse.de>
Subject: Re: [PATCH] Fix fixincludes for canadian cross builds
Date: Fri, 14 Apr 2017 04:18:00 -0000 [thread overview]
Message-ID: <AM4PR0701MB216243AFF31FFE670A5B88A8E4050@AM4PR0701MB2162.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <CAD57uCdjjVuo4Us=htfO7w-V=nJOa77VfiMoVpD7-hqW+z4S1A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3638 bytes --]
On 04/12/17 17:58, Yvan Roux wrote:
> Hi,
>
> On 20 February 2017 at 18:53, Bruce Korb <bkorb@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.roux@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fixinc.diff --]
[-- Type: text/x-patch; name="fixinc.diff", Size: 6252 bytes --]
2017-04-14 Bernd Edlinger <bernd.edlinger@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@
next prev parent reply other threads:[~2017-04-14 4:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-06 18:44 Bernd Edlinger
2017-02-18 1:07 ` Bruce Korb
2017-02-18 11:39 ` Bernd Edlinger
2017-02-20 18:18 ` Bruce Korb
2017-04-12 15:59 ` Yvan Roux
2017-04-12 16:22 ` Bruce Korb
2017-04-14 4:18 ` Bernd Edlinger [this message]
2017-04-14 8:24 ` Yvan Roux
2017-04-14 10:37 ` Bernd Edlinger
2017-04-14 11:20 ` Yvan Roux
2017-04-18 18:29 ` Bernd Edlinger
2017-04-19 7:56 ` Yvan Roux
2017-04-20 20:29 ` [PATCH] Fix fixincludes for canadian cross builds - next try Bernd Edlinger
2017-04-20 20:35 ` Matthew Fortune
2017-04-21 10:41 ` Yvan Roux
2017-04-28 19:13 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM4PR0701MB216243AFF31FFE670A5B88A8E4050@AM4PR0701MB2162.eurprd07.prod.outlook.com \
--to=bernd.edlinger@hotmail.de \
--cc=bkorb@gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=yvan.roux@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).