Patchwork [RFC] binutils: allow distro to select gold as default cross-linker

login
register
mail settings
Submitter Phil Blundell
Date June 15, 2011, 2:32 p.m.
Message ID <1308148335.25285.1774.camel@phil-desktop>
Download mbox | patch
Permalink /patch/5987/
State New, archived
Headers show

Comments

Phil Blundell - June 15, 2011, 2:32 p.m.
On Wed, 2011-06-15 at 09:04 +0100, Phil Blundell wrote:
> One slightly annoying thing is that (e)glibc isn't buildable with gold
> because the linker scripts don't work.  So a little bit of patching is
> going to be needed to have it use ld.bfd there.  There might be some
> other packages with similar issues but I haven't come across any yet.

I think something like this is probably what's required for that.

From 48eaba1da89086b8edccaa03c27075d78635ab01 Mon Sep 17 00:00:00 2001
From: Phil Blundell <philb@gnu.org>
Date: Wed, 15 Jun 2011 15:22:47 +0100
Subject: [PATCH] gcc-cross-intermediate: use ld.bfd if distro prefers gold


Signed-off-by: Phil Blundell <philb@gnu.org>
---
 .../gcc/gcc-cross-intermediate.inc                 |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Khem Raj - June 15, 2011, 4:26 p.m.
On 06/15/2011 07:32 AM, Phil Blundell wrote:
> On Wed, 2011-06-15 at 09:04 +0100, Phil Blundell wrote:
>> One slightly annoying thing is that (e)glibc isn't buildable with gold
>> because the linker scripts don't work.  So a little bit of patching is
>> going to be needed to have it use ld.bfd there.  There might be some
>> other packages with similar issues but I haven't come across any yet.
>
> I think something like this is probably what's required for that.
>
>  From 48eaba1da89086b8edccaa03c27075d78635ab01 Mon Sep 17 00:00:00 2001
> From: Phil Blundell<philb@gnu.org>
> Date: Wed, 15 Jun 2011 15:22:47 +0100
> Subject: [PATCH] gcc-cross-intermediate: use ld.bfd if distro prefers gold
>
>
> Signed-off-by: Phil Blundell<philb@gnu.org>
> ---
>   .../gcc/gcc-cross-intermediate.inc                 |    7 ++++++-
>   1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc b/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
> index 92c3ce2..05b5dbc 100644
> --- a/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
> +++ b/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
> @@ -7,6 +7,10 @@ CROSS_TARGET_SYS_DIR_append = ".${PN}"
>
>   # This is intended to be a -very- basic config
>   # sysroot is needed in case we use libc-initial
> +#
> +# Glibc won't compile with gold, and building glibc is the whole point of
> +# this recipe.   So we select ld.bfd explicitly here if gold is the distro's
> +# preferred linker.
>   EXTRA_OECONF = "--with-local-prefix=${STAGING_DIR_TARGET}${target_prefix} \
>   		--enable-shared \
>   		--disable-multilib \
> @@ -17,7 +21,8 @@ EXTRA_OECONF = "--with-local-prefix=${STAGING_DIR_TARGET}${target_prefix} \
>   		--with-sysroot=${STAGING_DIR_TCBOOTSTRAP} \
>   		--with-build-sysroot=${STAGING_DIR_TCBOOTSTRAP} \
>   		${EXTRA_OECONF_INTERMEDIATE} \
> -		${@get_gcc_fpu_setting(bb, d)}"
> +		${@get_gcc_fpu_setting(bb, d)} \
> +		${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--with-ld=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}ld.bfd', '', d)}"
>
>   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}"

this might not work second time around when gcc-cross has been staged.
Phil Blundell - June 15, 2011, 4:31 p.m.
On Wed, 2011-06-15 at 09:26 -0700, Khem Raj wrote:
> this might not work second time around when gcc-cross has been staged.

Oh, I thought that mess was fixed nowadays.  Doesn't eglibc always use
the -intermediate compiler from the special tcbootstrap place?  

If it's just picking whatever was staged most recently then yeah, this
will lose. 

