Patchwork [3/9] gcc-cross: Make gcc-cross-initial as the only intermediate gcc stage

login
register
mail settings
Submitter Khem Raj
Date Aug. 21, 2012, 3:07 a.m.
Message ID <8a3cf0ce40dbc72a43f08bfed56e61569fe7a910.1345518098.git.raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/35007/
State Accepted
Commit 30617bde61a3b0a0944b49a0c9fb7159dacbb19f
Headers show

Comments

Khem Raj - Aug. 21, 2012, 3:07 a.m.
Now glibc can be compiled with gcc-cross-initial therefore prepare
the stage to drop gcc-cross-intermediate

Also drop arm-nolibfloat.patch should not be needed anymore
half of changes in this patch are meant for OABI which we dont
use anymore

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/gcc/gcc-4.7.inc              |    1 -
 .../gcc/gcc-4.7/arm-nolibfloat.patch               |   40 ----------------
 meta/recipes-devtools/gcc/gcc-cross-initial.inc    |   50 +++++++++++++++-----
 3 files changed, 39 insertions(+), 52 deletions(-)
 delete mode 100644 meta/recipes-devtools/gcc/gcc-4.7/arm-nolibfloat.patch
Elvis Dowson - Aug. 24, 2012, 9:08 p.m.
Hi Khem,

On Aug 21, 2012, at 7:07 AM, Khem Raj wrote:

> Now glibc can be compiled with gcc-cross-initial therefore prepare
> the stage to drop gcc-cross-intermediate

I'm adapting my earlier gcc-4.5 recipes, to try and get them to build with the latest poky master. 

I'm using eglibc-2.13, so it is possible for this version to drop the gcc-cross-intermediate stage, or is it only with newer eglibc versions?

At the moment, I've made the required changes to the gcc-4.5 recipes, to match that of the current gcc-4.7 templates, and deleted the gcc-4.5 intermediate recipes.

Right now I get a compile error with eglibc-2.13, as follows:

