Patchwork [v2] Introduce multiarch DISTRO_FEATURE

login
register
mail settings
Submitter Julian Pidancet
Date Nov. 16, 2011, 1:01 a.m.
Message ID <689a6fbace429988bf14f144e9a93dc828a7e7bf.1321391467.git.julian.pidancet@gmail.com>
Download mbox | patch
Permalink /patch/15023/
State Accepted
Commit 99e295ef30ba02db3966c66619807c037ef5089f
Headers show

Comments

Julian Pidancet - Nov. 16, 2011, 1:01 a.m.
This patch introduces a distro feature which enables gcc to produce
both 32bit and 64bit code, and enables binutils to operate on both
32bit and 64bit binaries. It differs from multilib toolchains in
that it does not require to compile a version of the libc for each
architecture variant. However, the code produced for the secondary
architecture will not be linkable against the libc.

v2: - Renamed the feature name from "biarch" to "multiarch". The GCC
installation manual claims that the mips-linux can be made a tri-arch
compiler (http://gcc.gnu.org/install/configure.html)
    - For x86_64, the compiler is made bi-arch by default, so nothing
has to be done in particular.
    - I analyzed the gcc/config.gcc from GCC sources and added in this
patch all the architectures that could be made biarch with the version
of gcc currently used in OE, which are powerpc, and sparc, in addition
to x86. mips and s390 will probably be supported in future versions of
gcc. For x86 and sparc, only the --enable-targets=all option is valid
to make this work (this option doesn't have any other side effects than
making the compiler bi-arch). For powerpc, I used the
--enable-targets=powerpc64 option (although 'all' also works).

Note: - Untested on powerpc and sparc. But I believe it works the same
as with x86.
      - gcc in meta-toolchain is also made multiarch.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
---
 meta/recipes-devtools/binutils/binutils-cross.inc  |    3 ++-
 meta/recipes-devtools/binutils/binutils.inc        |    3 ++-
 meta/recipes-devtools/gcc/gcc-common.inc           |   10 ++++++++++
 meta/recipes-devtools/gcc/gcc-configure-common.inc |    3 ++-
 4 files changed, 16 insertions(+), 3 deletions(-)
Julian Pidancet - Nov. 23, 2011, 4:39 p.m.
On Wed, Nov 16, 2011 at 1:01 AM, Julian Pidancet
<julian.pidancet@gmail.com> wrote:
> This patch introduces a distro feature which enables gcc to produce
> both 32bit and 64bit code, and enables binutils to operate on both
> 32bit and 64bit binaries. It differs from multilib toolchains in
> that it does not require to compile a version of the libc for each
> architecture variant. However, the code produced for the secondary
> architecture will not be linkable against the libc.
>
> v2: - Renamed the feature name from "biarch" to "multiarch". The GCC
> installation manual claims that the mips-linux can be made a tri-arch
> compiler (http://gcc.gnu.org/install/configure.html)
>    - For x86_64, the compiler is made bi-arch by default, so nothing
> has to be done in particular.
>    - I analyzed the gcc/config.gcc from GCC sources and added in this
> patch all the architectures that could be made biarch with the version
> of gcc currently used in OE, which are powerpc, and sparc, in addition
> to x86. mips and s390 will probably be supported in future versions of
> gcc. For x86 and sparc, only the --enable-targets=all option is valid
> to make this work (this option doesn't have any other side effects than
> making the compiler bi-arch). For powerpc, I used the
> --enable-targets=powerpc64 option (although 'all' also works).
>
> Note: - Untested on powerpc and sparc. But I believe it works the same
> as with x86.
>      - gcc in meta-toolchain is also made multiarch.
>

Anybody got the time to review this ?
Richard Purdie - Nov. 23, 2011, 4:47 p.m.
On Wed, 2011-11-23 at 16:39 +0000, Julian Pidancet wrote:
> On Wed, Nov 16, 2011 at 1:01 AM, Julian Pidancet
> <julian.pidancet@gmail.com> wrote:
> > This patch introduces a distro feature which enables gcc to produce
> > both 32bit and 64bit code, and enables binutils to operate on both
> > 32bit and 64bit binaries. It differs from multilib toolchains in
> > that it does not require to compile a version of the libc for each
> > architecture variant. However, the code produced for the secondary
> > architecture will not be linkable against the libc.
> >
> > v2: - Renamed the feature name from "biarch" to "multiarch". The GCC
> > installation manual claims that the mips-linux can be made a tri-arch
> > compiler (http://gcc.gnu.org/install/configure.html)
> >    - For x86_64, the compiler is made bi-arch by default, so nothing
> > has to be done in particular.
> >    - I analyzed the gcc/config.gcc from GCC sources and added in this
> > patch all the architectures that could be made biarch with the version
> > of gcc currently used in OE, which are powerpc, and sparc, in addition
> > to x86. mips and s390 will probably be supported in future versions of
> > gcc. For x86 and sparc, only the --enable-targets=all option is valid
> > to make this work (this option doesn't have any other side effects than
> > making the compiler bi-arch). For powerpc, I used the
> > --enable-targets=powerpc64 option (although 'all' also works).
> >
> > Note: - Untested on powerpc and sparc. But I believe it works the same
> > as with x86.
> >      - gcc in meta-toolchain is also made multiarch.
> >
> 
> Anybody got the time to review this ?

Funnily enough I was just talking with Saul about this. We're going to
try and expose this to some extended testing (which we try and do for
all compiler changes).

Cheers,

Richard
Julian Pidancet - Nov. 23, 2011, 5:28 p.m.
On Wed, Nov 23, 2011 at 4:47 PM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Wed, 2011-11-23 at 16:39 +0000, Julian Pidancet wrote:
>> On Wed, Nov 16, 2011 at 1:01 AM, Julian Pidancet
>> <julian.pidancet@gmail.com> wrote:
>> > This patch introduces a distro feature which enables gcc to produce
>> > both 32bit and 64bit code, and enables binutils to operate on both
>> > 32bit and 64bit binaries. It differs from multilib toolchains in
>> > that it does not require to compile a version of the libc for each
>> > architecture variant. However, the code produced for the secondary
>> > architecture will not be linkable against the libc.
>> >
>> > v2: - Renamed the feature name from "biarch" to "multiarch". The GCC
>> > installation manual claims that the mips-linux can be made a tri-arch
>> > compiler (http://gcc.gnu.org/install/configure.html)
>> >    - For x86_64, the compiler is made bi-arch by default, so nothing
>> > has to be done in particular.
>> >    - I analyzed the gcc/config.gcc from GCC sources and added in this
>> > patch all the architectures that could be made biarch with the version
>> > of gcc currently used in OE, which are powerpc, and sparc, in addition
>> > to x86. mips and s390 will probably be supported in future versions of
>> > gcc. For x86 and sparc, only the --enable-targets=all option is valid
>> > to make this work (this option doesn't have any other side effects than
>> > making the compiler bi-arch). For powerpc, I used the
>> > --enable-targets=powerpc64 option (although 'all' also works).
>> >
>> > Note: - Untested on powerpc and sparc. But I believe it works the same
>> > as with x86.
>> >      - gcc in meta-toolchain is also made multiarch.
>> >
>>
>> Anybody got the time to review this ?
>
> Funnily enough I was just talking with Saul about this. We're going to
> try and expose this to some extended testing (which we try and do for
> all compiler changes).
>

That's good news. In the mean-time, if there is any additional testing
you'd like me to perform, feel free to ask.
Khem Raj - Nov. 24, 2011, 3:32 a.m.
On Tue, Nov 15, 2011 at 5:01 PM, Julian Pidancet
<julian.pidancet@gmail.com> wrote:
> This patch introduces a distro feature which enables gcc to produce
> both 32bit and 64bit code, and enables binutils to operate on both
> 32bit and 64bit binaries. It differs from multilib toolchains in
> that it does not require to compile a version of the libc for each
> architecture variant. However, the code produced for the secondary
> architecture will not be linkable against the libc.
>
> v2: - Renamed the feature name from "biarch" to "multiarch". The GCC
> installation manual claims that the mips-linux can be made a tri-arch
> compiler (http://gcc.gnu.org/install/configure.html)
>    - For x86_64, the compiler is made bi-arch by default, so nothing
> has to be done in particular.
>    - I analyzed the gcc/config.gcc from GCC sources and added in this
> patch all the architectures that could be made biarch with the version
> of gcc currently used in OE, which are powerpc, and sparc, in addition
> to x86. mips and s390 will probably be supported in future versions of
> gcc. For x86 and sparc, only the --enable-targets=all option is valid
> to make this work (this option doesn't have any other side effects than
> making the compiler bi-arch). For powerpc, I used the
> --enable-targets=powerpc64 option (although 'all' also works).
>
> Note: - Untested on powerpc and sparc. But I believe it works the same
> as with x86.
>      - gcc in meta-toolchain is also made multiarch.
>
> Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
> ---
>  meta/recipes-devtools/binutils/binutils-cross.inc  |    3 ++-
>  meta/recipes-devtools/binutils/binutils.inc        |    3 ++-
>  meta/recipes-devtools/gcc/gcc-common.inc           |   10 ++++++++++
>  meta/recipes-devtools/gcc/gcc-configure-common.inc |    3 ++-
>  4 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-devtools/binutils/binutils-cross.inc b/meta/recipes-devtools/binutils/binutils-cross.inc
> index 982224f..f07907e 100644
> --- a/meta/recipes-devtools/binutils/binutils-cross.inc
> +++ b/meta/recipes-devtools/binutils/binutils-cross.inc
> @@ -10,7 +10,8 @@ EXTRA_OECONF = "--with-sysroot=${STAGING_DIR_TARGET} \
>                 --disable-werror \
>                 --disable-nls \
>                 --enable-poison-system-directories \
> -               ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default', '', d)}"
> +                ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default', '', d)} \
> +                ${@base_contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
>
>  do_install () {
>        oe_runmake 'DESTDIR=${D}' install
> diff --git a/meta/recipes-devtools/binutils/binutils.inc b/meta/recipes-devtools/binutils/binutils.inc
> index 58fee85..51e4257 100644
> --- a/meta/recipes-devtools/binutils/binutils.inc
> +++ b/meta/recipes-devtools/binutils/binutils.inc
> @@ -49,7 +49,8 @@ B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
>
>  EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
>                 --enable-install-libbfd \
> -                --enable-shared"
> +                --enable-shared \
> +                ${@base_contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
>
>  EXTRA_OECONF_virtclass-native = "--enable-target=all --enable-64-bit-bfd --enable-install-libbfd"
>
> diff --git a/meta/recipes-devtools/gcc/gcc-common.inc b/meta/recipes-devtools/gcc/gcc-common.inc
> index 69e0213..7ec2f7e 100644
> --- a/meta/recipes-devtools/gcc/gcc-common.inc
> +++ b/meta/recipes-devtools/gcc/gcc-common.inc
> @@ -21,6 +21,16 @@ def get_gcc_mips_plt_setting(bb, d):
>         return "--with-mips-plt"
>     return ""
>
> +def get_gcc_multiarch_setting(bb, d):
> +    if 'multiarch' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'i586', 'i686' ] :
> +            return "--enable-targets=all"
> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'powerpc' ] :
> +            return "--enable-targets=powerpc64"
> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'sparc' ] :
> +            return "--enable-targets=all"
> +    return ""


you forgot mips here

> +
>  # We really need HOST_SYS here for some packages and TARGET_SYS for others.
>  # For now, libgcc is most important so we fix for that - RP.
>  SHLIBSDIR = "${STAGING_DIR_TARGET}/shlibs"
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> index ae23e8e..d014980 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> @@ -42,7 +42,8 @@ EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', 1) != 'n
>                 ${EXTRA_OECONF_BASE} \
>                 ${EXTRA_OECONF_FPU} \
>                 ${EXTRA_OECONF_PATHS} \
> -                ${@get_gcc_mips_plt_setting(bb, d)}"
> +                ${@get_gcc_mips_plt_setting(bb, d)} \
> +                ${@get_gcc_multiarch_setting(bb, d)}"
>
>  # Build uclibc compilers without cxa_atexit support
>  EXTRA_OECONF_append_linux               = " --enable-__cxa_atexit"
> --
> Julian Pidancet
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
Julian Pidancet - Nov. 24, 2011, 12:44 p.m.
>> +def get_gcc_multiarch_setting(bb, d):
>> +    if 'multiarch' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
>> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'i586', 'i686' ] :
>> +            return "--enable-targets=all"
>> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'powerpc' ] :
>> +            return "--enable-targets=powerpc64"
>> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'sparc' ] :
>> +            return "--enable-targets=all"
>> +    return ""
>
>
> you forgot mips here
>

mips and s390 are not yet supported in the gcc version that OE is using.
Khem Raj - Nov. 24, 2011, 5:36 p.m.
On (24/11/11 12:44), Julian Pidancet wrote:
> >> +def get_gcc_multiarch_setting(bb, d):
> >> +    if 'multiarch' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
> >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'i586', 'i686' ] :
> >> +            return "--enable-targets=all"
> >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'powerpc' ] :
> >> +            return "--enable-targets=powerpc64"
> >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'sparc' ] :
> >> +            return "--enable-targets=all"
> >> +    return ""

