From da66ad297d66d9ad24044561367b524b0572bc9a Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 11 Aug 2014 12:34:39 +0200 Subject: [PATCH] Add newlib for arm_none_eabi * Add sysroot support to the binutils * Add a "nolibc" version of gcc, used only to build the newlib * Add newlib recipe * Fix "main" gcc recipe to depend on the built newlib and set the sysroot and default include search path properly. This recipe set can now be derived to build bare-metal cross compilers for any other CPU supported by gcc, binutils and newlib. --- ..._none_eabi_binutils-2.24_2014_03_19.recipe | 4 +- .../arm_none_eabi_gcc-4.8.2_2014_03_20.recipe | 6 +- ...ne_eabi_gcc_nolibc-4.8.2_2014_03_20.recipe | 126 ++++++++++++++++++ .../arm_none_eabi_newlib-2.1.0.recipe | 88 ++++++++++++ 4 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc_nolibc-4.8.2_2014_03_20.recipe create mode 100644 sys-libs/arm_none_eabi_newlib/arm_none_eabi_newlib-2.1.0.recipe diff --git a/sys-devel/arm_none_eabi_binutils/arm_none_eabi_binutils-2.24_2014_03_19.recipe b/sys-devel/arm_none_eabi_binutils/arm_none_eabi_binutils-2.24_2014_03_19.recipe index 91a0f9444..90da667f3 100644 --- a/sys-devel/arm_none_eabi_binutils/arm_none_eabi_binutils-2.24_2014_03_19.recipe +++ b/sys-devel/arm_none_eabi_binutils/arm_none_eabi_binutils-2.24_2014_03_19.recipe @@ -5,7 +5,7 @@ srcGitRev="c20a732df8f8b6d0f32c872817f3a0498a5c4761" SRC_URI="https://github.com/haiku/buildtools/archive/$srcGitRev.tar.gz" CHECKSUM_SHA256="6d3b677cd8ef777bf6fb3186a15b5122e46345595a996370325c758b3d8a4ab6" SRC_FILENAME="binutils-$portVersion.tar.gz" -REVISION="5" +REVISION="6" LICENSE=" GNU GPL v2 GNU LGPL v2 @@ -90,7 +90,7 @@ BUILD() CFLAGS=-O2 CXXFLAGS=-O2 runConfigure "$sourceDir/configure" \ --exec-prefix=$installDir \ --includedir=$includeDir/binutils \ - --docdir=$docDir \ + --docdir=$docDir --with-sysroot=/system/develop/$targetArch/ \ --disable-nls --target=${targetArch} make $jobArgs diff --git a/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc-4.8.2_2014_03_20.recipe b/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc-4.8.2_2014_03_20.recipe index 5c323a0c1..8dea95378 100644 --- a/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc-4.8.2_2014_03_20.recipe +++ b/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc-4.8.2_2014_03_20.recipe @@ -8,7 +8,7 @@ srcGitRev="c20a732df8f8b6d0f32c872817f3a0498a5c4761" SRC_URI="https://github.com/haiku/buildtools/archive/$srcGitRev.tar.gz" CHECKSUM_SHA256="6d3b677cd8ef777bf6fb3186a15b5122e46345595a996370325c758b3d8a4ab6" SRC_FILENAME="$portVersionedName.tar.gz" -REVISION="1" +REVISION="2" LICENSE=" GNU GPL v2 GNU LGPL v2 @@ -46,6 +46,7 @@ REQUIRES=" " BUILD_REQUIRES=" cmd:${targetU}_as$secondaryArchSuffix + ${targetU}_newlib$secondaryArchSuffix " BUILD_PREREQUIRES=" haiku${secondaryArchSuffix}_devel >= $haikuVersion @@ -96,7 +97,8 @@ BUILD() --docdir=$docDir --disable-nls --disable-libssp --with-gnu-ld \ --enable-languages=c,c++ --enable-lto --enable-frame-pointer \ --enable-multilib --disable-shared \ - --without-headers --with-newlib \ + --with-newlib --with-sysroot=/system/develop/$targetArch/ \ + --with-native-system-header-dir=/include \ --with-pkgversion=$(echo $portVersion | cut -c 7-) --target=$targetArch make $jobArgs all-gcc all-target-libgcc diff --git a/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc_nolibc-4.8.2_2014_03_20.recipe b/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc_nolibc-4.8.2_2014_03_20.recipe new file mode 100644 index 000000000..f2524820b --- /dev/null +++ b/sys-devel/arm_none_eabi_gcc/arm_none_eabi_gcc_nolibc-4.8.2_2014_03_20.recipe @@ -0,0 +1,126 @@ +SUMMARY="C/C++ cross-compiler for ARM" +DESCRIPTION=" +Compiler for ARM processors. +" +HOMEPAGE="http://gcc.gnu.org" + +srcGitRev="c20a732df8f8b6d0f32c872817f3a0498a5c4761" +SRC_URI="https://github.com/haiku/buildtools/archive/$srcGitRev.tar.gz" +CHECKSUM_SHA256="6d3b677cd8ef777bf6fb3186a15b5122e46345595a996370325c758b3d8a4ab6" +SRC_FILENAME="$portVersionedName.tar.gz" +REVISION="1" +LICENSE=" + GNU GPL v2 + GNU LGPL v2 + " +COPYRIGHT="1988-2013 Free Software Foundation, Inc." + + +ARCHITECTURES="x86 x86_64 arm" +if [ $effectiveTargetArchitecture != x86_gcc2 ]; then + # x86_gcc2 is fine as primary target architecture as long as we're building + # for a different secondary architecture. + ARCHITECTURES="$ARCHITECTURES x86_gcc2" +fi +SECONDARY_ARCHITECTURES="x86" + +targetArch="arm-none-eabi" +targetU="arm_none_eabi" + +PROVIDES=" + ${targetU}_gcc_nolibc$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_c++$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_cc$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_cpp$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_g++$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_gcc$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_gcc_4.8.2$secondaryArchSuffix = $portVersion compat >= 4 + cmd:${targetU}_gcov$secondaryArchSuffix = $portVersion compat >= 4 + lib:${targetU}_libstdc++$secondaryArchSuffix = $portVersion compat >= 4 + " + +REQUIRES=" + haiku$secondaryArchSuffix >= $haikuVersion + cmd:${targetU}_as$secondaryArchSuffix + lib:libstdc++$secondaryArchSuffix + " +BUILD_REQUIRES=" + cmd:${targetU}_as$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + haiku${secondaryArchSuffix}_devel >= $haikuVersion + cmd:autoconf + cmd:awk + cmd:bison + cmd:find + cmd:flex + cmd:gcc$secondaryArchSuffix + cmd:ld$secondaryArchSuffix + cmd:make + cmd:makeinfo + cmd:sed + cmd:strip + cmd:tar + cmd:xargs + " + +SOURCE_DIR="buildtools-$srcGitRev/gcc" + +sourceDir=$(pwd) +relativeInstallDir="develop/tools/${targetArch}" +installDir="$prefix/$relativeInstallDir" +objectsDir=$(pwd)/../${portVersionedName}-obj + +BUILD() +{ + rm -rf $objectsDir + + # Touch some files generated by bison, so that bison won't run to update + # them. Fixes issues with newer bison versions. + # And while at it, touch gperf target, too (as gperf may not be installed). + (cd $sourceDir/gcc; touch c-parse.c c-parse.h cexp.c cp/parse.c \ + cp/parse.h c-gperf.h) + + mkdir -p $objectsDir + cd $objectsDir + + # Setting a quoted string in an environment variable is ugly (the quotes + # are removed at various stages and need an absurd amount of escaping), so + # let's use a file and --include instead. + echo '#define LIBRARY_PATH_ENV "ARM_LIBRARY_PATH"' > haiku_host.h + + CXXFLAGS="-O2 -include $objectsDir/haiku_host.h" \ + CFLAGS="-O2 -U_FORTIFY_SOURCE" "$sourceDir/configure" \ + --build=$effectiveTargetMachineTriple \ + --prefix=$installDir --libexecdir=$installDir/lib --mandir=$manDir \ + --docdir=$docDir --disable-nls --disable-libssp --with-gnu-ld \ + --enable-languages=c,c++ --enable-lto --enable-frame-pointer \ + --enable-multilib --disable-shared \ + --without-headers --with-newlib \ + --with-pkgversion=$(echo $portVersion | cut -c 7-) --target=$targetArch + + make $jobArgs all-gcc all-target-libgcc +} + +INSTALL() +{ + cd $objectsDir + + make install-gcc install-target-libgcc + + ### Symlinks ############################################## + + echo "Creating required symlinks" + + # make all tools available via default paths + mkdir -p $binDir + for f in c++ cc cpp g++ gcc gcov; do + symlinkRelative -sfn $installDir/bin/$targetArch-$f $binDir + done + + ### Cleanup ############################################### + + echo "Cleanup" + rm -rf $installDir/info + rm -rf $installDir/share +} diff --git a/sys-libs/arm_none_eabi_newlib/arm_none_eabi_newlib-2.1.0.recipe b/sys-libs/arm_none_eabi_newlib/arm_none_eabi_newlib-2.1.0.recipe new file mode 100644 index 000000000..90d5b87a0 --- /dev/null +++ b/sys-libs/arm_none_eabi_newlib/arm_none_eabi_newlib-2.1.0.recipe @@ -0,0 +1,88 @@ +SUMMARY="A C library for embedded systems" +DESCRIPTION="Newlib is a C library intended for use on embedded systems. It \ +is a conglomeration of several library parts, all under free software \ +licenses that make them easily usable on embedded products." +LICENSE=" + BSD (3-clause) + GNU LGPL v2.1 +" +HOMEPAGE="http://www.sourceware.org/newlib/" + +# This lists copyrights only for the parts used in this ARM compilation, other +# targets may need more or less. Please update this if making a recipe for +# another arch. +COPYRIGHT=" +1994-2009 Red Hat, Inc +1981-2000 The Regents of the University of California. +1991 by AT&T. +1998-2001 by Lucent Technologies +1989, 1990 Advanced Micro Devices, Inc. +1993 by Sun Microsystems, Inc. +1986 HEWLETT-PACKARD COMPANY +2001 Hans-Peter Nilsson +2001 Christopher G. Demetriou +2002 SuperH, Inc. +1999 Kungliga Tekniska Högskolan +2000, 2001 Alexey Zelkin +1997 by Andrey A. Chernov, Moscow, Russia. +1997-2002 FreeBSD Project. +1984,2000 S.L. Moshier +1999 Citrus Project +1998 Todd C. Miller +1991 DJ Delorie +1990-1999, 2000, 2001 Free Software Foundation, Inc. +2001 Mike Barcroft +2009 ARM Ltd +2008 Ed Schouten +" +REVISION="1" + +ARCHITECTURES="" +if [ $effectiveTargetArchitecture != x86_gcc2 ]; then + # x86_gcc2 is fine as primary target architecture as long as we're building + # for a different secondary architecture. + ARCHITECTURES="$ARCHITECTURES x86_gcc2" +fi +SECONDARY_ARCHITECTURES="x86" + +SRC_URI="ftp://sourceware.org/pub/newlib/newlib-2.1.0.tar.gz" +SOURCE_DIR="newlib-$portVersion" +CHECKSUM_SHA256="3e4d5ab9f0508942b6231b8ade4f8e5048cf92c96ed574c2bd6bd3320a599a48" + +targetArch="arm-none-eabi" +targetU="arm_none_eabi" + +PROVIDES=" + ${targetU}_newlib$secondaryArchSuffix = $portVersion +" + +BUILD_PREREQUIRES=" + haiku${secondaryArchSuffix}_devel >= $haikuVersion + cmd:awk + cmd:gcc$secondaryArchSuffix + cmd:make + cmd:makeinfo + cmd:${targetU}_ld$secondaryArchSuffix + ${tagetU}_gcc_nolibc$secondaryArchSuffix +" + +sourceDir=$(pwd) +installDir="$prefix/$relativeInstallDir/develop" +objectsDir=$(pwd)/../${portVersionedName}-obj + +BUILD() +{ + #rm -rf $objectsDir + mkdir -p $objectsDir + cd $objectsDir + + runConfigure $sourceDir/configure --target=arm-none-eabi \ + --prefix=$installDir + make +} + +INSTALL() +{ + cd $objectsDir + make install +}