p.
Khem Raj - June 15, 2011, 4:35 p.m.
On 06/15/2011 09:31 AM, Phil Blundell wrote:
> On Wed, 2011-06-15 at 09:26 -0700, Khem Raj wrote:
>> this might not work second time around when gcc-cross has been staged.
>
> Oh, I thought that mess was fixed nowadays.  Doesn't eglibc always use
> the -intermediate compiler from the special tcbootstrap place?
>
> If it's just picking whatever was staged most recently then yeah, this
> will lose.
>

ah I stand corrected.

STAGINGCC = "gcc-cross-intermediate"
PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"

so yes it uses gcc-cross-intermediate all the time.

This will work. Do you know what problems eglibc has linking with gold ?
may be we can fix it

> p.
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Phil Blundell - June 15, 2011, 4:42 p.m.
On Wed, 2011-06-15 at 09:35 -0700, Khem Raj wrote:
> This will work. Do you know what problems eglibc has linking with gold ?
> may be we can fix it

If I remember right, it relies on linker script functionality which gold
just doesn't have.  I suspect this would be hard to fix and, unless
there is a pressing need to fight that particular battle, I would be
inclined not to bother.

That said, though, I haven't checked recently and it's possible that
recent versions of gold will "just work".  If you wanted to give it a
try then I think it'd just be a question of h4x0ring eglibc's configure
script slightly to get it to accept gold as a valid linker version.

p.
Khem Raj - June 15, 2011, 4:47 p.m.
On 06/15/2011 09:42 AM, Phil Blundell wrote:
> On Wed, 2011-06-15 at 09:35 -0700, Khem Raj wrote:
>> This will work. Do you know what problems eglibc has linking with gold ?
>> may be we can fix it
>
> If I remember right, it relies on linker script functionality which gold
> just doesn't have.  I suspect this would be hard to fix and, unless
> there is a pressing need to fight that particular battle, I would be
> inclined not to bother.
>
> That said, though, I haven't checked recently and it's possible that
> recent versions of gold will "just work".  If you wanted to give it a
> try then I think it'd just be a question of h4x0ring eglibc's configure
> script slightly to get it to accept gold as a valid linker version.
>

I remember now. Accepting gold would be easier but changing how ld.so is 
built where it asks ld to spit out default linker script and then munge 
it before reusing it is harder part. I think status is still same. It 
reminds me that we probably need ld.bfd for kernel too.


> p.
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Phil Blundell - June 15, 2011, 4:50 p.m.
On Wed, 2011-06-15 at 09:47 -0700, Khem Raj wrote:
> we probably need ld.bfd for kernel too.

Yeah.  That's easy though, because the kernel invokes ld directly rather
than going through the compiler driver.  Just need to set ${KERNEL_LD}
appropriately and it should all be fine.

p.

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc b/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
index 92c3ce2..05b5dbc 100644
--- a/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross-intermediate.inc
@@ -7,6 +7,10 @@  CROSS_TARGET_SYS_DIR_append = ".${PN}"
 
 # This is intended to be a -very- basic config
 # sysroot is needed in case we use libc-initial
+#
+# Glibc won't compile with gold, and building glibc is the whole point of
+# this recipe.   So we select ld.bfd explicitly here if gold is the distro's 
+# preferred linker.
 EXTRA_OECONF = "--with-local-prefix=${STAGING_DIR_TARGET}${target_prefix} \
 		--enable-shared \
 		--disable-multilib \
@@ -17,7 +21,8 @@  EXTRA_OECONF = "--with-local-prefix=${STAGING_DIR_TARGET}${target_prefix} \
 		--with-sysroot=${STAGING_DIR_TCBOOTSTRAP} \
 		--with-build-sysroot=${STAGING_DIR_TCBOOTSTRAP} \
 		${EXTRA_OECONF_INTERMEDIATE} \
-		${@get_gcc_fpu_setting(bb, d)}"
+		${@get_gcc_fpu_setting(bb, d)} \
+		${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--with-ld=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}ld.bfd', '', d)}"
 
 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}"