looking at above function can this be made into a single if statement
instead of 3

and we also need multiarch support in gdb recipes as well.

> >
> >
> > you forgot mips here
> >
> 
> mips and s390 are not yet supported in the gcc version that OE is using.

yes right forgot about that it will be in 4.7
> 
> -- 
> Julian
Richard Purdie - Nov. 24, 2011, 5:51 p.m.
On Thu, 2011-11-24 at 09:36 -0800, Khem Raj wrote:
> On (24/11/11 12:44), Julian Pidancet wrote:
> > >> +def get_gcc_multiarch_setting(bb, d):
> > >> +    if 'multiarch' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
> > >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'i586', 'i686' ] :
> > >> +            return "--enable-targets=all"
> > >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'powerpc' ] :
> > >> +            return "--enable-targets=powerpc64"
> > >> +        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'sparc' ] :
> > >> +            return "--enable-targets=all"
> > >> +    return ""
> 
> looking at above function can this be made into a single if statement
> instead of 3

Julian: Could you update this to use the syntax d.getVar instead of
bb.data.getVar(..., d) please? We recently did a fairly big cleanup of
these and I'd rather not see it creep back in! We also prefer "True"
instead of "1" although we've not done a big cleanup on that yet (its
planned).

As Khem mentioned, we can probably get this down to a couple of getVar
calls instead of the above too!

