You are not logged in.
Pages: 1
I am struggling with building a cross toolchain, essentially it boils down to building these packages (in thegiven order):
binutils gcc-base newlib gcc
When done I am trying to compile a dummy cpp algorithm (euler gcd/ggT search) with no includes.
What the cross toolchain spits at me is the following:
$ arm-unknown-eabi-gcc -march=armv5te ./euklidisch_ggt.c -o ./euklidisch_ggt.bin.armv5te
/usr/bin/arm-unknown-eabi-ld: skipping incompatible /usr/lib/gcc/arm-unknown-eabi/4.5.2/../../../../arm-unknown-eabi/lib/libc.a when searching for -lc
/usr/bin/arm-unknown-eabi-ld: skipping incompatible /usr/arm-unknown-eabi/lib/libc.a when searching for -lc
/usr/bin/arm-unknown-eabi-ld: cannot find -lc
collect2: ld returned 1 exit status
I wrote a little script to build it (as I got pretty much fed up doing it all by hund, round #7 just failed again)
Note: it is semi-automated, you will still be requested to give your passwd to agree with install and blah
Note: use it with arg "cleanup" to get rid of old installed packages (run as root)
Note: use it to compile as user
#!/bin/bash
BUILDERUSER=buildmonkey
PREFIX="/usr"
TARGET="arm-unknown-eabi"
PKGBUILDDIR="/home/${BUILDERUSER}/PKGBUILD"
PKGS="binutils gcc-base newlib gcc"
export PREFIX
export TARGET
export BUILDERUSER
export PKGS
export PKGBUILDDIR
function cleanup
{
for j in ${PKGS}
do
export j
echo "Removing package ${TARGET}-${j}"
su -c'pacman -R ${TARGET}-${j}'
done
}
function compile_and_install
{
cd ${PKGBUILDDIR}
echo ""
echo ""
echo "Compileing ${TARGET}-${1} ... "
echo ""
echo ""
cd ./${TARGET}-${1}
rm ./${TARGET}-${1}*
makepkg -f || return 1
su -c 'pacman -U ./${TARGET}-${1}*'
echo ""
}
if [ "${1}" == "cleanup" ]; then
echo "cleanup requested...."
cleanup
exit 0
fi
if [ "$(id -u)" == "0" ]; then
echo "This script must not be run as root!!" 1>&2
exit 1
fi
echo ""
if [ -d "${PKGBUILDDIR}" ]; then
echo "PKGBUILD directory is ${PKGBUILDDIR}"
else
echo "PKGBUILD directory ${PKGBUILDDIR} is missing!!"
exit 1
fi
echo "PKGs are ${PKGS}"
echo ""
for i in ${PKGS}
do
compile_and_install ${i}
done
exit 0
The packagebuilds are as following (hacked away versions of the ones existing in AUR, which give me linker errors)
binutils
pkgname=arm-unknown-eabi-binutils
pkgver=2.21
pkgrel=1
pkgdesc="A set of programs to assemble and manipulate binary and object files"
arch=(i686 x86_64)
license=(GPL)
options=(!libtool)
url="http://sources.redhat.com/binutils"
depends=('glibc' 'zlib')
source=(ftp://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.bz2)
md5sums=('c84c5acc9d266f1a7044b51c85a823f5')
build() {
cd $srcdir/binutils-${pkgver}
[ $NOEXTRACT -eq 1 ] || ./configure\
--prefix=${PREFIX} \
--program-prefix=${TARGET}- \
--enable-shared \
--disable-multilib \
--with-lib-path=${PREFIX}/lib/binutils/{TARGET} \
--disable-nls \
--target=${TARGET} \
--build=${CHOST} \
--host=${CHOST}
# mkdir -p $pkgdir/${PREFIX}/lib/binutils
sed -i 's|know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));|{know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));}|' gas/config/tc-arm.c || return 1
make configure-host
make tooldir=$pkgdir/${PREFIX}
make prefix=$pkgdir/${PREFIX} tooldir=$pkgdir/${PREFIX} install
mkdir -p $pkgdir/${PREFIX}/lib/binutils/${TARGET}
cp -v include/libiberty.h $pkgdir/${PREFIX}/lib/binutils/${TARGET}
rm -f $pkgdir/${PREFIX}/man/man1/{dlltool,nlmconv,windres}*
rm -f $pkgdir/usr/bin/ar
rm -f $pkgdir/usr/bin/as
rm -f $pkgdir/usr/bin/ld
rm -f $pkgdir/usr/bin/nm
rm -f $pkgdir/usr/bin/objdump
rm -f $pkgdir/usr/bin/ranlib
rm -f $pkgdir/usr/bin/strip
rm -f $pkgdir/usr/bin/objcopy
rm -f $pkgdir/usr/lib/libiberty.a
rm -rf $pkgdir/usr/share
rm -rf $pkgdir/usr/lib/ldscripts
}
gcc-base
pkgname=arm-unknown-eabi-gcc-base
pkgver=4.5.2
pkgrel=1
pkgdesc="The GNU Compiler Collection"
arch=(i686 x86_64)
license=('GPL' 'LGPL')
url="http://gcc.gnu.org"
depends=('arm-unknown-eabi-binutils' 'libmpc' 'libelf' 'cloog-ppl')
options=(!libtool !emptydirs zipman docs !strip)
source=(ftp://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-core-${pkgver}.tar.bz2)
md5sums=('aa9e36bec080452372bfba793428ee82')
build() {
cd $srcdir/gcc-$pkgver
export CFLAGS="-O2 -pipe"
export CXXFLAGS="-O2 -pipe"
[ $NOEXTRACT -eq 1 ] || rm -rf build
mkdir build
cd build
[ $NOEXTRACT -eq 1 ] || ../configure --prefix=${PREFIX} \
--target=${TARGET} \
--host=$CHOST \
--build=$CHOST \
--enable-shared \
--disable-nls \
--enable-languages=c \
--enable-multilib \
--with-local-prefix=${PREFIX}/lib/${TARGET} \
--with-as=${PREFIX}/bin/${TARGET}-as \
--with-ld=${PREFIX}/bin/${TARGET}-ld \
--enable-softfloat \
--with-float=soft \
--with-newlib
make all-gcc all-target-libgcc
make DESTDIR=$pkgdir install-gcc install-target-libgcc
rm -f $pkgdir/usr/share/man/man7/fsf-funding.7*
rm -f $pkgdir/usr/share/man/man7/gfdl.7*
rm -f $pkgdir/usr/share/man/man7/gpl.7*
rm -rf $pkgdir/usr/share/info
cp -r $pkgdir/usr/libexec/* $pkgdir/usr/lib/
rm -rf $pkgdir/usr/libexec
# strip it manually
strip $pkgdir/usr/bin/* 2>/dev/null || true
find $pkgdir/usr/lib -type f -exec arm-none-eabi-strip {} \; 2>/dev/null || true
}
newlib
pkgname=arm-unknown-eabi-newlib
pkgver=1.19.0
pkgrel=1
pkgdesc="Newlib is a C library intended for use on embedded systems."
arch=('i686' 'x86_64')
groups=('devel')
url="http://sourceware.org/newlib/"
license=('GPL')
depends=('arm-unknown-eabi-binutils' 'arm-unknown-eabi-gcc-base')
source=(ftp://sources.redhat.com/pub/newlib/newlib-${pkgver}.tar.gz)
md5sums=('0966e19f03217db9e9076894b47e6601')
build() {
cd ${srcdir}
rm -rf build
mkdir build
cd build
export CFLAGS="-O2"
../newlib-${pkgver}/configure \
--target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
--with-gnu-as \
--with-gnu-ld \
--with-float=soft \
--disable-nls || return 1
make || return 1
make -j1 DESTDIR=${pkgdir} install || return 1
rm -rf ${pkgdir}/usr/share/info
return 0
}
gcc:
pkgname=arm-unknown-eabi-gcc
pkgver=4.5.2
pkgrel=1
pkgdesc="The GNU Compiler Collection - Cross compiler for ARM target"
arch=(i686 x86_64)
license=('GPL' 'LGPL')
url="http://gcc.gnu.org"
#an installed libc/newlib is needed for libstdc++ compile
depends=('arm-unknown-eabi-binutils>=2.18' 'cloog-ppl>=0.15.3' 'arm-unknown-eabi-newlib>=1.18.0')
# cross-arm-none-eabi-gcc is an superset of cross-arm-none-eabi-gcc-base
conflicts=('arm-unknown-eabi-gcc-base')
provides=("arm-unknown-eabi-gcc-base=${pkgver}")
options=(!libtool !emptydirs !strip zipman docs)
source=(ftp://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.bz2)
md5sums=('d6559145853fbaaa0fd7556ed93bce9a')
build() {
cd ${srcdir}/gcc-$pkgver
export CFLAGS="-O2 -pipe"
export CXXFLAGS="-O2 -pipe"
rm -rf build
mkdir build
cd build
../configure \
--prefix=${PREFIX} \
--target=${TARGET} \
--build=${CHOST} \
--host=${CHOST} \
--disable-nls \
--enable-multilib \
--enable-languages=c,c++ \
--enable-__cxa_atexit \
--enable-interwork \
--with-local-prefix=${PREFIX}/lib/${TARGET} \
--with-as=${PREFIX}/bin/${TARGET}-as \
--with-ld=${PREFIX}/bin/${TARGET}-ld \
--with-newlib \
--with-float=soft
make all-gcc all-target-libgcc all-target-libstdc++-v3 || return 1
make DESTDIR=${pkgdir} install-gcc install-target-libgcc install-target-libstdc++-v3 || return 1
rm -f $pkgdir/usr/share/man/man7/fsf-funding.7*
rm -f $pkgdir/usr/share/man/man7/gfdl.7*
rm -f $pkgdir/usr/share/man/man7/gpl.7*
rm -rf $pkgdir/usr/share/info
rm -rf $pkgdir/usr/share/gcc-4.5.2
cp -r $pkgdir/usr/libexec/* $pkgdir/usr/lib/ && \
rm -rf $pkgdir/usr/libexec
}
I already read linux from scratch howto for building cross compilers, though partly it contradicts with AUR comments especially in regard to --with-sysroot and --with-build-sysroot
If someone can please shed some light on this, the gcc doc is not very helpfull
Note: I know that a bare metal arm elf cross compiler exisis in the archlinux repository but that is not sufficient as I need different targets with some special options (where can I get the PKGBUILD from packages within the ABS?)
Offline
This is not exactly "Newbie" stuff. Lets not frighten anyone.
Can you be a little more specific as to what you are trying to achieve? There may be a more direct way to get there with tools that exist.
Otherwise, I think this thread might be moving over to "General Programming" where it will have better visibility amongst those who can help.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Current targets are armv7vfpv3 and armv5te softfloat, this compiler(s) (afaik softfloat and hardfloat can not be put into one compiler, correct me if I am wrong) will be used as basis for kernel compileing for these architectures plus the basic packages (afaik called bootstrapping).
And I knew it was not really newby stuff, but .. well .. after searching like 5 mins for an appropriate subforum I gave up and posted it just here, sorry
The point is this is the basis for a lot of core packages and I just want to do it right (and atm it ain't working at all )
Last edited by drahnr (2011-04-05 22:36:11)
Offline
Moved to General Programming (From Newbie Forum)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
... (where can I get the PKGBUILD from packages within the ABS?)
pacman -S abs
Pulls in the current ABS tree with pkgbuilds. Copy them to your directory of choice and build them like they are from the AUR
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Pages: 1