Subject: Tool Chain woes

From: Systems Administrator <[email-masked]>
Date: Wed, 2 Aug 2000 16:50:57 -0700

I have spent about 2 weeks trying to make a tool chain for my assabet box.  I
can't seem to make the glibc part and I get different errors depending on the
phase of the moon (or so it seems).  I the hope that I am doing the same
stupid thing over and over I have included all of the particulars for the
perusal of all who might be interested.  I hope someone can tell me I'm doing
something really stupid, and then I can fix it and get on with real life:

I am using the following ingredients:

ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.0-test4.tar.gz
ftp://ftp.arm.linux.org.uk/pub/armlinux/people/nico/diff-2.4.0-test4-np1.gz
binutils-2.9.5.0.22 
(no patches)
ftp://ftp.kernel.org/pub/mirrors/gnu/gcc/gcc-2.95.2,tar.gz
patch gcc-2.95-diff-990730
ftp://ftp.kernel.org/pub/mirrors/gnu/glibc/glibc-2.1.3.tar.gz
ftp://ftp.kernel.org/pub/mirrors/gnu/glibc/glibc-crypt-2.1.tar.gz
ftp://ftp.kernel.org/pub/mirrors/gnu/glibc/glibc-linuxthreads-2.1.3.tar.gz

#This is the top of the architecture development area
#for developing cross compliers and other support
#for various architectures like the StrongArm processor.
#The entire set is exported from the file server

export NFS=/nfs/tools

#It has also been decided that the "tars" directory and
#the "rpms" directory at this level will contain all of
#the different versions of all the software.

export TARS=${NFS}/tars
export RPMS=${NFS}/rpms

#Also at this level we have the kernel version directories.
#Each diectory (e.g. 2.4.0) contains a unique linux source tree.
#The Linux tree contains the architecture components within
#itself.  That is to say that the expanded kernel source is
#found in $KERNEL, and the archicture specific modules for
#various machines are located below that.

export KERNEL=$NFS/kernel/2.4.0/linux
[ ! -f $KERNEL ] && mkdir -p $KERNEL

#First we must install the kernel source and headers which will
#be referenced when building the compilers and libraries in the
#tool trees.  Each new kernel version build requires an un-tar,
#patch, configure, make , and make modules.

cd $KERNEL
cd ..

#The kernel headers for the linux kernel must first be corrected
#and this is done by untaring the kernel "2.4.0-test4" and
#patching it with "diff-2.4.0-test4-np1" (see the README) in
#the $NFS/tars directory for the source of these items.

tar xzf $NFS/tars/linux-2.4.0*
patch -p0 < $NFS/tars/diff-2.4.0-test4-np1

cd $KERNEL

make menuconfig
make dep
	
#--  that is all for now -- we must have a tool chain
#before we can actually build the compiler.  So! 

#Immediatly below $NFS and parallel to
#the various kernel source versions we have the architecture
#dependant "tool chain" level (gcc, glibc, etc) for the particular
#processor type (e.g. for arm). One or more "tool chain"'s will
#be expanded at this level and as such the arch name
#will include a version identity (e.g. armv1). A README file in the
#top arch directory will describe the particular set of
#source versions and kernel includes used in creating this particular
#tool chain version.

export ARCH=${NFS}/armv1
[ ! -d $ARCH ] && mkdir $ARCH

The sources will be expanded in $WORK/src/xxx and
#the associated objects in $WORK/obj/xxx. Hence:

export WORK=${NFS}/work
[ ! -d $WORK ] && mkdir $WORK
[ ! -d ${WORK}/src ] && mkdir ${WORK}/src
[ ! -d ${WORK}/obj ] && mkdir ${WORK}/obj

#For each architecture the "binary utilities" must be built
#first.  This process assumes a running gcc compiler on the
#host where the crosscomplier is being built.  The "binutils"
#source tar is downloaded into the "tars" directory.  Then
#cd to the "src" directory and untar it

cd $WORK/src
tar -xzf $NFS/tars/binutils*

mkdir $WORK/obj/binutils
cd  $WORK/obj/binutils

$WORK/src/binutils*/configure --target=arm-linux --prefix=$ARCH

make
make install

#And the binary utilities and supporting goodies will have been installed 
#in $ARCH and $ARCH/arm-linux

#Now we create the include directory
#in the $ARCH/arm-linux directory and place 2 links into it:

