|
HOWTO build arm-linux toolchain for ARM/XSCALE
----------------------------------------------
These instructions document how to build an arm-linux tool chain
that contains both little-endian and big-endian target libraries.
1. Packages used:
binutils-2.14.tar.gz
gcc-3.3.2.tar.gz
glibc-2.2.5.tar.gz
glibc-linuxthreads-2.2.5.tar.gz
2. binutils-2.14
tar xvzf binutils-2.14.tar.gz
cd binutils-2.14
mkdir xscale_linux_be
cd xscale_linux_be
../configure --target=armbe-linux --prefix=/opt/xscale_linux_be --with-lib-path=/opt/xscale_linux_be/armbe-linux/lib --program-prefix=xscale_linux_be-
make
make install
chmod 777 /opt/xscale_linux_be
3. gcc-3.3.2 -- bootstrap gcc
tar xvzf gcc-3.3.2.tar.gz
cd gcc-3.3.2
cp $(ATTACHED t-linux file) gcc/config/arm/
perl -pi -e 's/GCC_FOR_TARGET = \$\$r\/gcc\/xgcc /GCC_FOR_TARGET = \$\$r\/gcc\/xgcc -mbig-endian /g' Makefile.in
cd gcc
perl -pi -e 's/GCC_FOR_TARGET = \.\/xgcc /GCC_FOR_TARGET = \.\/xgcc -mbig-endian /g' Makefile.in
cd config/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
export PATH=/opt/xscale_linux_be/bin:/opt/xscale_linux_be/armbe-linux/include:$PATH
mkdir xscale_linux_be
cd xscale_linux_be
../configure --program-prefix=xscale_linux_be- --prefix=/opt/xscale_linux_be --target=armbe-linux --disable-shared --disable-threads --with-headers=/home/john_ho/ixp422/src/snapgear/linux-2.4.x/include --with-gnu-as --with-gnu-ld --enable-multilib --enable-languages=c
perl -pi -e 's/^program_transform_cross_name = s,\^,\$\(target-alias\)-,/program_transform_cross_name = s,\^,xscale_linux_be-,/g' gcc/Makefile
make
make install
4. glibc-2.2.5 (big-endian)
tar xvzf glibc-2.2.5.tar.gz
cd glibc-2.2.5
tar xvzf glibc-linuxthreads-2.2.5.tar.gz
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
cd sysdeps/arm
patch -p0 < ../../Patch.armbe-strlen-fix
vi linuxthreads/sysdeps/pthread/pthread.h
- change line 163, "__thread" -> "__thr"
- change line 591, "__thread" -> "__thr"
vi linuxthreads/internals.h
- change line 555, "__thread" -> "__thr"
vi linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h
- change line 36, "__thread" -> "__thr"
vi stdio-common/sprintf.c
- line 30, change to "sprintf(char *s, const char *format, ...)"
vi stdio-common/sscanf.c
- line 30, change to "sscanf(const char *s, const char *format, ...)"
vi sysdeps/unix/sysv/linux/arm/sysdep.h
- line 134, remove "a1" from clobber list
vi sysdeps/arm/dl-machine.h
- add '\n\' to end of all macro asm lines (there is a _lot_ of them)
vi config.make.in
- change "slibdir=@...@" to "slibdir=@libdir@"
vi sysdeps/unix/sysv/linux/arm/ioperm.c
- add include file <linux/input.h> to avoid compile error of BUS_ISA not defined.
mkdir xscale_linux_be
cd xscale_linux_be
export CC="xscale_linux_be-gcc -mbig-endian -finline-limit=10000"
export AR="xscale_linux_be-ar"
export RANLIB="xscale_linux_be-ranlib"
export LD="xscale-linux_be-ld -mbig-endian"
../configure armbe-linux --target=armbe-linux --prefix=/opt/xscale_linux_be/armbe-linux --build=i686-pc-linux-gnu --with-headers=/opt/xscale_linux_be/armbe-linux/sys-include --enable-add-ons=linuxthreads --enable-shared
make
make install
6. gcc-3.3.2 (c++, etc) full version
tar xvzf gcc-3.3.2.tar.gz
cd gcc-3.3.2
cp $(ATTACHED t-linux file) gcc/config/arm/
vi gcc/config/arm/t-linux
- remove all "-Dinhibit_libc" occruances
perl -pi -e 's/GCC_FOR_TARGET = \$\$r\/gcc\/xgcc /GCC_FOR_TARGET = \$\$r\/gcc\/xgcc -mbig-endian /g' Makefile.in
cd gcc
perl -pi -e 's/GCC_FOR_TARGET = \.\/xgcc /GCC_FOR_TARGET = \.\/xgcc -mbig-endian /g' Makefile.in
cd config/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
export PATH=/opt/xscale_linux_be/bin:/opt/xscale_linux_be/armbe-linux/include:$PATH
mkdir xscale_linux_be
cd xscale_linux_be
../configure --program-prefix=xscale_linux_be- --prefix=/opt/xscale_linux_be --target=armbe-linux --enable-multilib --with-headers=/opt/xscale_linux_be/armbe-linux/include --enable-languages=c,c++
perl -pi -e 's/int namelen/unsigned int namelen/' ../libjava/java/net/natInetAddress.cc
[ For big-endian ]
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
cd gcc
perl -pi -e 's/libstdc\+\+ /libstdc\+\+ -mbig-endian /' Makefile
make LDFLAGS="-mbig-endian"
make install
7. gdb-5.1.1
bzip2 -cd gdb-5.1.1.tar.bz2 | tar xvf -
cd gdb-5.1.1
mkdir xscale_linux_be
cd xscale_linux_be
../configure --prefix=/opt/xscale_linux_be --program-prefix=xscale_linux_be- --target=armbe-linux
make
make install
8. cd /
tar cvzf /opt/xscale_linux_be-toolchain-20040511.tar.gz /opt/xscale_linux_be
------------------------------------------------------------------------------
APPENDIX A -- modified t-linux for gcc-3.3.2
------------------------------------------------------------------------------
# Just for these, we omit the frame pointer since it makes such a big
# difference. It is then pointless adding debugging.
TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix
LIBGCC2_DEBUG_CFLAGS = -g0
# Don't build enquire
ENQUIRE=
LIB1ASMSRC = arm/lib1funcs.asm
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
# MULTILIB_OPTIONS = mhard-float/msoft-float
# MULTILIB_DIRNAMES = hard-float soft-float
MULTILIB_OPTIONS = mlittle-endian/mbig-endian
MULTILIB_DIRNAMES = le be
# If you want to build both APCS variants as multilib options this is how
# to do it.
# MULTILIB_OPTIONS += mapcs-32/mapcs-26
# MULTILIB_DIRNAMES += apcs-32 apcs-26
EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h
# Assemble startup files.
$(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/arm/crti.asm
$(T)crtn.o: $(srcdir)/config/arm/crtn.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/arm/crtn.asm
------------------------------------------------------------------------------
------------------------------------------------------------------------------
APPENDIX B -- Patch.armbe-strlen-fix for glibc-2.2.5
------------------------------------------------------------------------------
--- strlen.S.orig 2003-06-30 14:55:04.000000000 +0200
+++ strlen.S 2003-06-30 14:58:16.000000000 +0200
@@ -53,11 +53,20 @@
ldrne r2, [r1], $4 @ and we continue to the next word
bne Laligned @
Llastword: @ drop through to here once we find a
+#ifdef __ARMEB__
+ tst r2, $0xff000000 @ word that has a zero byte in it
+ addne r0, r0, $1 @
+ tstne r2, $0x00ff0000 @ and add up to 3 bytes on to it
+ addne r0, r0, $1 @
+ tstne r2, $0x0000ff00 @ (if first three all non-zero, 4th
+ addne r0, r0, $1 @ must be zero)
+#else
tst r2, $0x000000ff @ word that has a zero byte in it
addne r0, r0, $1 @
tstne r2, $0x0000ff00 @ and add up to 3 bytes on to it
addne r0, r0, $1 @
tstne r2, $0x00ff0000 @ (if first three all non-zero, 4th
addne r0, r0, $1 @ must be zero)
+#endif
RETINSTR(mov,pc,lr)
END(strlen)
------------------------------------------------------------------------------ |
|