You'll find below the build procedure we have used to make a
gcc big endian
cross toolchain for Intel IXP2400 which contains an ARM
XScale core. I think
this procedure is valid for any ARM target.
http://www.linux-france.org/~dmentre/doc/en/
I have managed to add to the good work that David has done and
implemented C++ support, which was missing.
Here is the a script that I now use to build my toolchains for IXP425
developement boards.
I would appreciate any comments. Its a work in progress.
---------------------------------------------------------
## NOTE: THIS Program is in ALPHA!!! As Such I could use some
suggestions.
####################################################
##
## Purpose: To AutoMagically install, apply patches and create a
toolchain.
##
## Author: Jeremy McNicoll, ***@mcnicoll.ca
##
## Credits: Arm mailing lists
## Cross compiler Mailing Lists
## Version 1.5 / 2003-05-15, toolchainHowto
(http://www.linux-france.org/~dmentre/doc/en/)
## David MENTRE <***@tcl.ite.mee.com>
## Mathieu BERTRAND <***@tcl.ite.mee.com>
## Robert Schiele's <***@uni-mannheim.de> GCC cross compiler
tutorial from the
## GCC Summit tutorial
(http://www.gccsummit.org/2003/view_abstract.php?talk=35)
##
##
## Problem:
## There has been alot of buzz recently on creating an arm cross
compile toolchain
## on the mailing lists. I too needed to have a toolchain for a
project that I am
## working on at school(http://www.carleton.ca). There are already
toolchains that
## can be downloaded on the net, but I had no luck in getting the C++
to work.
## So since this is a school project I decided to create my own script
for installing
## and creating a toolchain.
##
## Solution:
## Using some of the stuff that was available on the internet,
mainly the howto that
## David Mentre posted as a starting point. Then I added C++
support to the toolchain.
## This proved to be difficult but doable. YEE HA!!!!
##
## Assumptions:
## 1) You have downloaded , patched and configured the kernel
## for your target.
## 2) The following files are located in the same location as this
scripts:
## binutils-2.13.1.tar.gz
## gcc-3.2.3.tar.gz
## glibc-2.2.5.tar.gz
## glibc-linuxthreads-2.2.5.tar.gz
##
## Bugs Patched for:
## http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=8896
##
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/sysdeps/p
thread/pthread.h?cvsroot=glibc
##
##
## Testing:
## All Testing was done on a clean Mandrake 9.1 system.
##
## ToDO:
## -Get XScale (armv5b) working.
## -Command line parameters
## -Make it somewhat interactive with the user
## -test with GCC 3.3
##
## Extras:
## [***@project bin]$ ./arm-linux-g++ -v
## Reading specs from ./../lib/gcc-lib/arm-linux/3.2.3/specs
## Configured with: ./configure --target=arm-linux
--prefix=/usr/local/arm-tools i686-pc-linux-gnu
--with-headers=/usr/local/arm-tools/include --enable-languages=c,c++
## Thread model: posix
## gcc version 3.2.3
##
## Tips:
## for VI users to do a global search and replace use
## :%s/gcc-3.2.3/gcc-3.3/g
##
####################################################
#!/bin/sh -e
PREFIX=/usr/local/arm-tools
KERNEL=/ixp425/Kernel_Source/linux-2.4.19
HOST=i686-pc-linux-gnu
TARGET=arm-linux
echo "Setting the CC variable"
CC=/usr/bin/gcc
echo "CC is now set to $CC"
echo " "
##################################################
# Check to see if we have the required files first
##################################################
if [ "$KERNEL" = "" -o ! -f "$KERNEL/Documentation/arm/README" ]; then
echo "You haven't changed KERNEL to point at a valid kernel tree"
exit 1
fi
if [ ! -f binutils-2.13.1.tar.gz ]; then
echo Binutils 2.13.1 seems to be missing
exit 1
fi
if [ ! -f gcc-3.2.3.tar.gz ]; then
echo GCC 3.2.3 seems to be missing
exit 1
fi
if [ ! -f glibc-2.2.5.tar.gz ]; then
echo glibc-2.2.5.tar.gz seems to be missing
exit 1
fi
if [ ! -f glibc-linuxthreads-2.2.5.tar.gz ]; then
echo glibc-linuxthreads-2.2.5.tar.gz seems to be missing
exit 1
fi
##########################
### Copy everything over!
#########################
rm -rf $PREFIX
mkdir -p $PREFIX
mkdir -p $PREFIX/$TARGET/
mkdir -p $PREFIX/$TARGET/include
mkdir -p $PREFIX/$TARGET/include/linux/asm
mkdir -p $PREFIX/$TARGET/include/asm
cp -fr $KERNEL/include/linux $PREFIX/$TARGET/include
cp -fr $KERNEL/include/asm-arm/* $PREFIX/$TARGET/include/linux/asm/.
cp -fr $KERNEL/include/asm-arm/* $PREFIX/$TARGET/include/asm/.
######################
# Do Binutils
######################
rm -rf binutils-2.13.1
tar zvxf binutils-2.13.1.tar.gz
pushd binutils-2.13.1
./configure --target=arm-linux --prefix=$PREFIX
make LDFLAGS="-mbig-endian"
make install
popd
rm -rf binutils-2.13.1
###################
##Finished BinUtils
###################
##################
# Start GCC
#################
echo "Starting GCC First Pass!!!"
rm -rf gcc-3.2.3
echo "UnCompressing GCC"
tar zvxf gcc-3.2.3.tar.gz
echo "Finished Uncompressing GCC"
pushd gcc-3.2.3
perl -pi -e 's/^(TARGET_LIBGCC2_CFLAGS.*)/$1 -Dinhibit_libc
-D__gthr_posix_h/' gcc/config/arm/t-linux
echo "Changing GCC for BigEndian\n"
perl -pi -e 's/GCC_FOR_TARGET = \$\$r\/gcc\/xgcc /GCC_FOR_TARGET =
\$\$r\/gcc\/xgcc -mbig-endian /g' Makefile.in
##This is a known bug
#http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=8896
##But you dont have to do this for GCC 3.3
pushd gcc
patch -p0 < /ixp425/TOOLS/ToolChain/Patch.pr8896
perl -pi -e 's/GCC_FOR_TARGET = \.\/xgcc /GCC_FOR_TARGET = \.\/xgcc
-mbig-endian /g' Makefile.in
pushd config
pushd arm
##By default it compiles for little endian, so we have to change that to
big endian
perl -pi -e 's/^# MULTILIB_OPTIONS =
mlittle-endian\/mbig-endian/MULTILIB_OPTIONS +=
mlittle-endian\/mbig-endian/' t-arm-elf
perl -pi -e 's/^# MULTILIB_DIRNAMES = le be/MULTILIB_DIRNAMES +=
le be/' t-arm-elf
perl -pi -e 's/^# MULTILIB_MATCHES = mbig-endian=mbe
mlittle-endian=ml/MULTILIB_MATCHES += mbig-endian=mbe
mlittle-endian=ml/' t-arm-elf
popd
popd
popd
echo 'T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h' >>
gcc/config/arm/t-linux
PATH=$PREFIX/bin:$PREFIX/$TARGET/include:$PATH
echo "Setting the CC variable"
CC=/usr/bin/gcc
echo "CC is now set to $CC"
echo " "
./configure --target=arm-linux --prefix=$PREFIX $HOST
--with-headers=$PREFIX/include --disable-shared --disable-threads
--enable-languages="c"
make LDFLAGS="-mbig-endian"
make install
popd
rm -rf gcc-3.2.3
#######################
# Start GLIBC
#######################
rm -rf glibc-2.2.5
tar zvxf glibc-2.2.5.tar.gz
tar -C glibc-2.2.5 -zvxf glibc-linuxthreads-2.2.5.tar.gz
pushd glibc-2.2.5
perl -pi -e
's/i386/arm*)\n\tlibc_cv_gcc_unwind_find_fde=yes\n\tarch_minimum_kernel=
2.0.10\n\t;;\n i386/' sysdeps/unix/sysv/linux/configure
perl -pi -e 's/weak_alias \(__old_sys_nerr/\/\/ $&/'
sysdeps/unix/sysv/linux/arm/errlist.c
perl -pi -e 's/weak_alias \(__old_sys_nerr/\/\/ $&/'
sysdeps/unix/sysv/linux/errlist.c
popd
rm -rf build-glibc/
mkdir build-glibc
pushd build-glibc
perl -pi -e 's/__thread/__thread_param/'
../glibc-2.2.5/linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h
perl -pi -e 's/__thread/__thread_param/'
../glibc-2.2.5/linuxthreads/sysdeps/pthread/pthread.h
CC="$TARGET-gcc -mbig-endian" AR=$TARGET-ar RANLIB=$TARGET-ranlib
LD="$TARGET-ld -mbig-endian"
../glibc-2.2.5/configure $TARGET --target=$TARGET
--build=i686-pc-linux-gnu --with-headers=$PREFIX/$TARGET/include
--enable-add-ons=linuxthreads --enable-shared --prefix=$PREFIX/$TARGET
perl -pi -e 's/arm-linux-gcc/arm-linux-gcc -mbig-endian/' config.make
make LDFLAGS="-mbig-endian"
make install
popd
echo "Finished GLIBC , Now doing GCC for a Second Time"
echo " "
echo " "
rm -rf glibc-2.2.5
##################################
## Finish GLIBC
##################################
##################################
## Gcc a second time
##################################
tar zxvf gcc-3.2.3.tar.gz
pushd gcc-3.2.3
echo "Changing GCC for BigEndian\n"
perl -pi -e 's/GCC_FOR_TARGET = \$\$r\/gcc\/xgcc /GCC_FOR_TARGET =
\$\$r\/gcc\/xgcc -mbig-endian /g' Makefile.in
pushd gcc
patch -p0 < /ixp425/TOOLS/ToolChain/Patch.pr8896
perl -pi -e 's/GCC_FOR_TARGET = \.\/xgcc /GCC_FOR_TARGET = \.\/xgcc
-mbig-endian /g' Makefile.in
pushd config
pushd arm
perl -pi -e 's/^# MULTILIB_OPTIONS =
mlittle-endian\/mbig-endian/MULTILIB_OPTIONS +=
mlittle-endian\/mbig-endian/' t-arm-elf
perl -pi -e 's/^# MULTILIB_DIRNAMES = le be/MULTILIB_DIRNAMES +=
le be/' t-arm-elf
perl -pi -e 's/^# MULTILIB_MATCHES = mbig-endian=mbe
mlittle-endian=ml/MULTILIB_MATCHES += mbig-endian=mbe
mlittle-endian=ml/' t-arm-elf
popd
popd
popd
PATH=$PREFIX/bin:$PREFIX/$TARGET/include:$PATH
CC="$TARGET-gcc -mbig-endian" AR=$TARGET-ar RANLIB=$TARGET-ranlib
LD="$TARGET-ld -mbig-endian"
echo "Setting the CC variable"
CC=/usr/bin/gcc
echo "CC is now set to $CC"
echo " "
./configure --target=$TARGET --prefix=$PREFIX $HOST
--with-headers=$PREFIX/include --enable-languages="c,c++"
perl -pi -e 's/^CC_FOR_TARGET = \$\$r\/gcc\/xgcc/CC_FOR_TARGET =
\$\$r\/gcc\/xgcc -mbig-endian /' Makefile
perl -pi -e 's/\$\$r\/gcc\/ -nostdinc\+\+ /\$\$r\/gcc\/ -nostdinc++
-mbig-endian /' Makefile
pushd gcc
perl -pi -e 's/libstdc\+\+ /libstdc\+\+ -mbig-endian /' Makefile
popd
perl -pi -e 's/int namelen/unsigned int namelen/'
libjava/java/net/natInetAddress.cc
echo " "
echo " *********** "
echo " Now Running Make for Gcc The second time!!"
##I had to use the -i because after the C cross compiler is made
## there is another configure done which craps out when testing the
## C++ Xcompiler. But since we dont have one then it wotn work. Thsi
##step in the configure script should be ommited.
make -i LDFLAGS="-mbig-endian"
make install
popd
rm -rf gcc-3.2.3
echo " "
echo " "
echo " Good Bye All Done!"
echo "Thats It for now folks..."
exit 1
-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php