Cheers,

Richard
Julian Pidancet - Nov. 24, 2011, 10:38 p.m.
On Thu, Nov 24, 2011 at 5:36 PM, Khem Raj <raj.khem@gmail.com> wrote:
>
> and we also need multiarch support in gdb recipes as well.
>

Support for Biarch exists in gdb for x86 since May 2009, and it is
enabled by default as far as I can tell.
I managed to dig up the exact commit in the gdb sources:
http://sourceware.org/git/?p=gdb.git;a=commit;h=5d008094095c4a6f5ccc522abac263d6bc52738b

Regarding powerpc, it seems that gdb can only be made biarch when
configured for a powerpc64 machine.

Patch

diff --git a/meta/recipes-devtools/binutils/binutils-cross.inc b/meta/recipes-devtools/binutils/binutils-cross.inc
index 982224f..f07907e 100644
--- a/meta/recipes-devtools/binutils/binutils-cross.inc
+++ b/meta/recipes-devtools/binutils/binutils-cross.inc
@@ -10,7 +10,8 @@  EXTRA_OECONF = "--with-sysroot=${STAGING_DIR_TARGET} \
                 --disable-werror \
                 --disable-nls \
                 --enable-poison-system-directories \
-		${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default', '', d)}"
+                ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default', '', d)} \
+                ${@base_contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
 
 do_install () {
 	oe_runmake 'DESTDIR=${D}' install
diff --git a/meta/recipes-devtools/binutils/binutils.inc b/meta/recipes-devtools/binutils/binutils.inc
index 58fee85..51e4257 100644
--- a/meta/recipes-devtools/binutils/binutils.inc
+++ b/meta/recipes-devtools/binutils/binutils.inc
@@ -49,7 +49,8 @@  B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
 
 EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
                 --enable-install-libbfd \
-                --enable-shared"
+                --enable-shared \
+                ${@base_contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
 
 EXTRA_OECONF_virtclass-native = "--enable-target=all --enable-64-bit-bfd --enable-install-libbfd"
 
diff --git a/meta/recipes-devtools/gcc/gcc-common.inc b/meta/recipes-devtools/gcc/gcc-common.inc
index 69e0213..7ec2f7e 100644
--- a/meta/recipes-devtools/gcc/gcc-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-common.inc
@@ -21,6 +21,16 @@  def get_gcc_mips_plt_setting(bb, d):
         return "--with-mips-plt"
     return ""
 
+def get_gcc_multiarch_setting(bb, d):
+    if 'multiarch' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
+        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'i586', 'i686' ] :
+            return "--enable-targets=all"
+        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'powerpc' ] :
+            return "--enable-targets=powerpc64"
+        if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'sparc' ] :
+            return "--enable-targets=all"
+    return ""
+
 # We really need HOST_SYS here for some packages and TARGET_SYS for others.
 # For now, libgcc is most important so we fix for that - RP.
 SHLIBSDIR = "${STAGING_DIR_TARGET}/shlibs"
diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
index ae23e8e..d014980 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
@@ -42,7 +42,8 @@  EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', 1) != 'n
                 ${EXTRA_OECONF_BASE} \
                 ${EXTRA_OECONF_FPU} \
                 ${EXTRA_OECONF_PATHS} \
-                ${@get_gcc_mips_plt_setting(bb, d)}"
+                ${@get_gcc_mips_plt_setting(bb, d)} \
+                ${@get_gcc_multiarch_setting(bb, d)}"
 
 # Build uclibc compilers without cxa_atexit support
 EXTRA_OECONF_append_linux               = " --enable-__cxa_atexit"