Patchwork [07/10] external-csl-toolchain: support mips/ppc/arm

login
register
mail settings
Submitter Christopher Larson
Date Jan. 27, 2012, 5:13 p.m.
Message ID <08cc6aa12fba6bcdb28c68edf3fe2e32dd5f52ca.1327684024.git.chris_larson@mentor.com>
Download mbox | patch
Permalink /patch/20251/
State Accepted
Commit a37298eb3421a44e88ec5a66b2fc5305ab18f453
Headers show

Comments

Christopher Larson - Jan. 27, 2012, 5:13 p.m.
From: Christopher Larson <chris_larson@mentor.com>

- Rather than adjusting TARGET_VENDOR, which results in our TARGET_SYS
  matching the external toolchain, override TARGET_PREFIX to match external,
  and leave TARGET_SYS alone
- Grab the optimized files out of the toolchain if available
- Create a symlink in sysroot to ensure the sysroot layout matches toolchain
  expectations (optimized files in a subdir)

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/conf/distro/include/tcmode-external-csl.inc |   27 +++++++++++++++++-
 meta/recipes-core/meta/external-csl-toolchain.bb |   32 +++++++++++++++++-----
 2 files changed, 50 insertions(+), 9 deletions(-)
Khem Raj - Jan. 28, 2012, 8:28 p.m.
On (27/01/12 11:13), Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
> 
> - Rather than adjusting TARGET_VENDOR, which results in our TARGET_SYS
>   matching the external toolchain, override TARGET_PREFIX to match external,
>   and leave TARGET_SYS alone
> - Grab the optimized files out of the toolchain if available
> - Create a symlink in sysroot to ensure the sysroot layout matches toolchain
>   expectations (optimized files in a subdir)
> 
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
>  meta/conf/distro/include/tcmode-external-csl.inc |   27 +++++++++++++++++-
>  meta/recipes-core/meta/external-csl-toolchain.bb |   32 +++++++++++++++++-----
>  2 files changed, 50 insertions(+), 9 deletions(-)
> 
> diff --git a/meta/conf/distro/include/tcmode-external-csl.inc b/meta/conf/distro/include/tcmode-external-csl.inc
> index 0af3a45..1d82ca1 100644
> --- a/meta/conf/distro/include/tcmode-external-csl.inc
> +++ b/meta/conf/distro/include/tcmode-external-csl.inc
> @@ -2,12 +2,20 @@
>  # Configuration to use external CSL toolchain
>  #
>  
> -TARGET_VENDOR = "-none"
> -
>  EXTERNAL_TOOLCHAIN ?= "/usr/local/csl/${TARGET_ARCH}"
>  
>  PATH =. "${EXTERNAL_TOOLCHAIN}/bin:"
>  
> +CSL_TARGET_SYS_powerpc = "powerpc-linux-gnu"
> +CSL_TARGET_SYS_powerpc64 = "powerpc-linux-gnu"

hmm is it using powerpc-linux-gnu canonical name to do both ppc32
and ppc64

> +CSL_TARGET_SYS_arm = "arm-none-linux-gnueabi"
> +CSL_TARGET_SYS_mips = "mips-linux-gnu"
> +CSL_TARGET_SYS_mipsel = "mips-linux-gnu"


> +CSL_TARGET_SYS_mips64 = "mips-linux-gnu"

same as above

