diff options
author | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-09-20 17:57:51 +1000 |
---|---|---|
committer | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-09-23 10:42:34 +1000 |
commit | cf9571203be0af5fc654952d3f00e0a7e0fb1174 (patch) | |
tree | 8e8fadd90b3f32f5b198be757fbad5f467cb5962 | |
parent | 4204ea87969a5f7e000abd0d91a56d8e6db2ac61 (diff) | |
download | meta-xilinx-dylan.tar.gz |
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.inc | 79 | ||||
-rw-r--r-- | conf/distro/include/xilinx-versions.inc | 108 | ||||
-rw-r--r-- | recipes-core/meta/external-xilinx-toolchain.bb | 155 | ||||
-rw-r--r-- | recipes-core/meta/external-xilinx-toolchain/SUPPORTED | 0 |
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 @@ | |||
1 | # | ||
2 | # Configuration to use external Xilinx toolchain | ||
3 | # | ||
4 | |||
5 | TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:" | ||
6 | PATH =. "${TOOLCHAIN_PATH_ADD}" | ||
7 | |||
8 | CSL_TARGET_SYS_armv7a ?= "arm-xilinx-linux-gnueabi" | ||
9 | CSL_TARGET_SYS_microblazeel ?= "microblazeel-xilinx-linux-gnu" | ||
10 | CSL_TARGET_SYS = "${TARGET_SYS}" | ||
11 | |||
12 | TARGET_PREFIX = "${CSL_TARGET_SYS}-" | ||
13 | |||
14 | PREFERRED_PROVIDER_linux-libc-headers = "external-xilinx-toolchain" | ||
15 | PREFERRED_PROVIDER_linux-libc-headers-dev = "external-xilinx-toolchain" | ||
16 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-xilinx-toolchain" | ||
17 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-xilinx-toolchain" | ||
18 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-intermediate = "external-xilinx-toolchain" | ||
19 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-xilinx-toolchain" | ||
20 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-xilinx-toolchain" | ||
21 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-xilinx-toolchain" | ||
22 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-initial = "external-xilinx-toolchain" | ||
23 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-xilinx-toolchain" | ||
24 | PREFERRED_PROVIDER_libgcc = "external-xilinx-toolchain" | ||
25 | PREFERRED_PROVIDER_eglibc = "external-xilinx-toolchain" | ||
26 | PREFERRED_PROVIDER_virtual/libc = "external-xilinx-toolchain" | ||
27 | PREFERRED_PROVIDER_virtual/libintl = "external-xilinx-toolchain" | ||
28 | PREFERRED_PROVIDER_virtual/libiconv = "external-xilinx-toolchain" | ||
29 | PREFERRED_PROVIDER_glibc-thread-db = "external-xilinx-toolchain" | ||
30 | PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-xilinx-toolchain" | ||
31 | PREFERRED_PROVIDER_virtual/linux-libc-headers-dev = "external-xilinx-toolchain" | ||
32 | PREFERRED_PROVIDER_gdbserver ?= "external-xilinx-toolchain" | ||
33 | |||
34 | # No need to re-compile the locale files | ||
35 | GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled" | ||
36 | ENABLE_BINARY_LOCALE_GENERATION = "" | ||
37 | |||
38 | TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}" | ||
39 | |||
40 | # Default sysroot is inside the Xilinx ARM v7-A toolchain in the '<CSL_TARGET_SYS>/libc' (no debug-root) | ||
41 | EXTERNAL_TOOLCHAIN_SYSROOT_armv7a ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/libc" | ||
42 | EXTERNAL_TOOLCHAIN_DBGROOT_armv7a ?= "" | ||
43 | |||
44 | # Default sysroot is inside the Xilinx MicroBlaze toolchain in the '<CSL_TARGET_SYS>/sys-root' | ||
45 | EXTERNAL_TOOLCHAIN_SYSROOT_microblaze ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/sys-root" | ||
46 | EXTERNAL_TOOLCHAIN_DBGROOT_microblaze ?= "${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}/debug-root" | ||
47 | |||
48 | addhandler toolchain_setup | ||
49 | python toolchain_setup () { | ||
50 | if not isinstance(e, bb.event.BuildStarted): | ||
51 | return | ||
52 | import errno | ||
53 | |||
54 | d = e.data | ||
55 | d = d.createCopy() | ||
56 | d.finalize() | ||
57 | |||
58 | tarprefix = d.expand('${TARGET_PREFIX}') | ||
59 | files = [] | ||
60 | if tarprefix == "arm-xilinx-linux-gnueabi-": | ||
61 | files.append((tarprefix + "ld", tarprefix + "ld.bfd")) | ||
62 | |||
63 | if len(files) > 0: | ||
64 | ext_bindir = d.expand('${EXTERNAL_TOOLCHAIN}/bin') | ||
65 | loc_bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) | ||
66 | bb.mkdirhier(loc_bindir) | ||
67 | for f in files: | ||
68 | source = os.path.join(ext_bindir, f[0]) | ||
69 | dest = os.path.join(loc_bindir, f[1]) | ||
70 | try: | ||
71 | os.symlink(source, dest) | ||
72 | except OSError as exc: | ||
73 | if exc.errno == errno.EEXIST: | ||
74 | break | ||
75 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (f[0], f[1])) | ||
76 | } | ||
77 | |||
78 | require conf/distro/include/xilinx-versions.inc | ||
79 | |||
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 @@ | |||
1 | def csl_run(d, cmd, *args): | ||
2 | import bb.process | ||
3 | import subprocess | ||
4 | |||
5 | topdir = d.getVar('TOPDIR', True) | ||
6 | toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True) | ||
7 | if not toolchain_path: | ||
8 | return 'UNKNOWN', 'UNKNOWN' | ||
9 | |||
10 | target_prefix = d.getVar('TARGET_PREFIX', True) | ||
11 | path = os.path.join(toolchain_path, 'bin', target_prefix + cmd) | ||
12 | args = [path] + list(args) | ||
13 | |||
14 | return bb.process.run(args, cwd=topdir, stderr=subprocess.PIPE) | ||
15 | |||
16 | def csl_get_version(d): | ||
17 | try: | ||
18 | stdout, stderr = csl_run(d, 'gcc', '-v') | ||
19 | except bb.process.CmdError as exc: | ||
20 | bb.error('Failed to obtain CodeSourcery toolchain version: %s' % exc) | ||
21 | bb.error('Make sure that MACHINE is set correctly in your local.conf and the toolchain supports %s.' % d.getVar("TARGET_ARCH", True)) | ||
22 | return 'UNKNOWN' | ||
23 | else: | ||
24 | last_line = stderr.splitlines()[-1] | ||
25 | return last_line | ||
26 | |||
27 | def csl_get_main_version(d): | ||
28 | version = csl_get_version(d) | ||
29 | if version != 'UNKNOWN': | ||
30 | return version.split()[-1].rstrip(')') | ||
31 | else: | ||
32 | return version | ||
33 | |||
34 | def csl_get_gcc_version(d): | ||
35 | version = csl_get_version(d) | ||
36 | if version != 'UNKNOWN': | ||
37 | return version.split()[2] | ||
38 | else: | ||
39 | return version | ||
40 | |||
41 | def xilinx_get_libc_version(d): | ||
42 | syspath = d.expand('${EXTERNAL_TOOLCHAIN_SYSROOT}') | ||
43 | if not syspath: | ||
44 | return 'UNKNOWN' | ||
45 | |||
46 | libpath = syspath + '/lib/' | ||
47 | if not os.path.exists(libpath): | ||
48 | libpath = syspath + '/sgxx-glibc/lib/' | ||
49 | |||
50 | if os.path.exists(libpath): | ||
51 | for file in os.listdir(libpath): | ||
52 | if file.find('libc-') == 0: | ||
53 | return file[5:-3] | ||
54 | return 'UNKNOWN' | ||
55 | |||
56 | def xilinx_get_kernel_version(d): | ||
57 | syspath = d.expand('${EXTERNAL_TOOLCHAIN_SYSROOT}') | ||
58 | if not syspath: | ||
59 | return 'UNKNOWN' | ||
60 | |||
61 | vf = syspath + '/usr/include/linux/version.h' | ||
62 | if not os.path.exists(vf): | ||
63 | vf = syspath + '/sgxx-glibc/usr/include/linux/version.h' | ||
64 | |||
65 | try: | ||
66 | f = open(vf, 'r') | ||
67 | except (OSError, IOError): | ||
68 | return 'UNKNOWN' | ||
69 | |||
70 | l = f.readlines(); | ||
71 | f.close(); | ||
72 | for s in l: | ||
73 | if s.find('LINUX_VERSION_CODE') > 0: | ||
74 | ver = int(s.split()[2]) | ||
75 | maj = ver / 65536 | ||
76 | ver = ver % 65536 | ||
77 | min = ver / 256 | ||
78 | ver = ver % 256 | ||
79 | return str(maj)+'.'+str(min)+'.'+str(ver) | ||
80 | return 'UNKNOWN' | ||
81 | |||
82 | def csl_get_gdb_version(d): | ||
83 | try: | ||
84 | stdout, stderr = csl_run(d, 'gdb', '-v') | ||
85 | except bb.process.CmdError: | ||
86 | return 'UNKNOWN' | ||
87 | else: | ||
88 | first_line = stdout.splitlines()[0] | ||
89 | return first_line.split()[-1] | ||
90 | |||
91 | python xilinx_version_handler () { | ||
92 | if not isinstance(e, bb.event.ConfigParsed): | ||
93 | return | ||
94 | d = e.data | ||
95 | ld = d.createCopy() | ||
96 | ld.finalize() | ||
97 | |||
98 | d.setVar('CSL_VER_MAIN', csl_get_main_version(ld)) | ||
99 | d.setVar('CSL_VER_GCC', csl_get_gcc_version(ld)) | ||
100 | d.setVar('CSL_VER_LIBC', xilinx_get_libc_version(ld)) | ||
101 | d.setVar('CSL_VER_KERNEL', xilinx_get_kernel_version(ld)) | ||
102 | d.setVar('CSL_VER_GDB', csl_get_gdb_version(ld)) | ||
103 | } | ||
104 | addhandler xilinx_version_handler | ||
105 | |||
106 | # Ensure that any variable which includes the --sysroot (CC, CXX, etc) also | ||
107 | # depends on the toolchain version | ||
108 | 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 @@ | |||
1 | require recipes-core/eglibc/eglibc-package.inc | ||
2 | |||
3 | INHIBIT_DEFAULT_DEPS = "1" | ||
4 | |||
5 | # License applies to this recipe code, not the toolchain itself | ||
6 | SUMMARY = "External Xilinx toolchain" | ||
7 | LICENSE = "MIT" | ||
8 | LIC_FILES_CHKSUM = " \ | ||
9 | file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \ | ||
10 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \ | ||
11 | " | ||
12 | |||
13 | DEPENDS += "${@base_conditional('PREFERRED_PROVIDER_linux-libc-headers', PN, '', 'linux-libc-headers', d)}" | ||
14 | PROVIDES += "\ | ||
15 | linux-libc-headers \ | ||
16 | virtual/${TARGET_PREFIX}gcc \ | ||
17 | virtual/${TARGET_PREFIX}g++ \ | ||
18 | virtual/${TARGET_PREFIX}gcc-initial \ | ||
19 | virtual/${TARGET_PREFIX}gcc-intermediate \ | ||
20 | virtual/${TARGET_PREFIX}binutils \ | ||
21 | virtual/${TARGET_PREFIX}libc-for-gcc \ | ||
22 | virtual/${TARGET_PREFIX}libc-initial \ | ||
23 | virtual/${TARGET_PREFIX}compilerlibs \ | ||
24 | virtual/libc \ | ||
25 | virtual/libintl \ | ||
26 | virtual/libiconv \ | ||
27 | virtual/linux-libc-headers \ | ||
28 | glibc-thread-db \ | ||
29 | libgcc \ | ||
30 | eglibc \ | ||
31 | " | ||
32 | |||
33 | PV = "${CSL_VER_MAIN}" | ||
34 | PR = "r1" | ||
35 | |||
36 | SRC_URI = "file://SUPPORTED" | ||
37 | |||
38 | do_install() { | ||
39 | # Use optimized files if available | ||
40 | sysroot="${EXTERNAL_TOOLCHAIN_SYSROOT}" | ||
41 | dbgroot="${EXTERNAL_TOOLCHAIN_DBGROOT}" | ||
42 | |||
43 | cp -a $sysroot${base_libdir}/. ${D}${base_libdir} | ||
44 | cp -a $sysroot/sbin/. ${D}${base_sbindir} | ||
45 | |||
46 | install -d ${D}/usr | ||
47 | for usr_element in bin libexec sbin share ${base_libdir}; do | ||
48 | # Copy files from both the sysroot and the debugroot if they exist | ||
49 | if [ ! -z "$sysroot" -a -e $sysroot/usr/$usr_element ]; then | ||
50 | cp -a $sysroot/usr/$usr_element ${D}/usr/ | ||
51 | fi | ||
52 | if [ ! -z "$dbgroot" -a -e $dbgroot/usr/$usr_element ]; then | ||
53 | cp -a $dbgroot/usr/$usr_element ${D}/usr/ | ||
54 | fi | ||
55 | done | ||
56 | |||
57 | # Copy Include files | ||
58 | cp -a $sysroot/usr/include/. ${D}${includedir} | ||
59 | |||
60 | # strip out any multi-lib files (they are not supported) | ||
61 | for element in bs m ldscripts; do | ||
62 | if [ -e ${D}${libdir}/$element ]; then | ||
63 | rm -rf ${D}${libdir}/$element | ||
64 | fi | ||
65 | if [ -e ${D}${base_libdir}/$element ]; then | ||
66 | rm -rf ${D}${base_libdir}/$element | ||
67 | fi | ||
68 | done | ||
69 | |||
70 | # Clean up the image (remove files and directories that are not packaged) | ||
71 | ## ${D}${sysconfdir} | ||
72 | for i in ${D}/usr/share/zoneinfo ${D}/usr/lib/bin ${D}/usr/libexec ; do | ||
73 | if [ -e $i ]; then | ||
74 | rm -rf $i | ||
75 | fi | ||
76 | done | ||
77 | |||
78 | # Move libstdc++ to /usr/lib | ||
79 | if [ -e ${D}${base_libdir}/libstdc++.so ]; then | ||
80 | mv ${D}${base_libdir}/libstdc++.* ${D}${libdir}/ | ||
81 | fi | ||
82 | |||
83 | sed -i -e 's/__packed/__attribute__ ((packed))/' ${D}${includedir}/mtd/ubi-user.h | ||
84 | sed -i -e "s# ${base_libdir}# ../..${base_libdir}#g" -e "s# ${libdir}# .#g" ${D}${libdir}/libc.so | ||
85 | sed -i -e "s# ${base_libdir}# ../..${base_libdir}#g" -e "s# ${libdir}# .#g" ${D}${libdir}/libpthread.so | ||
86 | } | ||
87 | |||
88 | PACKAGES =+ " \ | ||
89 | libgcc libgcc-dev \ | ||
90 | libstdc++ libstdc++-dev libstdc++-staticdev \ | ||
91 | linux-libc-headers linux-libc-headers-dev \ | ||
92 | gdbserver gdbserver-dbg \ | ||
93 | " | ||
94 | |||
95 | # This test should be fixed to ignore .a files in .debug dirs | ||
96 | INSANE_SKIP_${PN}-dbg = "staticdev" | ||
97 | |||
98 | # We don't care about GNU_HASH in prebuilt binaries | ||
99 | INSANE_SKIP_${PN}-utils += "ldflags" | ||
100 | INSANE_SKIP_${PN}-dev += "ldflags" | ||
101 | INSANE_SKIP_libstdc++ += "ldflags" | ||
102 | INSANE_SKIP_libgcc += "ldflags" | ||
103 | INSANE_SKIP_gdbserver += "ldflags" | ||
104 | |||
105 | PKG_${PN} = "eglibc" | ||
106 | PKG_${PN}-dev = "eglibc-dev" | ||
107 | PKG_${PN}-staticdev = "eglibc-staticdev" | ||
108 | PKG_${PN}-doc = "eglibc-doc" | ||
109 | PKG_${PN}-dbg = "eglibc-dbg" | ||
110 | PKG_${PN}-pic = "eglibc-pic" | ||
111 | PKG_${PN}-utils = "eglibc-utils" | ||
112 | PKG_${PN}-gconv = "eglibc-gconv" | ||
113 | PKG_${PN}-extra-nss = "eglibc-extra-nss" | ||
114 | PKG_${PN}-thread-db = "eglibc-thread-db" | ||
115 | PKG_${PN}-pcprofile = "eglibc-pcprofile" | ||
116 | |||
117 | PKGV = "${CSL_VER_LIBC}" | ||
118 | PKGV_libgcc = "${CSL_VER_GCC}" | ||
119 | PKGV_libgcc-dev = "${CSL_VER_GCC}" | ||
120 | PKGV_libstdc++ = "${CSL_VER_GCC}" | ||
121 | PKGV_libstdc++-dev = "${CSL_VER_GCC}" | ||
122 | PKGV_libstdc++-staticdev = "${CSL_VER_GCC}" | ||
123 | PKGV_linux-libc-headers = "${CSL_VER_KERNEL}" | ||
124 | PKGV_linux-libc-headers-dev = "${CSL_VER_KERNEL}" | ||
125 | PKGV_gdbserver = "${CSL_VER_GDB}" | ||
126 | PKGV_gdbserver-dbg = "${CSL_VER_GDB}" | ||
127 | |||
128 | FILES_libgcc = "${base_libdir}/libgcc_s.so.1" | ||
129 | FILES_libgcc-dev = "${base_libdir}/libgcc_s.so" | ||
130 | FILES_libstdc++ = "${libdir}/libstdc++.so.*" | ||
131 | FILES_libstdc++-dev = " \ | ||
132 | ${includedir}/c++/${PV} \ | ||
133 | ${libdir}/libstdc++.so \ | ||
134 | ${libdir}/libstdc++.la \ | ||
135 | ${libdir}/libsupc++.la \ | ||
136 | " | ||
137 | FILES_libstdc++-staticdev = "${libdir}/libstdc++.a ${libdir}/libsupc++.a" | ||
138 | FILES_linux-libc-headers = " \ | ||
139 | ${includedir}/asm* \ | ||
140 | ${includedir}/linux \ | ||
141 | ${includedir}/mtd \ | ||
142 | ${includedir}/rdma \ | ||
143 | ${includedir}/scsi \ | ||
144 | ${includedir}/sound \ | ||
145 | ${includedir}/video \ | ||
146 | " | ||
147 | FILES_gdbserver = "${bindir}/gdbserver" | ||
148 | FILES_gdbserver-dbg = "${bindir}/.debug/gdbserver" | ||
149 | |||
150 | CSL_VER_MAIN ??= "" | ||
151 | |||
152 | python () { | ||
153 | if not d.getVar("CSL_VER_MAIN"): | ||
154 | raise bb.parse.SkipPackage("External toolchain not configured (CSL_VER_MAIN not set).") | ||
155 | } | ||
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 | |||