[08/10] external-csl-toolchain: support ia32

Submitted by Christopher Larson on Jan. 27, 2012, 5:13 p.m.

Details

Message ID 11a449c2659341f946915682c39d04a6e4a43d1a.1327684024.git.chris_larson@mentor.com
State Accepted
Commit c924d878b55cce7a0e98dc60acf706b5a1b4f404
Headers show

Commit Message

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

Unfortunately, the CSL ia32 toolchain has non-prefixed binaries in its bindir
(e.g. gcc, ld). To avoid this messing up our build, we avoid adding this
bindir to our PATH, and instead add symlinks to the prefixed binaries to our
staging toolchain bindir.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/conf/distro/include/tcmode-external-csl.inc |   59 +++++++++++++++++++++-
 meta/recipes-core/meta/external-csl-toolchain.bb |    5 ++
 2 files changed, 63 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/conf/distro/include/tcmode-external-csl.inc b/meta/conf/distro/include/tcmode-external-csl.inc
index 1d82ca1..0135590 100644
--- a/meta/conf/distro/include/tcmode-external-csl.inc
+++ b/meta/conf/distro/include/tcmode-external-csl.inc
@@ -4,7 +4,8 @@ 
 
 EXTERNAL_TOOLCHAIN ?= "/usr/local/csl/${TARGET_ARCH}"
 
-PATH =. "${EXTERNAL_TOOLCHAIN}/bin:"
+TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:"
+PATH =. "${TOOLCHAIN_PATH_ADD}"
 
 CSL_TARGET_SYS_powerpc = "powerpc-linux-gnu"
 CSL_TARGET_SYS_powerpc64 = "powerpc-linux-gnu"
@@ -12,6 +13,8 @@  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_i686 = "i686-pc-linux-gnu"
+CSL_TARGET_SYS_i586 = "i686-pc-linux-gnu"
 CSL_TARGET_SYS = "${TARGET_SYS}"
 
 TARGET_PREFIX = "${CSL_TARGET_SYS}-"
@@ -41,6 +44,8 @@  TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}"
 def csl_target_core(d):
     coredata = {
         'armv7a-vfp-neon': 'armv7-a-neon',
+        'i586': 'sgxx-glibc',
+        'i686': 'sgxx-glibc',
         'mips': 'mips32',
         'mipsel': 'el',
         'ppce500': 'te500v1',
@@ -51,3 +56,55 @@  def csl_target_core(d):
     return coredata.get(d.getVar('TUNE_PKGARCH', True), '')
 
 CSL_TARGET_CORE = "${@csl_target_core(d)}"
+
+# Unfortunately, the CSL ia32 toolchain has non-prefixed binaries in its
+# bindir (e.g. gcc, ld). To avoid this messing up our build, we avoid adding
+# this bindir to our PATH, and instead add symlinks to the prefixed binaries
+# to our staging toolchain bindir.
+
+python toolchain_metadata_setup () {
+    if not isinstance(e, bb.event.ConfigParsed):
+        return
+
+    d = e.data
+
+    if d.getVar('TUNE_PKGARCH', True) in ('i586', 'i686'):
+        d.setVar('TOOLCHAIN_PATH_ADD', '')
+}
+addhandler toolchain_metadata_setup
+
+python toolchain_setup () {
+    if not isinstance(e, bb.event.BuildStarted):
+        return
+
+    d = e.data
+
+    if d.getVar('TUNE_PKGARCH', True) in ('i586', 'i686'):
+        populate_toolchain_links(d)
+}
+addhandler toolchain_setup
+
+def populate_toolchain_links(d):
+    import errno
+    import os
+    from glob import glob
+
+    d = d.createCopy()
+    d.finalize()
+
+    pattern = bb.data.expand('${EXTERNAL_TOOLCHAIN}/bin/${TARGET_PREFIX}*', d)
+    files = glob(pattern)
+    if not files:
+        bb.fatal("Unable to populate toolchain binary symlinks")
+
+    bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True)
+    bb.mkdirhier(bindir)
+    for f in files:
+        base = os.path.basename(f)
+        newpath = os.path.join(bindir, base)
+        try:
+            os.symlink(f, newpath)
+        except OSError as exc:
+            if exc.errno == errno.EEXIST:
+                break
+            bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc))
diff --git a/meta/recipes-core/meta/external-csl-toolchain.bb b/meta/recipes-core/meta/external-csl-toolchain.bb
index 37ea271..a866e3e 100644
--- a/meta/recipes-core/meta/external-csl-toolchain.bb
+++ b/meta/recipes-core/meta/external-csl-toolchain.bb
@@ -60,6 +60,11 @@  external_toolchain_sysroot_adjust() {
                rm -f ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
                ln -s . ${SYSROOT_DESTDIR}/${CSL_TARGET_CORE}
        fi
+
+       if [ "${TUNE_PKGARCH}" = "i586" ]; then
+               rm -f ${SYSROOT_DESTDIR}/system32
+               ln -s . ${SYSROOT_DESTDIR}/system32
+       fi
 }
 
 GLIBC_INTERNAL_USE_BINARY_LOCALE ?= "compile"