aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Rossi <nathan.rossi@xilinx.com>2013-09-20 17:57:51 +1000
committerNathan Rossi <nathan.rossi@xilinx.com>2013-09-23 10:42:34 +1000
commitcf9571203be0af5fc654952d3f00e0a7e0fb1174 (patch)
tree8e8fadd90b3f32f5b198be757fbad5f467cb5962
parent4204ea87969a5f7e000abd0d91a56d8e6db2ac61 (diff)
downloadmeta-xilinx-dylan.tar.gz
meta-xilinx-dylan.tar.bz2
meta-xilinx-dylan.zip
external-xilinx-toochain: Created recipedylan
* Allows use of external Xilinx MicroBlaze and Zynq pre-built toolchains * Does not require additional layer dependencies * Backported from master Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
-rw-r--r--conf/distro/include/tcmode-external-xilinx.inc79
-rw-r--r--conf/distro/include/xilinx-versions.inc108
-rw-r--r--recipes-core/meta/external-xilinx-toolchain.bb155
-rw-r--r--recipes-core/meta/external-xilinx-toolchain/SUPPORTED0
4 files changed, 342 insertions, 0 deletions
diff --git a/conf/distro/include/tcmode-external-xilinx.inc b/conf/distro/include/tcmode-external-xilinx.inc
new file mode 100644
index 00000000..6859f8f9
--- /dev/null
+++ b/conf/distro/include/tcmode-external-xilinx.inc
@@ -0,0 +1,79 @@
+#
+# Configuration to use external Xilinx toolchain
+#
+
+TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:"
+PATH =. "${TOOLCHAIN_PATH_ADD}"
+
+CSL_TARGET_SYS_armv7a ?= "arm-xilinx-linux-gnueabi"
+CSL_TARGET_SYS_microblazeel ?= "microblazeel-xilinx-linux-gnu"
+CSL_TARGET_SYS = "${TARGET_SYS}"
+
+TARGET_PREFIX = "${CSL_TARGET_SYS}-"
+
+PREFERRED_PROVIDER_linux-libc-headers = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_linux-libc-headers-dev = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-intermediate = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-initial = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_libgcc = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_eglibc = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/libc = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/libintl = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/libiconv = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_glibc-thread-db = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_virtual/linux-libc-headers-dev = "external-xilinx-toolchain"
+PREFERRED_PROVIDER_gdbserver ?= "external-xilinx-toolchain"
+
+# No need to re-compile the locale files
+GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled"
+ENABLE_BINARY_LOCALE_GENERATION = ""
+
+TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}"
+
+# Default sysroot is inside the Xilinx ARM v7-A toolchain in the '<CSL_TARGET_SYS>/libc' (no debug-root)
+EXTERNAL_TOOLCHAIN_SYSROOT_armv7a ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc"
+EXTERNAL_TOOLCHAIN_DBGROOT_armv7a ?= ""
+
+# Default sysroot is inside the Xilinx MicroBlaze toolchain in the '<CSL_TARGET_SYS>/sys-root'
+EXTERNAL_TOOLCHAIN_SYSROOT_microblaze ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/sys-root"
+EXTERNAL_TOOLCHAIN_DBGROOT_microblaze ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/debug-root"
+
+addhandler toolchain_setup
+python toolchain_setup () {
+ if not isinstance(e, bb.event.BuildStarted):
+ return
+ import errno
+
+ d = e.data
+ d = d.createCopy()
+ d.finalize()
+
+ tarprefix = d.expand('${TARGET_PREFIX}')
+ files = []
+ if tarprefix == "arm-xilinx-linux-gnueabi-":
+ files.append((tarprefix + "ld", tarprefix + "ld.bfd"))
+
+ if len(files) > 0:
+ ext_bindir = d.expand('${EXTERNAL_TOOLCHAIN}/bin')
+ loc_bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True)
+ bb.mkdirhier(loc_bindir)
+ for f in files:
+ source = os.path.join(ext_bindir, f[0])
+ dest = os.path.join(loc_bindir, f[1])
+ try:
+ os.symlink(source, dest)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ break
+ bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (f[0], f[1]))
+}
+
+require conf/distro/include/xilinx-versions.inc
+
diff --git a/conf/distro/include/xilinx-versions.inc b/conf/distro/include/xilinx-versions.inc
new file mode 100644
index 00000000..a65358d4
--- /dev/null
+++ b/conf/distro/include/xilinx-versions.inc
@@ -0,0 +1,108 @@
+def csl_run(d, cmd, *args):
+ import bb.process
+ import subprocess
+
+ topdir = d.getVar('TOPDIR', True)
+ toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True)
+ if not toolchain_path:
+ return 'UNKNOWN', 'UNKNOWN'
+
+ target_prefix = d.getVar('TARGET_PREFIX', True)
+ path = os.path.join(toolchain_path, 'bin', target_prefix + cmd)
+ args = [path] + list(args)
+
+ return bb.process.run(args, cwd=topdir, stderr=subprocess.PIPE)
+
+def csl_get_version(d):
+ try:
+ stdout, stderr = csl_run(d, 'gcc', '-v')
+ except bb.process.CmdError as exc:
+ bb.error('Failed to obtain CodeSourcery toolchain version: %s' % exc)
+ bb.error('Make sure that MACHINE is set correctly in your local.conf and the toolchain supports %s.' % d.getVar("TARGET_ARCH", True))
+ return 'UNKNOWN'
+ else:
+ last_line = stderr.splitlines()[-1]
+ return last_line
+
+def csl_get_main_version(d):
+ version = csl_get_version(d)
+ if version != 'UNKNOWN':
+ return version.split()[-1].rstrip(')')
+ else:
+ return version
+
+def csl_get_gcc_version(d):
+ version = csl_get_version(d)
+ if version != 'UNKNOWN':
+ return version.split()[2]
+ else:
+ return version
+
+def xilinx_get_libc_version(d):
+ syspath = d.expand('${EXTERNAL_TOOLCHAIN_SYSROOT}')
+ if not syspath:
+ return 'UNKNOWN'
+
+ libpath = syspath + '/lib/'
+ if not os.path.exists(libpath):
+ libpath = syspath + '/sgxx-glibc/lib/'
+
+ if os.path.exists(libpath):
+ for file in os.listdir(libpath):
+ if file.find('libc-') == 0:
+ return file[5:-3]
+ return 'UNKNOWN'
+
+def xilinx_get_kernel_version(d):
+ syspath = d.expand('${EXTERNAL_TOOLCHAIN_SYSROOT}')
+ if not syspath:
+ return 'UNKNOWN'
+
+ vf = syspath + '/usr/include/linux/version.h'
+ if not os.path.exists(vf):
+ vf = syspath + '/sgxx-glibc/usr/include/linux/version.h'
+
+ try:
+ f = open(vf, 'r')
+ except (OSError, IOError):
+ return 'UNKNOWN'
+
+ l = f.readlines();
+ f.close();
+ for s in l:
+ if s.find('LINUX_VERSION_CODE') > 0:
+ ver = int(s.split()[2])
+ maj = ver / 65536
+ ver = ver % 65536
+ min = ver / 256
+ ver = ver % 256
+ return str(maj)+'.'+str(min)+'.'+str(ver)
+ return 'UNKNOWN'
+
+def csl_get_gdb_version(d):
+ try:
+ stdout, stderr = csl_run(d, 'gdb', '-v')
+ except bb.process.CmdError:
+ return 'UNKNOWN'
+ else:
+ first_line = stdout.splitlines()[0]
+ return first_line.split()[-1]
+
+python xilinx_version_handler () {
+ if not isinstance(e, bb.event.ConfigParsed):
+ return
+ d = e.data
+ ld = d.createCopy()
+ ld.finalize()
+
+ d.setVar('CSL_VER_MAIN', csl_get_main_version(ld))
+ d.setVar('CSL_VER_GCC', csl_get_gcc_version(ld))
+ d.setVar('CSL_VER_LIBC', xilinx_get_libc_version(ld))
+ d.setVar('CSL_VER_KERNEL', xilinx_get_kernel_version(ld))
+ d.setVar('CSL_VER_GDB', csl_get_gdb_version(ld))
+}
+addhandler xilinx_version_handler
+
+# Ensure that any variable which includes the --sysroot (CC, CXX, etc) also
+# depends on the toolchain version
+TOOLCHAIN_OPTIONS[vardeps] += "CSL_VER_MAIN CSL_VER_GCC"
diff --git a/recipes-core/meta/external-xilinx-toolchain.bb b/recipes-core/meta/external-xilinx-toolchain.bb
new file mode 100644
index 00000000..392d94cf
--- /dev/null
+++ b/recipes-core/meta/external-xilinx-toolchain.bb
@@ -0,0 +1,155 @@
+require recipes-core/eglibc/eglibc-package.inc
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# License applies to this recipe code, not the toolchain itself
+SUMMARY = "External Xilinx toolchain"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = " \
+ file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
+ file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \
+ "
+
+DEPENDS += "${@base_conditional('PREFERRED_PROVIDER_linux-libc-headers', PN, '', 'linux-libc-headers', d)}"
+PROVIDES += "\
+ linux-libc-headers \
+ virtual/${TARGET_PREFIX}gcc \
+ virtual/${TARGET_PREFIX}g++ \
+ virtual/${TARGET_PREFIX}gcc-initial \
+ virtual/${TARGET_PREFIX}gcc-intermediate \
+ virtual/${TARGET_PREFIX}binutils \
+ virtual/${TARGET_PREFIX}libc-for-gcc \
+ virtual/${TARGET_PREFIX}libc-initial \
+ virtual/${TARGET_PREFIX}compilerlibs \
+ virtual/libc \
+ virtual/libintl \
+ virtual/libiconv \
+ virtual/linux-libc-headers \
+ glibc-thread-db \
+ libgcc \
+ eglibc \
+ "
+
+PV = "${CSL_VER_MAIN}"
+PR = "r1"
+
+SRC_URI = "file://SUPPORTED"
+
+do_install() {
+ # Use optimized files if available
+ sysroot="${EXTERNAL_TOOLCHAIN_SYSROOT}"
+ dbgroot="${EXTERNAL_TOOLCHAIN_DBGROOT}"
+
+ cp -a $sysroot${base_libdir}/. ${D}${base_libdir}
+ cp -a $sysroot/sbin/. ${D}${base_sbindir}
+
+ install -d ${D}/usr
+ for usr_element in bin libexec sbin share ${base_libdir}; do
+ # Copy files from both the sysroot and the debugroot if they exist
+ if [ ! -z "$sysroot" -a -e $sysroot/usr/$usr_element ]; then
+ cp -a $sysroot/usr/$usr_element ${D}/usr/
+ fi
+ if [ ! -z "$dbgroot" -a -e $dbgroot/usr/$usr_element ]; then
+ cp -a $dbgroot/usr/$usr_element ${D}/usr/
+ fi
+ done
+
+ # Copy Include files
+ cp -a $sysroot/usr/include/. ${D}${includedir}
+
+ # strip out any multi-lib files (they are not supported)
+ for element in bs m ldscripts; do
+ if [ -e ${D}${libdir}/$element ]; then
+ rm -rf ${D}${libdir}/$element
+ fi
+ if [ -e ${D}${base_libdir}/$element ]; then
+ rm -rf ${D}${base_libdir}/$element
+ fi
+ done
+
+ # Clean up the image (remove files and directories that are not packaged)
+ ## ${D}${sysconfdir}
+ for i in ${D}/usr/share/zoneinfo ${D}/usr/lib/bin ${D}/usr/libexec ; do
+ if [ -e $i ]; then
+ rm -rf $i
+ fi
+ done
+
+ # Move libstdc++ to /usr/lib
+ if [ -e ${D}${base_libdir}/libstdc++.so ]; then
+ mv ${D}${base_libdir}/libstdc++.* ${D}${libdir}/
+ fi
+
+ sed -i -e 's/__packed/__attribute__ ((packed))/' ${D}${includedir}/mtd/ubi-user.h
+ sed -i -e "s# ${base_libdir}# ../..${base_libdir}#g" -e "s# ${libdir}# .#g" ${D}${libdir}/libc.so
+ sed -i -e "s# ${base_libdir}# ../..${base_libdir}#g" -e "s# ${libdir}# .#g" ${D}${libdir}/libpthread.so
+}
+
+PACKAGES =+ " \
+ libgcc libgcc-dev \
+ libstdc++ libstdc++-dev libstdc++-staticdev \
+ linux-libc-headers linux-libc-headers-dev \
+ gdbserver gdbserver-dbg \
+ "
+
+# This test should be fixed to ignore .a files in .debug dirs
+INSANE_SKIP_${PN}-dbg = "staticdev"
+
+# We don't care about GNU_HASH in prebuilt binaries
+INSANE_SKIP_${PN}-utils += "ldflags"
+INSANE_SKIP_${PN}-dev += "ldflags"
+INSANE_SKIP_libstdc++ += "ldflags"
+INSANE_SKIP_libgcc += "ldflags"
+INSANE_SKIP_gdbserver += "ldflags"
+
+PKG_${PN} = "eglibc"
+PKG_${PN}-dev = "eglibc-dev"
+PKG_${PN}-staticdev = "eglibc-staticdev"
+PKG_${PN}-doc = "eglibc-doc"
+PKG_${PN}-dbg = "eglibc-dbg"
+PKG_${PN}-pic = "eglibc-pic"
+PKG_${PN}-utils = "eglibc-utils"
+PKG_${PN}-gconv = "eglibc-gconv"
+PKG_${PN}-extra-nss = "eglibc-extra-nss"
+PKG_${PN}-thread-db = "eglibc-thread-db"
+PKG_${PN}-pcprofile = "eglibc-pcprofile"
+
+PKGV = "${CSL_VER_LIBC}"
+PKGV_libgcc = "${CSL_VER_GCC}"
+PKGV_libgcc-dev = "${CSL_VER_GCC}"
+PKGV_libstdc++ = "${CSL_VER_GCC}"
+PKGV_libstdc++-dev = "${CSL_VER_GCC}"
+PKGV_libstdc++-staticdev = "${CSL_VER_GCC}"
+PKGV_linux-libc-headers = "${CSL_VER_KERNEL}"
+PKGV_linux-libc-headers-dev = "${CSL_VER_KERNEL}"
+PKGV_gdbserver = "${CSL_VER_GDB}"
+PKGV_gdbserver-dbg = "${CSL_VER_GDB}"
+
+FILES_libgcc = "${base_libdir}/libgcc_s.so.1"
+FILES_libgcc-dev = "${base_libdir}/libgcc_s.so"
+FILES_libstdc++ = "${libdir}/libstdc++.so.*"
+FILES_libstdc++-dev = " \
+ ${includedir}/c++/${PV} \
+ ${libdir}/libstdc++.so \
+ ${libdir}/libstdc++.la \
+ ${libdir}/libsupc++.la \
+ "
+FILES_libstdc++-staticdev = "${libdir}/libstdc++.a ${libdir}/libsupc++.a"
+FILES_linux-libc-headers = " \
+ ${includedir}/asm* \
+ ${includedir}/linux \
+ ${includedir}/mtd \
+ ${includedir}/rdma \
+ ${includedir}/scsi \
+ ${includedir}/sound \
+ ${includedir}/video \
+ "
+FILES_gdbserver = "${bindir}/gdbserver"
+FILES_gdbserver-dbg = "${bindir}/.debug/gdbserver"
+
+CSL_VER_MAIN ??= ""
+
+python () {
+ if not d.getVar("CSL_VER_MAIN"):
+ raise bb.parse.SkipPackage("External toolchain not configured (CSL_VER_MAIN not set).")
+}
diff --git a/recipes-core/meta/external-xilinx-toolchain/SUPPORTED b/recipes-core/meta/external-xilinx-toolchain/SUPPORTED
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/recipes-core/meta/external-xilinx-toolchain/SUPPORTED