> +CSL_TARGET_SYS = "${TARGET_SYS}"
> +
> +TARGET_PREFIX = "${CSL_TARGET_SYS}-"
> +
>  PREFERRED_PROVIDER_linux-libc-headers = "external-csl-toolchain"
>  PREFERRED_PROVIDER_linux-libc-headers-dev = "external-csl-toolchain"
>  PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-csl-toolchain"
> @@ -28,3 +36,18 @@ TARGET_CPPFLAGS_prepend = " -isystem${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/include
>  TARGET_LDFLAGS_prepend = " -L${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/lib -Wl,-rpath-link,${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/lib "
>  
>  TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}"
> +
> +# Translate to CodeSourcery's names for their optimized files in the toolchain
> +def csl_target_core(d):
> +    coredata = {
> +        'armv7a-vfp-neon': 'armv7-a-neon',
> +        'mips': 'mips32',
> +        'mipsel': 'el',
> +        'ppce500': 'te500v1',
> +        'ppce500mc': 'te500mc',
> +        'ppce500v2': 'te500v2',
> +        'ppce600': 'te600'
> +    }
> +    return coredata.get(d.getVar('TUNE_PKGARCH', True), '')
> +
> +CSL_TARGET_CORE = "${@csl_target_core(d)}"
> diff --git a/meta/recipes-core/meta/external-csl-toolchain.bb b/meta/recipes-core/meta/external-csl-toolchain.bb
> index f1e5332..37ea271 100644
> --- a/meta/recipes-core/meta/external-csl-toolchain.bb
> +++ b/meta/recipes-core/meta/external-csl-toolchain.bb
> @@ -25,25 +25,43 @@ PROVIDES = "\
>  	virtual/linux-libc-headers "
>  RPROVIDES = "glibc-utils libsegfault glibc-thread-db"
>  PACKAGES_DYNAMIC = "glibc-gconv-*"
> -PR = "r2"
> +PR = "r3"
>  
> -#SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2"
> +#SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${CSL_TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2"
>  
>  SRC_URI = "file://SUPPORTED"
>  
>  do_install() {
>  	install -d ${D}${sysconfdir} ${D}${bindir} ${D}${sbindir} ${D}${base_bindir} ${D}${libdir}
> -	install -d ${D}${base_libdir} ${D}${base_sbindir} ${D}${datadir}
> +	install -d ${D}${base_libdir} ${D}${base_sbindir} ${D}${datadir} ${D}/usr
>  
> -	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/lib/*  ${D}${base_libdir}
> -	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/etc/*  ${D}${sysconfdir}
> -	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/sbin/* ${D}${base_sbindir}
> -	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/usr/*  ${D}/usr
> +	if [ -d ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE} ]; then
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/lib/.  ${D}${base_libdir}
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/etc/.  ${D}${sysconfdir}
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/sbin/. ${D}${base_sbindir}
> +		if [ ! -e ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/usr/include ]; then
> +			cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/usr/include  ${D}/usr/
> +		fi
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/usr/.  ${D}/usr/
> +	else
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/lib/.  ${D}${base_libdir}
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/etc/.  ${D}${sysconfdir}
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/sbin/. ${D}${base_sbindir}
> +		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/usr/.  ${D}/usr/
> +	fi
>  
>  	sed -i -e "s# /lib# ../../lib#g" -e "s# /usr/lib# .#g" ${D}${libdir}/libc.so
>  	sed -i -e "s# /lib# ../../lib#g" -e "s# /usr/lib# .#g" ${D}${libdir}/libpthread.so
>  }
>  
> +SYSROOT_PREPROCESS_FUNCS += "external_toolchain_sysroot_adjust"
> +external_toolchain_sysroot_adjust() {
> +       if [ -n "${CSL_TARGET_CORE}" ]; then
> +               rm -f ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
> +               ln -s . ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
> +       fi
> +}
> +
>  GLIBC_INTERNAL_USE_BINARY_LOCALE ?= "compile"
>  
>  PACKAGES += "libgcc libgcc-dev libstdc++ libstdc++-dev linux-libc-headers linux-libc-headers-dev"
> -- 
> 1.7.8.rc4
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Chris Larson - Feb. 2, 2012, 6:27 p.m.
On Sat, Jan 28, 2012 at 1:28 PM, Khem Raj <raj.khem@gmail.com> wrote:
> hmm is it using powerpc-linux-gnu canonical name to do both ppc32
> and ppc64
>
>> +CSL_TARGET_SYS_arm = "arm-none-linux-gnueabi"
>> +CSL_TARGET_SYS_mips = "mips-linux-gnu"
>> +CSL_TARGET_SYS_mipsel = "mips-linux-gnu"
>
>
>> +CSL_TARGET_SYS_mips64 = "mips-linux-gnu"
>
> same as above

Yeah, from what I can tell it's handled via -m32/-m64, not via the prefix.

Patch

diff --git a/meta/conf/distro/include/tcmode-external-csl.inc b/meta/conf/distro/include/tcmode-external-csl.inc
index 0af3a45..1d82ca1 100644
--- a/meta/conf/distro/include/tcmode-external-csl.inc
+++ b/meta/conf/distro/include/tcmode-external-csl.inc
@@ -2,12 +2,20 @@ 
 # Configuration to use external CSL toolchain
 #
 
-TARGET_VENDOR = "-none"
-
 EXTERNAL_TOOLCHAIN ?= "/usr/local/csl/${TARGET_ARCH}"
 
 PATH =. "${EXTERNAL_TOOLCHAIN}/bin:"
 
+CSL_TARGET_SYS_powerpc = "powerpc-linux-gnu"
+CSL_TARGET_SYS_powerpc64 = "powerpc-linux-gnu"
+CSL_TARGET_SYS_arm = "arm-none-linux-gnueabi"
+CSL_TARGET_SYS_mips = "mips-linux-gnu"
+CSL_TARGET_SYS_mipsel = "mips-linux-gnu"
+CSL_TARGET_SYS_mips64 = "mips-linux-gnu"
+CSL_TARGET_SYS = "${TARGET_SYS}"
+
+TARGET_PREFIX = "${CSL_TARGET_SYS}-"
+
 PREFERRED_PROVIDER_linux-libc-headers = "external-csl-toolchain"
 PREFERRED_PROVIDER_linux-libc-headers-dev = "external-csl-toolchain"
 PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-csl-toolchain"
@@ -28,3 +36,18 @@  TARGET_CPPFLAGS_prepend = " -isystem${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/include
 TARGET_LDFLAGS_prepend = " -L${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/lib -Wl,-rpath-link,${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/lib "
 
 TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}"
+
+# Translate to CodeSourcery's names for their optimized files in the toolchain
+def csl_target_core(d):
+    coredata = {
+        'armv7a-vfp-neon': 'armv7-a-neon',
+        'mips': 'mips32',
+        'mipsel': 'el',
+        'ppce500': 'te500v1',
+        'ppce500mc': 'te500mc',
+        'ppce500v2': 'te500v2',
+        'ppce600': 'te600'
+    }
+    return coredata.get(d.getVar('TUNE_PKGARCH', True), '')
+
+CSL_TARGET_CORE = "${@csl_target_core(d)}"
diff --git a/meta/recipes-core/meta/external-csl-toolchain.bb b/meta/recipes-core/meta/external-csl-toolchain.bb
index f1e5332..37ea271 100644
--- a/meta/recipes-core/meta/external-csl-toolchain.bb
+++ b/meta/recipes-core/meta/external-csl-toolchain.bb
@@ -25,25 +25,43 @@  PROVIDES = "\
 	virtual/linux-libc-headers "
 RPROVIDES = "glibc-utils libsegfault glibc-thread-db"
 PACKAGES_DYNAMIC = "glibc-gconv-*"
-PR = "r2"
+PR = "r3"
 
-#SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2"
+#SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${CSL_TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2"
 
 SRC_URI = "file://SUPPORTED"
 
 do_install() {
 	install -d ${D}${sysconfdir} ${D}${bindir} ${D}${sbindir} ${D}${base_bindir} ${D}${libdir}
-	install -d ${D}${base_libdir} ${D}${base_sbindir} ${D}${datadir}
+	install -d ${D}${base_libdir} ${D}${base_sbindir} ${D}${datadir} ${D}/usr
 
-	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/lib/*  ${D}${base_libdir}
-	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/etc/*  ${D}${sysconfdir}
-	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/sbin/* ${D}${base_sbindir}
-	cp -a ${EXTERNAL_TOOLCHAIN}/${TARGET_SYS}/libc/usr/*  ${D}/usr
+	if [ -d ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE} ]; then
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/lib/.  ${D}${base_libdir}
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/etc/.  ${D}${sysconfdir}
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/sbin/. ${D}${base_sbindir}
+		if [ ! -e ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/usr/include ]; then
+			cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/usr/include  ${D}/usr/
+		fi
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/${CSL_TARGET_CORE}/usr/.  ${D}/usr/
+	else
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/lib/.  ${D}${base_libdir}
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/etc/.  ${D}${sysconfdir}
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/sbin/. ${D}${base_sbindir}
+		cp -a ${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc/usr/.  ${D}/usr/
+	fi
 
 	sed -i -e "s# /lib# ../../lib#g" -e "s# /usr/lib# .#g" ${D}${libdir}/libc.so
 	sed -i -e "s# /lib# ../../lib#g" -e "s# /usr/lib# .#g" ${D}${libdir}/libpthread.so
 }
 
+SYSROOT_PREPROCESS_FUNCS += "external_toolchain_sysroot_adjust"
+external_toolchain_sysroot_adjust() {
+       if [ -n "${CSL_TARGET_CORE}" ]; then
+               rm -f ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
+               ln -s . ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
+       fi
+}
+
 GLIBC_INTERNAL_USE_BINARY_LOCALE ?= "compile"
 
 PACKAGES += "libgcc libgcc-dev libstdc++ libstdc++-dev linux-libc-headers linux-libc-headers-dev"