Simplescalar installation made simple

Preface

The following text describes the procedure of installation of Simple Scalar on Linux distro – Ubuntu. It was tested on Ubuntu 9.04 by me, and 8.10. The sources used while writing the post have been listed at the bottom and they hold the highest credit.

Update:
[September 23rd 2009] – It has been tested on Redhat too with the exception of omitting/avoiding Error  #1 of GCC Cross Compiler installation
[August 14th 2011] – Check the video tutorial for Installation of SimpleScalar.

Necessary Files

Download the necessary Source code files.

(Just for precaution, I’ve uploaded to my web-host in case the actual source is not available. The link igoY.in directs to my host space)

Simpletools-2v0.tgz – igoY.in | Simplescalar.com

Simplesim-3v0d.tar.gz – igoY.in | Simplescalar.com

Simpleutils-990811.tar.gz – igoY.in | Simplescalar.com

Gcc-2.7.2.3.ss.tar.gz – igoY.in

Setting up environment

Open up the terminal and type

uname -a

You will get to know your kernel version and the type of linux installed (i386/i686)

Depending on that change the Host id below as either
HOST=i686-pc-linux or HOST=i386-pc-linux

$ export HOST=FROM_ABOVE_OPTION
$ export IDIR=/home/YOUR_USER_NAME/simplescalar
$ export TARGET=sslittle-na-sstrix

(If you use tcsh or the like, the only difference should be in how environment variables are set.)

Create the directory “simplescalar” under your home directory and copy all the four tar files into it. To do so, use the following commands.

$ mkdir $IDIR
$ cd $IDIR

Make sure you have installed the following packages

  • flex
  • bison
  • build-essential

You can use the command “sudo apt-get install <PACKAGE_NAME>” to retrieve and install these packages.

Installing Simple tools

Just un-pack the package file, and remove the old gcc folder. To do so, use:

$ cd $IDIR
$ tar xzvf simpletools-2v0.tgz
$ rm -rf gcc-2.6.3

Installing SimpleUtils

First un-pack the package file. To do so, use:

$ tar xzvf simpleutils-990811.tar.gz
$ cd simpleutils-990811

Before building the code, you need to fix some sources of errors. In directory ld find file ldlex.l and replace all instances of
yy_current_buffer with YY_CURRENT_BUFFER.

You may either do it manually by opening the respected file and renaming it or to make it simple just type this code

$ find . -type f -print0 | xargs -0 sed -i -e ’s,yy_current_buffer,YY_CURRENT_BUFFER,g’
$ ./configure –host=$HOST –target=$TARGET –with-gnu-as –with-gnu-ld –prefix=$IDIR
$ make
$ make install

Installing Simulator

Un-pack the simulator package.

$ cd $IDIR
$ tar xzvf simplesim-3v0d.tgz
$ cd simplesim-3.0
$ make config-pisa
$ make

You may test the installation of simplesim by

$ ./sim-safe tests/bin.little/test-math

Installing GCC Cross-Compiler

This is the important step where most of the newbies (including me) are/were struggling. So please follow these steps carefully.

$ 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

Now before you proceed ahead, there are quite a few corrections that have to be made in some files:

1.) Change the Makefile at line 130, by appending –I/usr/include to the end of the line

To do so you can use command

$ gedit Makefile

makefile

(This, I feel is the important step which makes this installation process Ubuntu specific. I may be wrong as -I./include should have done the trick for other linux. But still its OK to include it in the usr folder than the current directory)

2.) Edit line 60 of protoize.c, and replace

#include <varargs.h> with #include <stdarg.h>

Todo so you can use command

$ chmod +w protoize.c
$ gedit protoize.c

3.) Edit obstack.h at line 341 and change

*((void **)__o->next_free)++=((void *)datum); 

with

*((void **)__o->next_free++)=((void *)datum);

To do so you can use the following command

$ chmod +w obstack.h
$ gedit obstack.h

