On Sat, 2014-12-20 at 14:43 +0000, Peter Saunderson wrote: > I have seen a brief IRC chat > (https://www.yoctoproject.org/irc/%23yocto.2013-09-23.log.html talking > about https://github.com/nathanrossi/meta-parallella) about this > question but nothing much else so this is an attempt to get more public > feedback on this request. > > I am trying to build a cross compiler that runs on the target processor > and a cross compiler that runs on the host processor so that I can build > code for a third processor (Epiphany). If you want examples of the > traditional way to build this compiler look at > https://github.com/adapteva/epiphany-sdk epiphany-gcc epiphany-newlib > epiphany-binutils... The end result would be a set of recipes that run > on a pc build machine that build both arm code for the interim target > and epiphany code for the final target and provides an SDK for the pc > that enables you to cross compile for both arm and epiphany. > > As I am just starting to look at this I would like to know what size of > task I am up against! My initial efforts based on review of > poky/meta/recipes-devtools/binutils etc seem to suggest that I have to > modify at least ${HOST_PREFIX}, ${TARGET_PREFIX}, ${TARGET_ARCH} etc for > my epiphany-??? recipes so that the I can install the compiler in a > suitable location with a suitable prefix, the IRC chat indicates that > there are more things to consider also. > > The question I have is about how easy it will be to use existing recipes > for existing compiler / binutils etc... or is this likely to end up as a > completely new set of recipes from the ground up because the existing > recipes cant cope with building cross / cross compilers where there are > three processors to consider (host (intel based pc), interim target > (arm) and final target (epiphany)), or at least a lot of changes in the > existing recipes to cope with something like TARGET_TARGET_ARCH = > ${TARGET_ARCH}_${FINAL_TARGET_ARCH}??
As mentioned, I had need to do something like this for an avr target. I've created some *extremely* hacky recipes which do this and the resulting toolchain does actually work, much to my surprise. I've included the recipes I created below, warts and all in case it helps. Basically, its all a bit of a hack, the trouble is the system is very much tuned to have TARGET pointed at HOST for standard recipes. In the end I found it easier to 'sed' in the right target values into configure and then 'sed' other variables to change TARGET_PREFIX/TARGET_SYS where needed. Ultimately if we were doing a lot of this, we may be able to use a different variable name to make the recipes a lot neater. Cheers, Richard >From f58f90257a5af3e6b6974090e62cad9d90d53ae5 Mon Sep 17 00:00:00 2001 From: Richard Purdie <richard.pur...@linuxfoundation.org> Date: Tue, 23 Dec 2014 09:01:34 +0000 Subject: Add target avr support Known issues: * dependencies between the recipes is missing/incorrect * on target avr libgcc isn't installed Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org> diff --git a/meta/recipes-devtools/avr-libc/avr-libc_1.8.1.bb b/meta/recipes-devtools/avr-libc/avr-libc_1.8.1.bb new file mode 100644 index 0000000..81481ba --- /dev/null +++ b/meta/recipes-devtools/avr-libc/avr-libc_1.8.1.bb @@ -0,0 +1,31 @@ +SRC_URI = "http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.1.tar.bz2" +LICENSE = "BSD" +LIC_FILES_CHKSUM = "file://LICENSE;md5=8d91a8f153d3de715f67a5df0d841c43" + +SRC_URI[md5sum] = "0caccead59eaaa61ac3f060ca3a803ef" +SRC_URI[sha256sum] = "c3062a481b6b2c6959dc708571c00b0e26301897ba21171ed92acd0af7c4a969" + +inherit autotools + +TOOLCHAIN_OPTIONS = "" + +TARGET_CFLAGS = "" +TARGET_LDFLAGS = "" + +export CC = "avr-gcc" +export AS = "avr-as" +export RANLIB = "avr-ranlib" +export AR = "avr-ar" + +FILES_${PN} += "${exec_prefix}/avr" +INSANE_SKIP_${PN} = "arch staticdev" + +python () { + def replace(var, x, y): + d.setVar(var, d.getVar(var, True).replace(d.expand(x),y)) + + replace('CONFIGUREOPTS', '--host=${HOST_SYS}','--host=avr') + replace('CONFIGUREOPTS', '--target=${TARGET_SYS}','--target=avr') +} + + diff --git a/meta/recipes-devtools/binutils/binutils-cross-target-avr_2.24.bb b/meta/recipes-devtools/binutils/binutils-cross-target-avr_2.24.bb new file mode 100644 index 0000000..e19cf54 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils-cross-target-avr_2.24.bb @@ -0,0 +1,37 @@ +require binutils.inc +require binutils-${PV}.inc +require binutils-cross.inc + +DEPENDS += "flex bison zlib" +PROVIDES = "virtual/binutils-target-avr" + +BPN = "binutils" + + + +python () { + def replace(var, x, y): + d.setVar(var, d.getVar(var, True).replace(d.expand(x),y)) + + replace('CONFIGUREOPTS', '--target=${TARGET_SYS}','--target=avr') + replace('EXTRA_OECONF', '--program-prefix=${TARGET_PREFIX}' ,'--program-prefix=avr-') + replace('do_install', '${TARGET_PREFIX}' ,'avr-') + replace('do_install', '${TARGET_SYS}' ,'avr') +} + +EXTRA_OECONF += "--with-sysroot=/ \ + --enable-install-libbfd \ + --enable-install-libiberty \ + --enable-shared \ + " + +do_install () { + oe_runmake 'DESTDIR=${D}' install +} + +sysroot_stage_all() { + sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR} + sysroot_stage_dir ${D}${STAGING_DIR_NATIVE}${prefix_native}/avr ${SYSROOT_DESTDIR}${STAGING_DIR_NATIVE}${prefix_native}/avr + sysroot_stage_dir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${BUILD_SYS} ${SYSROOT_DESTDIR}${STAGING_DIR_NATIVE}${prefix_native}/${BUILD_SYS} +} + diff --git a/meta/recipes-devtools/binutils/binutils-target-avr_2.24.bb b/meta/recipes-devtools/binutils/binutils-target-avr_2.24.bb new file mode 100644 index 0000000..66a899c --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils-target-avr_2.24.bb @@ -0,0 +1,57 @@ +require binutils.inc +require binutils-${PV}.inc + +DEPENDS += "flex bison zlib" + +BPN = "binutils" + +FILES_${PN}-dev += " \ + ${exec_prefix}/${HOST_SYS}/avr/lib/lib*.la \ + ${exec_prefix}/${HOST_SYS}/avr/lib/libopcodes.so \ + ${exec_prefix}/${HOST_SYS}/avr/lib/libbfd.so \ + ${exec_prefix}/${HOST_SYS}/avr/include \ +" +FILES_${PN}-staticdev += " \ + ${exec_prefix}/${HOST_SYS}/avr/lib/lib*.a \ +" + +USE_ALTERNATIVES_FOR = "" + +python () { + def replace(var, x, y): + d.setVar(var, d.getVar(var, True).replace(d.expand(x),y)) + + replace('CONFIGUREOPTS', '--target=${TARGET_SYS}','--target=avr') + replace('EXTRA_OECONF', '--program-prefix=${TARGET_PREFIX}' ,'--program-prefix=avr-') + replace('do_install', '${TARGET_PREFIX}' ,'avr-') + replace('do_install', '${TARGET_SYS}' ,'avr') + replace(d.expand('FILES_${PN}'), '${TARGET_PREFIX}' ,'avr-') + replace(d.expand('FILES_${PN}'), '${TARGET_SYS}' ,'avr') + d.appendVar(d.expand('FILES_${PN}'), " ${exec_prefix}/${HOST_SYS}/avr/lib/*-*.so ${libdir}/ldscripts") + d.appendVar(d.expand('FILES_${PN}-dbg'), " ${exec_prefix}/${HOST_SYS}/avr/lib/.debug") +} + +EXTRA_OECONF += "--with-sysroot=/ \ + --enable-install-libbfd \ + --enable-install-libiberty \ + --enable-shared \ + " + +#do_install_append() { +# # Remove symlinks created by do_install +# for p in ${TARGET_PREFIX}* ; do +# rm `echo $p | sed -e s,${TARGET_PREFIX},,` +# done +#} + +do_install () { + autotools_do_install + + # Fix the /usr/${TARGET_SYS}/bin/* links + for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do + rm -f $l + ln -sf `echo ${prefix}/${TARGET_SYS}/bin \ + | tr -s / \ + | sed -e 's,^/,,' -e 's,[^/]*,..,g'`${bindir}/${TARGET_PREFIX}`basename $l` $l + done +} \ No newline at end of file diff --git a/meta/recipes-devtools/gcc/gcc-cross-target-avr_4.8.bb b/meta/recipes-devtools/gcc/gcc-cross-target-avr_4.8.bb new file mode 100644 index 0000000..aa5c469 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-cross-target-avr_4.8.bb @@ -0,0 +1,41 @@ +require recipes-devtools/gcc/gcc-${PV}.inc +require gcc-cross.inc + +BPN = "gcc" +PROVIDES = "virtual/gcc-target-avr" + +ARCH_FLAGS_FOR_TARGET = "" +TARGET_CFLAGS = "" + +EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', True) != 'no']} \ + --with-gnu-ld \ + --enable-languages=c \ + ${GCCMULTILIB} \ + --disable-libssp \ + --program-prefix=avr- \ + --without-local-prefix \ + ${OPTSPACE} \ + --enable-lto \ + --disable-bootstrap \ + --disable-libmudflap \ + --with-system-zlib \ + --enable-linker-build-id \ + --with-ppl=no \ + --with-cloog=no \ + --enable-checking=release \ + ${EXTRA_OECONF_PATHS}" + +python () { + def replace(var, x, y): + #bb.warn(x) + #bb.warn(d.expand(x)) + #bb.warn(d.getVar(var)) + #bb.warn(d.getVar(var, True).replace(d.expand(x),y)) + d.setVar(var, d.getVar(var, True).replace(d.expand(x),y)) + + replace('CONFIGUREOPTS', '--target=${TARGET_SYS}','--target=avr') + #replace('do_configure', '${HOST_PREFIX}' ,'avr-') + replace('do_install', '${TARGET_PREFIX}' ,'avr-') + replace('do_install', '${TARGET_SYS}' ,'avr') +} + diff --git a/meta/recipes-devtools/gcc/gcc-target-avr_4.8.bb b/meta/recipes-devtools/gcc/gcc-target-avr_4.8.bb new file mode 100644 index 0000000..b2be069 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-target-avr_4.8.bb @@ -0,0 +1,50 @@ +require recipes-devtools/gcc/gcc-${PV}.inc +require gcc-target.inc + +BPN = "gcc" + +ARCH_FLAGS_FOR_TARGET = "" + +EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', True) != 'no']} \ + --with-gnu-ld \ + --enable-languages=c \ + ${GCCMULTILIB} \ + --disable-libssp \ + --program-prefix=avr- \ + --without-local-prefix \ + ${OPTSPACE} \ + --enable-lto \ + --disable-bootstrap \ + --disable-libmudflap \ + --with-system-zlib \ + --with-ppl=no \ + --with-cloog=no \ + --enable-checking=release \ + ${EXTRA_OECONF_PATHS}" + + +python () { + def replace(var, x, y, d): + d.setVar(var, d.getVar(var, True).replace(d.expand(x),y)) + + ld = bb.data.createCopy(d) + ld.setVar("TARGET_CFLAGS", "") + ld.setVar("HOST_CC_ARCH", "") + ld.setVar("TOOLCHAIN_OPTIONS", "") + + replace('CONFIGUREOPTS', '--target=${TARGET_SYS}','--target=avr', d) + replace('EXTRA_OECONF', '--program-prefix=${TARGET_PREFIX}' ,'--program-prefix=avr-', d) + replace('do_configure', '${HOST_PREFIX}' ,'avr-', ld) + d.setVar('do_configure', ld.getVar('do_configure')) + replace('do_install', '${TARGET_PREFIX}' ,'avr-', d) + replace('do_install', '${TARGET_SYS}' ,'avr', d) + replace(d.expand('FILES_${PN}'), '${TARGET_PREFIX}' ,'avr-', d) + replace(d.expand('FILES_cpp'), '${TARGET_PREFIX}' ,'avr-', d) + replace(d.expand('FILES_gcov'), '${TARGET_PREFIX}' ,'avr-', d) + replace(d.expand('FILES_${PN}'), '${TARGET_SYS}' ,'avr', d) + replace(d.expand('FILES_${PN}-plugin-dev'), '${TARGET_SYS}' ,'avr', d) + replace(d.expand('FILES_${PN}-dbg'), '${TARGET_SYS}' ,'avr', d) + replace(d.expand('FILES_${PN}-dev'), '${TARGET_SYS}' ,'avr', d) + #d.appendVar(d.expand('FILES_${PN}'), " ${exec_prefix}/${HOST_SYS}/avr/lib/*-*.so") + #d.appendVar(d.expand('FILES_${PN}-dbg'), " ${exec_prefix}/${HOST_SYS}/avr/lib/.debug") +} -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto