simple-arm
Building SimpleScalar/ARM cross compiler based on gcc-2.95.2
This entry talks about my experience in building the SimpleScalar/ARM cross compiler based on gcc-2.95.2
This was built on Ubuntu 8.10 with gcc-3.4 running on a Virtual Machine - Sun Virtual Box, XP Host, x86 Architecture
(The following instructions are an updated version to the instructions in ANNOUNCE.cross fromhttp://www.eecs.umich.edu/~taustin/code/arm-cross/ANNOUNCE.cross)
--
1. Get all packages fromhttp://www.simplescalar.com/v4test.html
cross compiler kit
http://www.eecs.umich.edu/~taustin/code/arm-cross/ANNOUNCE.cross
http://www.eecs.umich.edu/~taustin/code/arm-cross/gcc-2.95.2.tar.gz
http://www.eecs.umich.edu/~taustin/code/arm-cross/binutils-2.10.tar.gz
http://www.eecs.umich.edu/~taustin/code/arm-cross/glibc-2.1.3.tar.gz
2. Untar and expand all 3 .tar.gz files into a single folder. (/home/example/arm-cross)
3. Make sure you have gcc-3.4 installed on the system. (Ubuntu's GCC 4.3.2 did not compile this package)
4. Build and Install binutils
cd binutils-2.10
../configure --target=arm-linux --prefix=/home/example/arm-cross
make
make install
cd ..
5. You should now have a bin/ folder inside arm-cross/. Add this to your path. (If using bash shell, use the below command, modify to fit your shell)
export PATH=$PATH:/home/example/arm-cross/bin
6. Rehash the filesystem to see the newly created executables.
In Ubuntu 8.10, rehash is /usr/bin/c_rehash - no arguments, just executable
7. Now build the GNU GCC cross compiler (This is what gave me the most trouble- after lots of playing around, the following steps worked) [1]
7.a. inside arm-cross/
cd gcc-2.95.2
../configure --prefix=/home/example/arm-cross --target=arm-linux --with-as=/home/example/arm-cross/bin/arm-linux-as
This should configure without any errors.
7.b. Now, edit the Makefile. Inside the Makefile, find and replace 'rmdir' with 'rm -rf' (without the quotes)
7.c The current version of libgcc (as shipped with Ubuntu 8.10) seems to be incompatible with the build environment of the cross compiler, so we are going to build it with STATIC linkage. [2]
make LANGUAGES=c BOOT_LDFLAGS=-static
This should take a while, but should complete without any errors.
If you encounter any errors in this step, check the above steps carefully. Before reattempting to build, always do a 'make distclean'. This will purge all files that were created during the make process and allow you to start afresh. One of the side effects of make distclean is that it will also remove the Makefile. Hence you will have to begin at the ./configure step again.
If this passes successfully, install the package using the below:
make LANGUAGES=c install
At this point you have the compiler installed and working.
Here's the output of the version string as reported by the cross compiler at this stage:
example@machine:~/$ arm-linux-gcc -v
Reading specs from /home/example/arm-cross/lib/gcc-lib/arm-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
8. Now follow the instructions in ANNOUNCE.cross to fix the specs
vim /home/example/arm-cross/lib/gcc-lib/arm-linux/2.95.2/specs
replace all occurrences of "elf32arm" with "armelf_linux",
this fixes an innocuous incompatibility between the most
recent GCC and GLIBC libraries...
9. You now have a working arm-cross compiler that can produce binaries that can be run on SimpleScalar/ARM
arm-linux-gcc example_code.c -o object_file.o
Now run object_file.o using the appropriate simplescalar tool.
-------------------------------------------------------------
[1]
To fix error with xgcc
from http://sourceware.org/ml/crossgcc/2001-02/msg00081.html
use an explicit "--with-as=/path/to/as" on the gcc configure line
[2]
This fixes the set of messages:
ibgcc1.S: Assembler messages:
libgcc1.S:1: Warning: rest of line ignored; first ignored character is `@'
libgcc1.S:2: Warning: rest of line ignored; first ignored character is `@'
from
https://www.linuxquestions.org/questions/linux-general-1/arm-toolchain-problem-350988/
use the BUILD_LDFLAGS=-static
source: http://suneilmohan.blogspot.com/2009/02/building-simplescalararm-cross-compiler.html
Things I needed to do to get it to work on gcc
export PATH=$PATH:<path to cross compiler>/bin
./configure --target=arm-linux --prefix=<path to cross compiler> --with-as=<path to cross compiler>/bin/arm-linux-as
make LANGUAGES=c CFLAGS=-D_FORTIFY_SOURCE=0 BOOT_LDFLAGS=-static
make LANGUAGES=c CFLAGS=-D_FORTIFY_SOURCE=0 BOOT_LDFLAGS=-static install