4.) Copy the patched files located in the patched directory to avoid some parse errors while compiling. To do so use the following command.

$ 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 in your browser, you probably didnt unrar it properly. Again unrar the GCC tar file “at a different location” (say your Desktop) and copy from it.

5.) *** Crucial Step*** Download this file, un-tar it and place its contents .i.e ar & ranlib in $IDIR/sslittle-na-sstrix/bin – FILE

You would also want to confirm that these files have “execution & write permission” You can do so by

$ cd $IDIR/sslittle-na-sstrix/bin
ls -al

If you see each file of this folder with write(w) & execution(x) permission then you are ready to go further. If not then you have to assign them the permission by using

chmod +w <filename>
chmod +x <filename>

$ make

Again you will face few errors

1.) Now you will get many insn-output.c errors. To solve this you need to add line breaks (‘’) after each of the three FIXME (line 675, 750 and 823) in the insn-output.c
To open this file, use

$ gedit insn-output.c
$ make

2.) In objc/sendmsg.c, add the following code at line 35

#define STRUCT_VALUE 0
$ cd $IDIR/gcc-2.7.2.3/objc
$ chmod +w sendmsg.c
$ gedit sendmsg.c
$ cd ..
$ make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"

3.) The last make command will lead to an error message which requires you to edit cxxmain.c file

To solve this you need to remove lines 2978-2979 in file cxxmain.c .i.e Remove the following lines

char * malloc ();
char * realloc ();

To do so, use this command.

$ chmod +w cxxmain.c
$ gedit cxxmain.c

Now cross your fingers, because we are about to execute the final error free make command.

$ make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
$ make install  LANGUAGES="c c++" CFLAGS="-O" CC="gcc"

Testing

To test the simulator use these commands

$ clear
$ cd $IDIR
$ gedit hello.c

Now in Gedit you can write your program like this (You may modify it)

[c]
#include<stdio.h>
main (void)
{
printf(“My name is Yogesh Mhatre. I’m not a Coder, but I do like debugging errors.nI like blogging and sharring my minuscule knowledge to the world through it.n”);
}
[/c]

Once you are done writing the code, use the following command to test it.

$ $IDIR/bin/sslittle-na-sstrix-gcc -o hello hello.c
$ $IDIR/simplesim-3.0/sim-safe hello

You would “hopefully” get an output similar to this

sim: ** starting functional simulation **
My name is Yogesh Mhatre. I’m not a Coder, but I do like debugging errors.
I like blogging and sharring my minuscule knowledge to the world through  it.

sim: ** simulation statistics **
sim_num_insn                   9242 # total number of instructions executed
sim_num_refs                   4328 # total number of loads and stores executed
sim_elapsed_time                  1 # total simulation time in seconds
sim_inst_rate             9242.0000 # simulation speed (in insts/sec)
ld_text_base             0×00400000 # program text (code) segment base
ld_text_size                  71968 # program text (code) size in bytes
ld_data_base             0×10000000 # program initialized data segment base
ld_data_size                   8528 # program init’ed `.data’ and uninit’ed `.bss’ size in bytes
ld_stack_base            0×7fffc000 # program stack segment base (highest address in stack)
ld_stack_size                 16384 # program initial stack size
ld_prog_entry            0×00400140 # program entry point (initial PC)
ld_environ_base          0×7fff8000 # program environment base address address
ld_target_big_endian              0 # target executable endian-ness, non-zero if big endian
mem.page_count                   26 # total number of pages allocated
mem.page_mem                   104k # total size of memory pages allocated
mem.ptab_misses                  26 # total first level page table misses
mem.ptab_accesses            495046 # total page table accesses
mem.ptab_miss_rate           0.0001 # first level page table miss rate

Thats said. You may scream now. “Whoopiee”

Good Luck! (Now wake me up when september ends)

Update : Check out the Video Tutorial