mkdir $ARCH/arm-linux/include
cd $ARCH/arm-linux/include
ln -s $KERNEL/include/asm-arm asm
ln -s $KERNEL/include/linux linux

#Now we are ready to build the compiler:

cd $WORK/src
tar -xzf $NFS/tars/gcc-2.95.2*
cd $WORK/src/gcc-2.95.2
	
#if the patch below has not yet been unzipped then unzip it
#before you try to apply it

patch -p0 < $NFS/tars/gcc-2.95-diff-990730

#then you must alter the file gcc/config/arm/linux-elf.h to change
#the first occurance of "#if 0"  to "#if 1" (I have no idea why
#this is true and whatever it is will probably be fixed soon.  I
#got a tip from the Good Fairy.  You can ivestigate the code if
#you wish)

#then you must alter gcc/config/arm/t-linux so as to not need
#libc headers on this initial build.  That is done by changing
#the line which says:

#"TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC"
#to say 
#"TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC \
-Dinhibit_libc -D__gthr_posix_h"

#This will be changed back after glibc is built and installed and then we can
#rebuild the compiler AND g++ and Objective-c and such (won't 
need LANGUAGES=c).

mkdir $WORK/obj/gcc-2.95.2
cd $WORK/obj/gcc-2.95.2
$WORK/src/gcc-2.95.2/configure arm-linux --prefix=$ARCH  \
--with-cpu=strongarm110 --disable-threads

make LANGUAGES=c
make LANGAUGES=c install

#  At this point we should have a C crosscompiler for a StrongArm system
#
#  But we are not done yet because we will need to build the c libraries and
#such so that we can create and maintain all the other stuff that makes a
#real Linux.  So even before we use the new compiler to make the kernel we
#will go ahead and build "glibc"
#

#Define the c complier as the just installed arm-linux-gcc

export CC=arm-linux-gcc

!!!!!!!!!!!!   W A R N I N G   !!!!!!  W A R N I N G   !!!!! 

#you MUST have $ARCH/bin in your path at this time 
#If not then arm-linux-gcc is not found.

cd $WORK/src
tar xzf $NFS/tars/glibc-2.1.3.tar.gz
cd glibc-2.1.3
tar xzf $NFS/tars/glibc-linuxthreads-2.1.3.tar.gz
tar xzf $NFS/tars/glibc-crypt-2.1.tar.gz

#there seems to be no patch file for glic at this time

mkdir $WORK/obj/glibc-2.1.3
cd $WORK/obj/glibc-2.1.3 
$WORK/src/glibc-2.1.3/configure arm-linux --build=i586-linux
\ --prefix=$ARCH/arm-linux  --enable-add-ons

make
make install
make[1]: Entering directory `/nfs/arch/work/src/glibc-2.1.3/misc'
arm-linux-gcc ../sysdeps/unix/syscall.S -c  -I../include -I.  -I.. -I../libio  
-I../sysdeps/arm/elf -I../crypt/sysdeps/unix
-I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread
-I../linuxthreads/sysdeps/unix/sysv -I../linuxthreads/sysdeps/unix
-I../linuxthreads/sysdeps/arm -I../sysdeps/unix/sysv/linux/arm
-I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common
-I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv
-I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm/fpu
-I../sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754
-I../sysdeps/libm-ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic  
-D_LIBC_REENTRANT -include ../include/libc-symbols.h     -DASSEMBLER   -o
syscall.o ../sysdeps/unix/syscall.S: Assembler messages:
../sysdeps/unix/syscall.S:28: Error: Can not represent SWI relocation in this
object file format (0) make[1]: *** [syscall.o] Error 1 make[1]: Leaving
directory `/nfs/arch/work/src/glibc-2.1.3/misc' make: *** [misc/subdir_lib]
Error 2

-- 
Mike Coburn
Sys. Admin.

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]
++        Please use [email-masked] for           ++
++                        kernel-related discussions.                      ++

---

From: Philip Blundell <[email-masked]>
Date: Thu, 03 Aug 2000 18:38:44 +0100

>directory `/nfs/arch/work/src/glibc-2.1.3/misc' make: *** [misc/subdir_lib]

Run that command with the "-o syscall.o" removed and -c changed to -E, and 
find the `swi' instruction.  Then find out why the macro that makes up its 
argument isn't being substituted.  All the __NR_xx constants should be defined 
by <asm/unistd.h>.

p.