Sunteți pe pagina 1din 6

This guide describes the installation procedure of SimpleScalar simulator and its

companion cross-compiler on Lab machines. It has been tested on


hydra.cs.auckland.ac.nz and some of the Debian boxes in the Undergraduate Lab at
1st floor.

1. Download and unpack the source files


The source files can be downloaded from www.simplescalar.com under the
section of Download -> Tools. There are four files that are needed for this installation.
- simplesim-3v0c.tgz
- simpleutils-990811.tar.gz
- gcc-2.7.2.3.ss.tar.gz
- simpletools-2v0.tgz
Use gunzip < file.tgz | tar xvf - to unzip
- simplesim-3v0c.tgz
- simpletools-2v0.tgz

Use gunzip < file.tar.gz | tar xvf – to unzip


- gcc-2.7.2.3.ss.tar.gz
- simpleutils-990811.tar.gz

After this step we should have the following folders:


- f2c-1994.09.27
- gcc-2.6.3
- gcc-2.7.2.3
- glibc-1.09
- simplesim-3.0
- simpleutils-990811
- ssbig-na-sstrix
- sslittle-na-sstrix
And one file:
- Readme.gcc-2.7.2.3

2. Set up flex
flex is a program that does some lexical analysis work for the utility tools that we
are trying to compile in step 4. We have known issues with the system default 2.5.31
version of flex and the kind admin of our beloved lab had put a more stable version of
2.5.4 of flex on both hydra and lab Debian boxes. Now we need to make a symbolic
link of flex-2.5.4 and put that on to our PATH environment variable.
- make the symbolic link of flex-2.5.4
ln –s /usr/local/bin/flex-2.5.4 flex
The above command will generate a symbolic link called flex which point to
/usr/local/bin/flex-2.5.4. We also need to set up the PATH variable so that we can use
this symbolic link when we call flex rather than using the system default version of
flex.
- set up the PATH, assuming that we put the symbolic link in folder
yourunixhome/bin
export PATH=yourunixhome/bin:$PATH
To test whether we set up the PATH correctly, use flex --version. If the version
number is 2.5.4, we are sure that we get it right.

3. Set up environment variables


export IDIR=/your installation directory
export HOST=i686-pc-linux
export TARGET=sslittle-na-sstrix

4. Install the simpleutils, which contains a few tools the cross-compiler will be using
in step 6
Before we start the installation of the simpleutils, we have to make sure that we
are using the right version of flex by the following command:
flex --version
We need version 2.5.4 in order to proceed because version 2.5.31 has known
issues with our installation. If you haven’t set up flex, stop here and read step 2,
otherwise you will encounter different kinds of errors we describe below.
If the version of flex is right, we are ready to precede the installation using the
following instructions.
cd $IDIR/simpleutils-990811
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld
--prefix=$IDIR
make
make install
5. Build SimpleScalar 3.0
This step is easy. Just use the following instructions.
cd $IDIR/simplesim-3.0
make config-pisa
make
After a successful setup, we should have last line saying “my work is done here”.
Or we could test by:
cd $IDIR/simplesim-3.0
./sim-safe tests/bin.little/test-math

6. Install the gcc cross-compiler for SimpleScalar


This gcc cross-compiler will compile code for the SimplScalar PISA instruction
set, therefore it is very critical to the simulation that we will run later. The gcc
cross-compiler is very delicate since we are using a quite old version of it. There are a
few errors that we will encounter but we have got solutions to them so let’s start.
cd $IDIR/gcc-2.7.2.3
export PATH=$PATH:$IDIR/sslittle-na-sstrix/bin (This line must be there)
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld
--prefix=$IDIR
make LANGUAGES=c

During make process, we might have the following errors:

1. Error in insn-output.c, error messages like the following:

cc -DCROSS_COMPILE -DIN_GCC -g -I. -I. -I./config -c


insn-output.c

insn-output.c:675:10: missing terminating " character

insn-output.c: In function `output_110':

insn-output.c:676: error: parse error before "sll"

……..(omit 50 lines of error messages)

make: *** [insn-output.o] Error 1

Solution:

Edit insn-output.c

- append ‘\’ at the end of at line 675

- append ‘\’ at the end of at line 750

- append ‘\’ at the end of at line 823

2. Error about stdio.h, error messages like the following:

In file included from ./libgcc2.c:1419:

stdio.h:167: parse error before `void'

make: *** [libgcc2.a] Error 1

Solution:

Edit Makefile at line 130, append –I/usr/include to the end of the line.
3. Error in objc/sendmsg.c, error messages like the following:

sendmsg.c:36: parse error

make[1]: *** [sendmsg.o] Error 1

make[1]: Leaving directory


`/afs/ec.auckland.ac.nz/users/xyz/unixhome/ss/gcc-2.7.2.3/objc'

make: *** [libobjc.a] Error 2

Solution:

In objc/sendmsg.c, insert "#define INVISIBLE_STRUCT_RETURN 0" at


line 35, and delete line 36 to 40 inclusive.

4. Error with protoize.c, error messages like the following:

In file included from protoize.c:60:

/usr/lib/gcc-lib/i486-linux/3.3.5/include/varargs.h:4:2: #error "GCC no


longer implements <varargs.h>."

/usr/lib/gcc-lib/i486-linux/3.3.5/include/varargs.h:5:2: #error "Revise


your code to use <stdarg.h>."

make: *** [stamp-proto] Error 1

Solution:

In protoize.c line 60, replace "#include <varargs.h>" with "#include


<stdarg.h>".

5. When running a program which involves input from a file, the input stream is
disrupted without warning, do the following:

Replace the cdefs.h in IDIR/sslittle-na-sstrix/include/sys with the one


under IDIR/gcc-2.7.2.3/patched/.

make enquire

../simplesim-3.0/sim-safe ./enquire -f > float.h-cross

make install

Test the gcc cross-compiler by type the following lines into hello.c
#include<stdio.h>
main()
{
printf("Hello World!\n");

then compile the hello.c using the following:

$IDIR/bin/sslittle-na-sstrix-gcc hello.c

It should generate a.out without trouble.

Run the simulator using a.out as input:

$IDIR/simplesim-3.0/sim-safe a.out

In the output, you should be able to find the following:

sim: ** starting functional simulation **

Hello World!

And also can test the cross-compiler by

$IDIR/sslittle-na-sstrix/bin/gcc –v

It should generate something like the following:

Reading specs from


/afs/ec.auckland.ac.nz/users/xyz/unixhome/simplescalar/lib/gcc-lib/sslittle-na-
sstrix/2.7.2.3/specs

To compile program for SimpleScalar simulator:

sslittle-na-sstrix/bin/gcc program.c

Run the generated a.out use the following:


simplesim-3.0/sim-safe a.out

WARNING: install simplescalar might depend on the order of unzipping


files. Suggestion: unzip simpleutils-990811.tar.gz at the very last step.

Reference:
SimpleScalar installation guide, downloaded from the following url:
http://www.simplescalar.com/docs/install_guide_v2.txt
SimpleSclar installation guide prepared by Pan Yu of National University of
Singapore, http://www.comp.nus.edu.sg/~panyu/simplesim.htm
Special thanks to Dr. Bruce Hutton, Dr. Douge Burger and Alvan Tan for their kind
advise for solving problems that are encountered in making this paper.

S-ar putea să vă placă și