Wednesday, December 3, 2014

[Installation Instructions] Procedure to install simple scalar on Ubuntu

The following are the instructions to setup the simplescalar toolset on linux system. I have tested them on Ubuntu 10.04 i686 and x86_64 machine with gcc 4.4.3.
You can either set it up on your ubuntu installation on your pc or set it up on your account in gcl.
If you want to try out the simulator without taking the pain of installation, you can append the following paths to the PATH environmental variable in your gcl account:

export PATH=$PATH:/home/dual/cs5070217/simplescalar/bin
export PATH=$PATH:/home/dual/cs5070217/simplescalar/simplesim-3.0
But it is highly recommended that you install it right away as the assignments will focus on editing the source code of the simulator.



1. Necessary Files:
Download the necessary Source code files:

2. Setting up the Environment:
  • Find out the machine hardware name by running the following command on the terminal:
    uname -m 
  • Use this to set the HOST environment variable as i686-pc-linux or i386-pc-linux etc. Even if you have a 64 bit machine (machine name x86_64) use i686 itself. We will be using it as 32 bit installation even on the 64 bit machine.
    Now set the following three environmental variables:
    export HOST=FROM_ABOVE_OPTION
    export IDIR=
    export TARGET=sslittle-na-sstrix
  • Create the installation directory, i.e. $IDIR and copy All the installations files downloaded into the same
    mkdir $IDIR
    Make sure you have the following packages installed on your system.
    • flex
    • bison
    • build-essential
    You can install these packages using :
    sudo apt-get install

3. Installing simpletools:
  • Unpack the compressed file and remove the gcc folder(older version, we'll be using a newer one)
    cd $IDIR
    tar xzvf simpletools-2v0.tgz
    rm -rf gcc-2.6.3

4. Installing simpleutils:
  • Unpack the package:
    tar xzvf simpleutils-990811.tar.gz
    cd simpleutils-990811
  • Now one change in the code needs to be done:
  • In the file ld/ldlex.l change all occurrences of yy_current_buffer with YY_CURRENT_BUFFER
  • Install using following commands:
    ./configure -host=$HOST -target=$TARGET -with-gnu-as -with-gnu-ld -prefix=$IDIR
    make
    make install

5. Installing simulator:
  • Unpack the simulator:
    cd $IDIR
    tar xzvf simplesim-3v0d.tgz
    cd simplesim-3.0
    make config-pisa
    make
    Congratulations! You have installed the simulator. The battle is half won.
  • Test your installation by running a sample program:
    ./sim-safe tests/bin.little/test-math

6. Installing the cross compiler:
  • Unpack the compiler and append the path to sslittle-na-sstrix/bin to the environmental variable PATH
    cd $IDIR
    tar xzvf gcc-2.7.2.3.ss.tar.gz
    cd gcc-2.7.2.3
    export PATH=$PATH:/home/YOUR_USER_NAME/simplescalar/sslittle-na-sstrix/bin
    ./configure -host=$HOST -target=$TARGET -with-gnu-as -with-gnu-ld -prefix=$IDIR
  • Change permissions to edit the files:
    chmod -R +w .
  • Next, you need to do some changes in the code:
  • Change the line number 130 of the Makefile to:
    GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) -I./include -I/usr/include
    i.e., add -I/usr/include towards the end of the line
  • At line number 60 of protoize.c change
    varargs.h
    to
    stdarg.h

  • At line number 341 of obstack.h change
    *((void **)__o->next_free)++=((void *)datum); 
    
    to
    *((void **)__o->next_free++)=((void *)datum);
  • Now copy the following files as shown:
    cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h
    cp ../sslittle-na-sstrix/lib/libc.a ../lib/
    cp ../sslittle-na-sstrix/lib/crt0.o ../lib/
    *If you dont find the patched directory and libc.a/crt0.o, you probably didnt untar it properly. Use 'tar' on command-line again.
  • Download the ar_and_ranlib.tar.gz file and extract it.
  • Replace the ar and ranlib file in $IDIR/sslittle-na-sstrix/bin with the above extracted files.
    You might need to set appropriate permissions for these files. You can do that by:
    chmod +w
  • Compile using:
    make
  • Now in the file insn-output.c, change line 675, 750 and 824 from
    return "FIXME\n
    to
    return "FIXME\n\
  • Compile again
    LANGUAGES="c c++" CFLAGS="-O" CC="gcc -m32"
  • At line number 35 of the file objc/sendmsg.c add:
    #define STRUCT_VALUE 0
  • Run the following commands:
    cd $IDIR/gcc-2.7.2.3
    make LANGUAGES="c c++" CFLAGS="-O" CC="gcc -m32"
  • Now edit the generated cxxmain.c file and remove line number 2978-2979
    i.e. Remove
    char * malloc ()
    char * realloc ()
  • Lastly, pray for the good health of Dr. Todd Austin and run the final commands:
    make LANGUAGES="c c++" CFLAGS="-O" CC="gcc -m32"
    make install LANGUAGES="c c++" CFLAGS="-O" CC="gcc -m32"
    This should set up your system for running the simplescalar toolset.
  • Last piece of advice, add the cross-compiler bin path permanently to the PATH environmental variable by editing your .bashrc as:
    export PATH=$PATH:< simplescalar installation path >/bin
    export PATH=$PATH:< simplescalar installation path >/simplesim-3.0

I hope these instructions are exhaustive enough. Still, if you get stuck somewhere, do not hesitate to google out the solution.

Instructions: courtesy IITD

No comments:

Post a Comment