Projects

  • Gndrix

    Hello, I’ve followed the instructions and everything’s going great, but unfortunately, the file ar-ranlib.tar.gz is no longer hosted by the website, is there any place where I can find it?. Thanks in advance.

    • mhatrey

      The link is fixed now. You may try it again.

  • Gndrix

    Thanks a lot, I have it working since yesterday. Greetings from México.

  • hlyu

    This tutorial really helps me. I have to thank the author very much!!!

  • Gndrix

    Hello again, I would like to know which version of gcc did you use to compile the simulators. I’ve been having some issues with sim-outorder (simulations that take long long hours to run, I mean 10+ hours with spec2000 benchmarks with 200000000 instructions to execute with 100000000 of fast forwarding) and my instructor suspects that’s because of the version of gcc and its support of threads. My first installation was using gcc 4.3.3 because it’s the native in my system, then I installed gcc-3.3.6 and tried again, then 3.0.4 and tried again, but, to my disappointment, it still takes a long, really long time to simulate some of the benchmarks while others run quite fast. Do you have any clue here?.

    Thanks in advance!

  • mhatrey

    Believe it or not thats the case. But the below link should help you out.

    [quote]…..Beware that SPEC2000 running under a full sim-outorder or sim-mase simulation environment will run for weeks on even the fastest Intel processor available”….[/quote]Link

    Another option would be run less number of instructions

  • Siddharth Pal

    great!!!! can’t believe this actually worked..

  • Jay

    I feel like I’m so close to getting this thing working, but I am getting stuck on the last step. I do not have a cxxmain.c file. I have a cppmain.c file, but it isn’t 2000+ lines long, so I’m unsure of where to make the edits.

    Do you have any pointers?

    • mhatrey

      Hi jay,

      if you donot get cxxmain.c it means you have gone wrong somewhere…

      I would suggest you to start the procedure again …
      also make sure you have distclean everything

      • Karma

        same issue here – went many times through the procedure but nothing helped… do you know how to fix

        • Karma

          edit: ubuntu version is 10.10

          • Rekha Graj

             I am also having same issue..Pls help me out in this..Error msg is:

            make: *** [genemit] Error 1

            techgsec@ubuntu:~/simplescalar/gcc-2.7.2.3$ chmod +w cxxmain.cchmod: cannot access `cxxmain.c’: No such file or directory
             

      • kmarf

        I am running into this same issue. Has there been resolution on this? Thanks for the help.

    • kmarf

      Jay, Im running into this same problem. By chance did you get this figured out? If so, what was the fix? Thanks.

  • mehul

    I m getttin an as error while installing gcc-2.7.2.3 in the 4th step of it

    cp: cannot create regular file ../sslittle-na-sstrix/include/sys/cdefs.h: No such file or directory.
    Can you please let me know how to fix this error.
    Thanks!!

    • congnt

      thank you for helping me :)

  • Pavan

    Hey Man …..
    Thanx a lot …. you cant imagine how grateful i am to you …. because i had trying to install this for 3 days now …. and was getting a lot of errors . . . . following your steps from scratch solved all of them ….. thanx … now i can sleep in peace

  • sachin

    hiiiiii….. i trying install smiplescaler in ubantu. but
    lot of error are coming. so please …..send to me code of
    installation at <

    • mhatrey

      The installation code is right on the site. There is nothing extra that you need to do beside than to follow it.

  • Saman

    Hey man,
    I have been trying to install this tool for so long. Although your tutorial was very helpful I encountered an error while compiling gcc cross-compiler, after the second step (objc/sendmsg.c) I get this error when I try to make:

    echo “__foo () {}” > dummy.c
    ./xgcc -B./ -DCROSS_COMPILE -DIN_GCC -O -I./include –I/usr/include -c dummy.c
    xgcc: –I/usr/include: No such file or directory
    make: *** [libgcc1.null] Error 1

    I saw this error on web but no one has a solution for it. any idea would be appreciated, I am badly stuck here!!

    • mhatrey

      Have you installed flex and bison ..

      Also next time you do the procedure again .. make sure you do it in the different directory ..

      or atleast you use distclean

      • Saman

        Thanks,

        Actually, I removed the line “–I/usr/include” from Makefile, and it worked.
        Thanks anyway, your tutorial helped a lot.

        • mhatrey

          You are welcome. :)

  • http://itmindia.edu shally

    Hi all
    during installation of simple scalar when I am running these commands
    $ cp ../sslittle-na-sstrix/lib/libc.a ../lib/
    $ cp ../sslittle-na-sstrix/lib/crt0.o ../lib/

    error occurs: cannot create regular file.

    plz help me how to solve this error

  • alberto

    Thanks for your guide, is really useful! I am trying to install SimpleScalar in OpenSuse, but I get strange errors in the final step of “Installing GCC Cross-Compiler”. I performed all the modifications, but when I execute the command
    make LANGUAGES=”c c++” CFLAGS=”-O” CC=”gcc”
    I get a strange error:
    In file included from /usr/include/ss/ss_err.h:6,
    from /usr/include/ss/ss.h:26,
    from config/ss/sslittle.h:103,
    from tm.h:1,
    from config/ss/xm-ss.h:57,
    from tconfig.h:1,
    from ./libgcc2.c:33:
    /usr/include/et/com_err.h:47: warning: invalid character in macro parameter name
    /usr/include/et/com_err.h:47: badly punctuated parameter list in `#define’

    I looked up the file com_err.h, and found these lines:
    #if 0
    extern int init_error_table(const char * const *msgs, long base, int count);
    #else
    #define init_error_table(…) PLEASE_DO_NOT_USE_init_error_table_FUNCTION
    #endif

    I tried to change the #if 0 with #if 1 and got another error:
    ./libgcc2.c: In function `__udivmoddi4′:
    ./libgcc2.c:484: `BITS_PER_UNIT’ undeclared (first use this function)
    ./libgcc2.c:484: (Each undeclared identifier is reported only once
    ./libgcc2.c:484: for each function it appears in.)

    I am thinking that something is not right with the included files…have you got any ideas on what is going wrong here? Thank you for your time!

    • Asherhang

       While, I have encountered the same problem. But finally I figured it out. Maybe you run some command line error.

  • Abhilash

    Hi my name is abhilash i was just wondering if there is a multi core extension to simplescalar simulator?
    thanks in advance

    • bosnia

      look on the simple scalar website under the 'extensions' link

  • Mustapha

     Great job thank you so much, installed and worked perfectly on Ubuntu 11.04 

  • farshad

    Hello,
    I have a problem with following commands:
    $ cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h2$ cp ../sslittle-na-sstrix/lib/libc.a ../lib/
    3$ cp ../sslittle-na-sstrix/lib/crt0.o ../lib/
    actually there is no include folder in the  sslittle-na-sstrix folder. and also I cannot find libc.a and crt0.o. I really appreciate your help.thanks

  • Rish

    Well done, Yogesh…. SimpleScalar people must learn something from you. At least in terms of: “how to build SimpleScalar without problems?” Very well done, indeed.

  • Rekha G

    Thank you very much Sir..:) I can’t believe it worked on my system..:)

    • http://www.igoy.in Yogesh Mhatre

      My Pleasure

  • Nastaran_motavali

    Hi
    My problem is in Testing step, the error is:
    hello.c: In function `main’:
    hello.c:4: parse error before character 0342
    Can anyone help me?
    Thanks

    • http://www.igoy.in Yogesh Mhatre

      Ohh, I think you just copy pasted the text which I wrote …

      In stead of copy-pasting just type the text program and you should be good

  • Kevin7993

    Hi,
    I had tried to install the simpleutils on my computer with cygwin, because my OS is win7.
    However, I faced the problem in this  “./configure –host=$HOST –target=$TARGET –with-gnu-as –with-gnu-ld –prefix=$IDIR”  procedure. It always showed that ”No such file or directory” 
    I think maybe my got wrong in setting environment variable, I set it for ” i686-pc-cygwin” was it right?
    Thanks,

    • http://www.igoy.in Yogesh Mhatre

      Hmm .. .. It says “No Such File or directory” … are you sure you went into that simpleutils folder  and tried listing the whole folder to see whether you see “configure” file or not ..

      check the video http://www.igoy.in/simplescalar-installation-video/ …

      Ohh by the way I would recommend using Virtual Box/VMware instead

      • Kevin7993

        When I entered the iinstruction “./configure –host=$HOST –target=$TARGET –with-gnu-as –with-gnu-ld –prefix=$IDIR”
        it was shows that ” Invalided configuration ‘i686-KL-NB-Cygwin’ : machine ‘i686-KL-NB’ not recognized

        However, I enter “uname -a” it indicate that ” CYGWIN_NT-6.1-WOW64 KL-NB 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin”

        Please tell what to do….

        Thanks,

        • http://www.igoy.in Yogesh Mhatre

          Hmm .. set HOST as “i386-pc-linux” and try .. 

          • Kevin7993

            Thank you very much!!
            Without your kindly help, I can’t successfully install simplescalar.

          • Kevin7993

            Oh…I’m facing another problem….when I installed the gcc in last step…” libgcc1-test.o:file not recognized: File format not recognized
            make: ***[libgcc1-test] Error 1 ”
            How to fix it?

            Thanks,

          • http://www.igoy.in Yogesh Mhatre

            I think, cygwin is not able to recognize that file…

            Have you installed Flex, Bison & Buildessential as stated earlier ?

          • Kevin7993

            Yes, I did. However, there is also another problem ” /home/kl/simplescalar/sslittle-na-sstrix/bin/ar: cannot be execute binary file

            make: ***[libgcc1.null] Error 1″

            I had replaced the “ar” and “ranlib” already which like the instruction on your website….

            Thanks, 

          • http://www.igoy.in Yogesh Mhatre

            Check the permission of ar & ranlib which you replaced .. They should have execute permission

  • Cappedantarip

    Could u plz help me by telling me how do I link to external libraries from simplescalar while running C programs on it? e.g I need to link to GNU MP library but I am unable to do so.

  • http://www.facebook.com/karoon23 Karthik Narayanan

    hi
    when i am trying to install Simpleutils during make install i get the following error
    libtool: install: `DIR/lib’ must be an absolute directory name
    and then some error message appear
    i am new to linux so can’t figure out what the problem is . plz help me out

    • http://www.igoy.in Yogesh Mhatre

      Karthik,

      Make sure $IDIR is set properly.

      Check the video posted at Youtube. I would suggest you do a clean install of Simplescalar again

  • Madiraju Santosh

    In step 4 of installing the GCC cross compiler, I am getting an error after the “$ cp ../sslittle-na-sstrix/lib/libc.a ../lib/” command.
    The error is : cp: cannot create regular file ‘../lib/’: Is a directory.
    Please help me out.
    Thanks

  • Joshi

    the cxxmain.c file is missing.. how do i proceed?

    • http://www.igoy.in Yogesh Mhatre

      You cannot proceed without cxxmain.c You probably made a mistake somewhere..

      Do ‘make distclean’ and follow the video on how to proceed with the installation

  • Shivprasad

    Hey, I’m new to linux and simulators. I did manage to install simplescalar, thnks to ur post, but here the GCC is configured fo liitle  endian right? cos the benchmarks I’m supposed to run are pisa-big and I’m getting the error wrong endian! So, could plese point the changes I have to make?

    • Shivprasad

      got it… thnks fr d post anyway

  • Majid 06

    thank you so much for this toturial………It helps me for my midterm

  • Bagher Salami

    thanks very much. but i in step 4 of Installing GCC Cross-Compiler create lib directory and copy two files manually. also in step 5 of Installing GCC Cross-Compiler i create bin folder manually and search 6 files ar as gcc ld nm ranlib, strip in home directory and placed in bin directory. by these action it work very well.