Vous êtes sur la page 1sur 11

loading

igoY.in
The Journey of Yogi
About Disclosure Policy Contact Project 365

Ads by Google

Download Linux

Linux Download

C for Linux

Linux Ubuntu

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, Ive 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 1 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 1 2 3 $ 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. 1 2 $ 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: 1 2 3 $ 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: 1 2 $ 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 1 1 2 3 $ 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. 1 2 3 4 5 $ $ $ $ $ cd $IDIR tar xzvf simplesim-3v0d.tgz cd simplesim-3.0 make config-pisa make

You may test the installation of simplesim by 1 $ ./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. 1 2 3 4 5 $ $ $ $ $ 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 1 $ gedit 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 1 2 3.) Edit obstack.h at line 341 and change
*((void **)__o->next_free)++=((void *)datum);

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

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

To do so you can use the following command 1 2 4.) Copy the patched files located in the patched directory to avoid some parse errors while compiling. To do so use the following command. 1 $ cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h $ chmod +w obstack.h $ gedit obstack.h

2 3

$ 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 1 2 $ 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>

1 $ 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 1 2 2.) In objc/sendmsg.c, add the following code at line 35
#define STRUCT_VALUE 0

$ gedit insn-output.c $ make

1 2 3 4 5

$ $ $ $ $

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. 1 2 Now cross your fingers, because we are about to execute the final error free make command. 1 2 $ make LANGUAGES="c c++" CFLAGS="-O" CC="gcc" $ make install LANGUAGES="c c++" CFLAGS="-O" CC="gcc" $ chmod +w cxxmain.c $ gedit cxxmain.c

Testing
To test the simulator use these commands 1 2 3 $ 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. Im 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. 1 $ $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 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 sim: ** starting functional simulation ** My name is Yogesh Mhatre. Im 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 sim_num_refs 4328 sim_elapsed_time 1 sim_inst_rate 9242.0000 ld_text_base 000400000 ld_text_size 71968 ld_data_base 010000000 ld_data_size 8528 ld_stack_base 07fffc000 ld_stack_size 16384 ld_prog_entry 000400140 ld_environ_base 07fff8000 ld_target_big_endian 0 mem.page_count 26 mem.page_mem 104k mem.ptab_misses 26 mem.ptab_accesses 495046 mem.ptab_miss_rate 0.0001 # # # # # # # # # # # # # # # # # # total number of instructions executed total number of loads and stores executed total simulation time in seconds simulation speed (in insts/sec) program text (code) segment base program text (code) size in bytes program initialized data segment base program inited `.data and uninited `.bss size in bytes program stack segment base (highest address in stack) program initial stack size program entry point (initial PC) program environment base address address target executable endian-ness, non-zero if big endian total number of pages allocated total size of memory pages allocated total first level page table misses total page table accesses 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

Ads by Google

C for Linux

Linux Ubuntu

Linux Install

Arm Linux

Hello, Ive followed the instructions and everythings 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 Mxico. 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. Ive 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 thats because of the version of gcc and its support of threads. My first installation was using gcc 4.3.3 because its 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!!!! cant believe this actually worked.. Jay I feel like Im 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 isnt 2000+ lines long, so Im 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 fileshave 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 cant 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 cant successfully install simplescalar. Kevin7993 OhIm 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 cant 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 Aras You probably forgot to do the make install part. 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 Jiongren Download the following files and put them on $IDIR/sslittle-na-sstrix/bin : - http://www.ict.kth.se/courses/IS2202/ar - http://www.ict.kth.se/courses/IS2202/ranlib Then assign them the execution(x) permission Shivprasad Hey, Im 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 Im supposed to run are pisa-big and Im 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 toturialIt 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. Jeremy Gummeson Thanks so much! Your instructions worked like a charm

Guest Thank you very much. I had some troubles with this, but I finally was able to get it working! Very happy for all the help. Thanks a shitton! Mayuri i am using x86_64 m/c and i686 linux. simplescalar and gcc 2.7.2.3 got installed successfully. but now the problem i am facing is, if i give my test binary as input to the simulator it gives an error bad magic number not an executable . why this error is coming? kindly help me out. i will be very much thankful to you. Sreeramhere I too am facing the same issue..if u have any solution kindly mail to sreeramhere@gmail.com Anonymous Important: Do not edit the Makefile when youre installing gcc on a Linux system thats not UBUNTU. The between the lines hint was helpful, but maybe it should be more explicit. If you do edit the Makefile, you get stuck in the missing cxxmain.c pitfall. Naveen Well, I am on Kubuntu 11.10. I had the missing cxxmain.c problem. I edited out the changes I made to the Makefile i.e it is not necessary to make any changes to Makefile at all. Then it did generate cxxmain.c file. All is well now . May be someone else can confirm this. zizo Do you mean even the UBUNTU based systems? I have Linux Mint12 here Amirali Boroumand hi! thank you very much for your great tutorial! I want to install simulator and GCC cross compiler for big-endian. is it correct to follow these steps and use big instead of little? thanks Naveen Did you try it out Amirali? What are your observations? Please do share. Thanks Xinming hi! Thanks so much for the wonderful tutorial! This works on Ubuntu 10.10 i686 with gcc 4.4.5 Morphtrinity hi! Firstly, thanks a lot for the tutorial! I was installing SimpleScalar following the steps you have given when I got stuck at Installing SimpleUtils. After giving the make command, i got several errors (I have attached the screenshot of the terminal). Problem seems to be coming from conflicting declarations of a variable sys_errlist in libeberty/strerror.c and in /usr/include/bits/sys_errlist.h. Please help. Smhmnejad nice tut; but I encounter with this error @ the end, would u plz help? In file included from /usr/include/assert.h:37, from hash.c:27: /usr/include/features.h:324: bits/predefs.h: No such file or directory In file included from /usr/include/assert.h:37, from hash.c:27: /usr/include/features.h:389: gnu/stubs.h: No such file or directory In file included from runtime.h:31, from hash.c:32: /usr/include/stdio.h:36: bits/types.h: No such file or directory In file included from /usr/include/libio.h:32, from /usr/include/stdio.h:75, from runtime.h:31, from hash.c:32: /usr/include/_G_config.h:9: bits/types.h: No such file or directory In file included from runtime.h:31, from hash.c:32: /usr/include/stdio.h:165: bits/stdio_lim.h: No such file or directory /usr/include/stdio.h:850: bits/sys_errlist.h: No such file or directory In file included from runtime.h:32, from hash.c:32: /usr/include/ctype.h:28: bits/types.h: No such file or directory In file included from /usr/include/ctype.h:41, from runtime.h:32, from hash.c:32: /usr/include/endian.h:37: bits/endian.h: No such file or directory /usr/include/endian.h:61: bits/byteswap.h: No such file or directory make[1]: *** [hash.o] Error 1 make[1]: Leaving directory `/home/smhmnejad/simplescalar/gcc-2.7.2.3/objc make: *** [libobjc.a] Error 2 Sreeramhere

THANX A LOT !!! This worked perfectly in UBUNTU 10.10 Just seamlesswas facing various issues with UBUNTU 12.04 (especially in downloading build essentialsNote:am a real rookie to linux )Hats off for this wonderful tutorial..

Copyright since 2009 | Log in igoY.in - The Journey of Yogi. Theme by Sawyer Hollenshead. Modified by Yogesh Mhatre

Vous aimerez peut-être aussi