| powerpc-poky-linux-gcc  -m32  -msoft-float -mcpu=440 --sysroot=/tool/yocto/poky/build/tmp/sysroots/virtex5-tcbootstrap -nostdlib -nostartfiles -o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/iconv_prog -msoft-float -Wl,-dynamic-linker=/lib/ld.so.1   -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/csu/crt1.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/csu/crti.o `powerpc-poky-linux-gcc  -m32  -msoft-float -mcpu=440 --sysroot=/tool/yocto/poky/build/tmp/sysroots/virtex5-tcbootstrap -msoft-float --print-file-name=crtbegin.o` /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/iconv_prog.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/iconv_charmap.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/charmap.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/charmap-dir.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/linereader.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/dummy-repertoire.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/simple-hash.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/xstrdup.o /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/xmalloc.o  -Wl,-rpath-link=/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/math:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/elf:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/dlfcn:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/nss:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/nis:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/rt:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/resolv:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/crypt:/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/nptl /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/libc.so.6 /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/libc_nonshared.a  /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/elf/ld.so  -lgcc -lgcc_eh  `powerpc-poky-linux-gcc  -m32  -msoft-float -mcpu=440 --sysroot=/tool/yocto/poky/build/tmp/sysroots/virtex5-tcbootstrap -msoft-float --print-file-name=crtend.o` /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/csu/crtn.o
| /tool/yocto/poky/build/tmp/sysroots/x86_64-linux/usr/libexec/ppc440-poky-linux.gcc-cross-initial/gcc/powerpc-poky-linux/4.5.1/ld: cannot find -lgcc_eh
| collect2: ld returned 1 exit status
| make[2]: *** [/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/iconvconfig] Error 1
| make[2]: *** Waiting for unfinished jobs....
| /tool/yocto/poky/build/tmp/sysroots/x86_64-linux/usr/libexec/ppc440-poky-linux.gcc-cross-initial/gcc/powerpc-poky-linux/4.5.1/ld: cannot find -lgcc_eh
| collect2: ld returned 1 exit status
| make[2]: *** [/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/build-powerpc-poky-linux/iconv/iconv_prog] Error 1
| make[2]: Leaving directory `/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/eglibc-2_13/libc/iconv'
| make[1]: *** [iconv/others] Error 2
| make[1]: Leaving directory `/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/eglibc-2_13/libc'
| make: *** [all] Error 2
| ERROR: oe_runmake failed
| ERROR: Function failed: do_compile (see /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/eglibc-2.13-r28+svnr15508/temp/log.do_compile.55715 for further information)
ERROR: Task 32 (/tool/yocto/meta-openembedded/toolchain-layer/recipes-core/eglibc/eglibc_2.13.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1146 tasks of which 1145 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /tool/yocto/meta-openembedded/toolchain-layer/recipes-core/eglibc/eglibc_2.13.bb, do_compile
Summary: There was 1 ERROR message shown, returning a non-zero exit code.


Best regards,

Elvis Dowson
Khem Raj - Aug. 24, 2012, 9:10 p.m.
On Fri, Aug 24, 2012 at 2:08 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>
> I'm adapting my earlier gcc-4.5 recipes, to try and get them to build with
> the latest poky master.
>
> I'm using eglibc-2.13, so it is possible for this version to drop the
> gcc-cross-intermediate stage, or is it only with newer eglibc versions?
>

well it wont work with anything older than eglibc 2.16

> At the moment, I've made the required changes to the gcc-4.5 recipes, to
> match that of the current gcc-4.7 templates, and deleted the gcc-4.5
> intermediate recipes.
>
> Right now I get a compile error with eglibc-2.13, as follows:
Elvis Dowson - Aug. 24, 2012, 9:20 p.m.
On Aug 25, 2012, at 1:10 AM, Khem Raj wrote:

> On Fri, Aug 24, 2012 at 2:08 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>> 
>> I'm adapting my earlier gcc-4.5 recipes, to try and get them to build with
>> the latest poky master.
>> 
>> I'm using eglibc-2.13, so it is possible for this version to drop the
>> gcc-cross-intermediate stage, or is it only with newer eglibc versions?
>> 
> 
> well it wont work with anything older than eglibc 2.16

What should I do to get the gcc-4.5 recipes to continue to build, with eglib-2.13, 
against the poky master branch? Should I retain the gcc-intermediate recipes?

Best regards,

Elvis
Khem Raj - Aug. 24, 2012, 9:59 p.m.
On Friday, August 24, 2012, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>
> On Aug 25, 2012, at 1:10 AM, Khem Raj wrote:
>
>> On Fri, Aug 24, 2012 at 2:08 PM, Elvis Dowson <elvis.dowson@gmail.com>
wrote:
>>>
>>> I'm adapting my earlier gcc-4.5 recipes, to try and get them to build
with
>>> the latest poky master.
>>>
>>> I'm using eglibc-2.13, so it is possible for this version to drop the
>>> gcc-cross-intermediate stage, or is it only with newer eglibc versions?
>>>
>>
>> well it wont work with anything older than eglibc 2.16
>
> What should I do to get the gcc-4.5 recipes to continue to build, with
eglib-2.13,
> against the poky master branch? Should I retain the gcc-intermediate
recipes?

Back port some patches I did for eglibc 2.16 and drop intermediate recipes
> Best regards,
>
> Elvis
Elvis Dowson - Oct. 6, 2012, 6:59 a.m.
Hi Khem,

On Aug 25, 2012, at 1:59 AM, Khem Raj wrote:

> On Friday, August 24, 2012, Elvis Dowson <elvis.dowson@gmail.com> wrote:
> >
> > On Aug 25, 2012, at 1:10 AM, Khem Raj wrote:
> >
> >> On Fri, Aug 24, 2012 at 2:08 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
> >>>
> >>> I'm adapting my earlier gcc-4.5 recipes, to try and get them to build with
> >>> the latest poky master.
> >>>
> >>> I'm using eglibc-2.13, so it is possible for this version to drop the
> >>> gcc-cross-intermediate stage, or is it only with newer eglibc versions?
> >>>
> >>
> >> well it wont work with anything older than eglibc 2.16
> >
> > What should I do to get the gcc-4.5 recipes to continue to build, with eglib-2.13,
> > against the poky master branch? Should I retain the gcc-intermediate recipes?
> 
> Back port some patches I did for eglibc 2.16 and drop intermediate recipes

I've back ported the patches you did for eglibc-2.16 for eglibc-2.13, to use with my gcc-4.5 recipe, for the PowerPC 440 target. With that patch applied, in a local copy of my meta-openembedded/toolchain-layer, containing both the eglibc-2.13 and gcc-4.5, recipe,

building against the poky/master commit id works:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=b0faebd1f07e1616004bd19664395932e7c2c48f
gcc-cross: Make gcc-cross-initial as the only intermediate gcc stage

I am able to get to the shell prompt, and get no crashes upto this point. The root file system seems to be working fine, and I am able to ping the host machine.

It is with the application of the next patch, that I get a an init crash on the console, as I have been seeing earlier. 

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=48df3fe947c4d900aa6b66d9d8352c0d9e59ebe4
eglibc: Fix eglibc-initial and let eglibc depend on it

I've narrowed down the init problem, to the application of the above patch, but I'm unable to figure out why it is failing. Any suggestions?

Best regards,

Elvis Dowson
Khem Raj - Oct. 6, 2012, 3:41 p.m.
On Fri, Oct 5, 2012 at 11:59 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>
> I've narrowed down the init problem, to the application of the above patch,
> but I'm unable to figure out why it is failing. Any suggestions?
>

is it eglibc 2.13 ? or 2.16 one thing  I see is that it is disabling
ssp but otherwise it looks not to so much than changing eglibc to
use gcc-initial
Elvis Dowson - Oct. 6, 2012, 4:11 p.m.
Hi Khem,

On Oct 6, 2012, at 7:41 PM, Khem Raj wrote:

> On Fri, Oct 5, 2012 at 11:59 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>> 
>> I've narrowed down the init problem, to the application of the above patch,
>> but I'm unable to figure out why it is failing. Any suggestions?
>> 
> 
> is it eglibc 2.13 ? or 2.16 one thing  I see is that it is disabling
> ssp but otherwise it looks not to so much than changing eglibc to
> use gcc-initial

It's eglibc-2.13. I will try without disabling ssp. 

I also cherry-picked this patch

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=800ce0f1d09f2d4fc489c98ecca04cf695d707fa
gcc-cross-initial: Reinstate limits.h generation fix

and I think I'll need to backport this patch to gcc-4.5.1, 

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=42f0f96903ac312881ef841ae4380b4d1c72980f
gcc-4.7: Backport libgcc fixes to appease the new build sequence

FYI, I also briefly tested the latest poky master as of today, for the powerpc440 target, but no change from the previous sitatuation, with gcc-4.7.x and eglibc-2.16, which is init=/bin/sh gives no bash prompt. It just finishes loading the kernel and stops with no prompt. If I click on the enter key, the display scrolls up, but that's it. 

With gcc-4.5.1, and specific commits, it varies with things working correctly and giving a bash prompt; to a kernel panic when attempting to run the bash prompt. 

Best regards,

Elvis Dowson
Elvis Dowson - Oct. 9, 2012, 1:48 p.m.
Hi Khem,

On Oct 6, 2012, at 7:41 PM, Khem Raj wrote:

> On Fri, Oct 5, 2012 at 11:59 PM, Elvis Dowson <elvis.dowson@gmail.com> wrote:
>> 
>> 

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=48df3fe947c4d900aa6b66d9d8352c0d9e59ebe4
eglibc: Fix eglibc-initial and let eglibc depend on it

>> I've narrowed down the init problem, to the application of the above patch,
>> but I'm unable to figure out why it is failing. Any suggestions?
>> 
> 
> is it eglibc 2.13 ? or 2.16 one thing  I see is that it is disabling
> ssp but otherwise it looks not to so much than changing eglibc to
> use gcc-initial


I was able to get past the error, with back porting the following patch:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=42f0f96903ac312881ef841ae4380b4d1c72980f
gcc-4.7: Backport libgcc fixes to appease the new build sequence

disabling ssp was not the problem, tested with both ssp enabled and disabled.

So, now I've got gcc-4.5.4 working with eglibc-2.13, upto the point where the kconfig infrastructure was added.

Next, to add the kconfig infrastructure to eglibc-2.13, and fast forward to the tip of the poky master branch, and
see if things are still ok, with the PowerPC440.

Best regards,

Elvis Dowson
Elvis Dowson - Oct. 9, 2012, 5:37 p.m.
Hi Khem,

On Oct 9, 2012, at 5:48 PM, Elvis Dowson wrote:

> So, now I've got gcc-4.5.4 working with eglibc-2.13, upto the point where the kconfig infrastructure was added.
> 
> Next, to add the kconfig infrastructure to eglibc-2.13, and fast forward to the tip of the poky master branch, and
> see if things are still ok, with the PowerPC440.

Good news, I was able to get the backported patches for gcc-4.5.4 and eglibc-2.13 working with the latest poky and meta-openembedded master branch commits. This includes the gcc toolchain rework and the kconfig support to eglibc.

Let me now try to switch to gcc-4.7.2 and eglibc-2.16, and see if things work. I noticed that there was a recent patch to fix a core-image.bb class, that prevented root login if debug tweaks was enabled. Perhaps that is why I didn't see the boot prompt on the target console with the recent gcc versions?

Best regards,

Elvis Dowson
Khem Raj - Oct. 9, 2012, 6:12 p.m.
On Oct 9, 2012, at 10:37 AM, Elvis Dowson <elvis.dowson@gmail.com> wrote:

> Hi Khem,
> 
> On Oct 9, 2012, at 5:48 PM, Elvis Dowson wrote:
> 
>> So, now I've got gcc-4.5.4 working with eglibc-2.13, upto the point where the kconfig infrastructure was added.
>> 
>> Next, to add the kconfig infrastructure to eglibc-2.13, and fast forward to the tip of the poky master branch, and
>> see if things are still ok, with the PowerPC440.
> 
> Good news, I was able to get the backported patches for gcc-4.5.4 and eglibc-2.13 working with the latest poky and meta-openembedded master branch commits. This includes the gcc toolchain rework and the kconfig support to eglibc.
> 
> Let me now try to switch to gcc-4.7.2 and eglibc-2.16, and see if things work. I noticed that there was a recent patch to fix a core-image.bb class, that prevented root login if debug tweaks was enabled. Perhaps that is why I didn't see the boot prompt on the target console with the recent gcc versions?
> 

I don't think so. You should always see login prompt. It might not let you login if you don't have debug-tweaks in IMAGE_FEATURES

> Best regards,
> 
> Elvis Dowson

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-4.7.inc b/meta/recipes-devtools/gcc/gcc-4.7.inc
index 4ad4819..3f13385 100644
--- a/meta/recipes-devtools/gcc/gcc-4.7.inc
+++ b/meta/recipes-devtools/gcc/gcc-4.7.inc
@@ -52,7 +52,6 @@  SRC_URI = "git://github.com/mirrors/gcc.git;branch=${BRANCH};protocol=git \
            file://306-libstdc++-namespace.patch  \
            file://740-sh-pr24836.patch  \
            file://800-arm-bigendian.patch  \
-           file://arm-nolibfloat.patch  \
            file://gcc-poison-system-directories.patch \
            file://gcc-poison-dir-extend.patch \
            file://gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \
diff --git a/meta/recipes-devtools/gcc/gcc-4.7/arm-nolibfloat.patch b/meta/recipes-devtools/gcc/gcc-4.7/arm-nolibfloat.patch
deleted file mode 100644
index 901f014..0000000
--- a/meta/recipes-devtools/gcc/gcc-4.7/arm-nolibfloat.patch
+++ /dev/null
@@ -1,40 +0,0 @@ 
-Upstream-Status: Pending
-
-# Dimitry Andric <dimitry@andric.com>, 2004-05-01
-#
-# * Removed the extra -lfloat option from LIBGCC_SPEC, since it isn't needed
-#   anymore.  (The required functions are now in libgcc.)
-# 
-# Fixes errors like
-# arm-softfloat-linux-gnu/3.4.0/../../../../arm-softfloat-linux-gnu/bin/ld: cannot find -lfloat
-# collect2: ld returned 1 exit status
-# make[2]: *** [arm-softfloat-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/iconvdata/ISO8859-1.so] Error 1
-# when building glibc-2.3.3 with gcc-3.4.0 for arm-softfloat
-
-Index: trunk/gcc/config/arm/linux-elf.h
-===================================================================
---- trunk.orig/gcc/config/arm/linux-elf.h	2012-02-22 12:04:30.644385926 -0800
-+++ trunk/gcc/config/arm/linux-elf.h	2012-02-22 12:04:30.764385931 -0800
-@@ -57,7 +57,7 @@
-    %{shared:-lc} \
-    %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
- 
--#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
-+#define LIBGCC_SPEC "-lgcc"
- 
- #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
- 
-Index: trunk/libgcc/config/arm/t-linux
-===================================================================
---- trunk.orig/libgcc/config/arm/t-linux	2012-02-22 12:11:48.372407121 -0800
-+++ trunk/libgcc/config/arm/t-linux	2012-02-22 12:13:19.868411588 -0800
-@@ -1,6 +1,8 @@
- LIB1ASMSRC = arm/lib1funcs.S
- LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
--	_arm_addsubdf3 _arm_addsubsf3
-+	_negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
-+	_truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
-+	_fixsfsi _fixunssfsi _floatdidf _floatundidf _floatdisf _floatundisf
- 
- # Just for these, we omit the frame pointer since it makes such a big
- # difference.
diff --git a/meta/recipes-devtools/gcc/gcc-cross-initial.inc b/meta/recipes-devtools/gcc/gcc-cross-initial.inc
index 543a94a..be47f85 100644
--- a/meta/recipes-devtools/gcc/gcc-cross-initial.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross-initial.inc
@@ -19,12 +19,11 @@  EXTRA_OECONF = "--with-newlib \
                 ${OPTSPACE} \
 		--program-prefix=${TARGET_PREFIX} \
 		--with-sysroot=${STAGING_DIR_TARGET} \
-		--with-build-sysroot=${GCCCROSS_BUILDSYSROOT} \
+		--with-build-sysroot=${STAGING_DIR_TARGET} \
 		${EXTRA_OECONF_INITIAL} \
 		${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--with-ld=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}ld.bfd', '', d)} \
 		${EXTRA_OECONF_FPU}"
 
-
 GCCCROSS_BUILDSYSROOT = "${B}/tmpsysroot"
 
 do_configure_prepend () {
@@ -39,13 +38,42 @@  do_configure_prepend () {
 do_compile () {
     oe_runmake all-gcc all-target-libgcc
 }
-# fixed limits.h infact includes the so called real limits.h
-# which should come from libc but when we build libc-initial
-# then bunch of configure tests include fixed limits.h which in turn
-# includes real limits.h but this real limits.h is not staged yet
-# so we overwirte the generated include-fixed/limits.h for gcc-cross-initial
-# to get rid references to real limits.h
-
-do_install_append () {
-    cp gcc/include-fixed/limits.h ${D}${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed/limits.h
+do_install () {
+	oe_runmake 'DESTDIR=${D}' install-gcc install-target-libgcc
+
+	# We don't really need this (here shares/ contains man/, info/, locale/).
+	rm -rf ${D}${datadir}/
+
+	# We use libiberty from binutils
+	find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
+	find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
+
+	# Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
+	# found. These need to be relative paths so they work in different locations.
+	dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
+	install -d $dest
+	for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
+		ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
+	done
+	# fixed limits.h infact includes the so called real limits.h
+	# which should come from libc but when we build libc-initial
+	# then bunch of configure tests include fixed limits.h which in turn
+	# includes real limits.h but this real limits.h is not staged yet
+	# so we overwirte the generated include-fixed/limits.h for gcc-cross-initial
+	# to get rid references to real limits.h
+	cp gcc/include-fixed/limits.h ${D}${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed/limits.h
+}
+#
+# Override the default sysroot staging copy since this won't look like a target system
+#
+sysroot_stage_all() {
+	sysroot_stage_dir ${D} ${SYSROOT_DESTDIR}
+	install -d ${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}${target_base_libdir}/
+	install -d ${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}${target_libdir}/
+	mv ${SYSROOT_DESTDIR}${target_base_libdir}/* ${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}${target_base_libdir}/ || true
+	mv ${SYSROOT_DESTDIR}${target_libdir}/* ${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}${target_libdir}/ || true
 }
+
+do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_HOST} ${SYSROOT_DESTDIR}/${STAGING_DIR_TARGET}/${target_base_libdir}"
+do_populate_sysroot[sstate-outputdirs] = "${STAGING_DIR_HOST} ${STAGING_DIR_TCBOOTSTRAP}/${target_base_libdir}"
+