Sunday, October 4, 2015

prime-indicator problem

Machine: Ubuntu 14.04.3

Problem description:
When I start my Ubuntu today, I come across a problem that prime-indicator crashes with the error "TabError: inconsistent with tabs and spaces" something like this. prime-indicator is a tool used to switch between Intel graphics card and Nvidia graphics card.

Solves:
I guess this problem is related to python, and since I changed the default python to python3.4 and the original python version is python2.7. I did a command like this:

/usr/bin $ sudo rm python
/usr/bin $ sudo ln -s python3.4 python

now I know I shouldn't change the system's python version, instead, I can use alias command to change the default python version only in my account. So first of all I change back to default python which is linked with python2.7 and reboot, prime-indicator comes back!
Then I add this line to my .bashrc file

alias python='python3.4'

and then source .bashrc

Saturday, June 20, 2015

Install SimpleScalar in Ubuntu 12.04

This tutorial is based on Ubuntu 12.04.5LTS.
Reference links are :
http://www.cse.iitd.ernet.in/~drajeswari/ss_installn.html
https://zealoct.wordpress.com/2011/04/19/install-simplescalar-on-ubuntu-10-10-with-gcc-4-4/
http://harryscode.blogspot.de/2008/10/installing-simplescalar.html

I checked a lot of tutorials online and finally managed to install simplescalar3.0 on my Ubuntu 12.04, to save time for those who haven't find a successful way to install that , I just post my installing process here. It just worked for me and I am not sure if it would work for you. If you find any mistakes please tell me.


Step1:  install flex and bison
$ sudo apt-get install flex bison


Step2: Download the source code here:

SimpleScalar source package: http://csrl.unt.edu/downloads/simplescalar.tgz

ar tool:  http://www.ict.kth.se/courses/IS2202/ar
ranlib tool: http://www.ict.kth.se/courses/IS2202/ranlib

Step3: create directory and uncompress source code
$mkdir -p ~/opt/simplescalar

copy all the source packages to ~/opt fold and uncompress them, you should get simpletools-2v0.tgz; simpleutils-990811.tar.gz; simplesim-3v0d.tgz; gcc-2.7.2.3 and flex-2.5.4a. In this tutorial I don't use gcc-2.7 and flex-2.5.4a.

Extract simpletools-2v0.tgz and move all the folds into ~/opt/simplescalar
which includes f2c-1994.09.27; glibc-1.09; gcc-2.6.3; ssbig-na-sstrix and sslittle-na-sstrix.

Extract simpleutils-990811.tar.gz to ~/opt

Extract simplesim-3v0d.tgz to ~/opt


Step4: Set up installation
$ export HOST=i386-pc-linux
$export TARGET=sslittle-na-sstrix
$export IDIR=/home/yourname/opt/simplescalar            //path you want to install

Step5: We need to modify some source code
 
  • binutils-2.5.2/libiberty/functions.def Line: 36
    Action: comment out
    Line: 56
    Action: comment out
  • binutils-2.5.2/ld/ldlex.l
    Line: 476
    Action: change yy_current_buffer to YY_CURRENT_BUFFER
  • binutils-2.5.2/ld/ldmisc.c
    Line: 24
    Action: change varargs.h to stdarg.h Line: 343 356 388 400
    Action: change all four functions info_msg() einfo() minfo() finfo() like this:

    343 void info_msg(const char* fmt, va_list ap)
    344 //va_dcl
    345 {
    346 char *fmt;
    347 va_list arg;
    348 /* va_start(arg);
    349 fmt = va_arg(arg, char *);
    350 vfinfo(stdout, fmt, arg);
    351 va_end(arg); */
    352 }
  • gcc-2.6.3/cccp.c
    Line: 194
    Action: comment out
  • gcc-2.6.3/cp/g++.c
    Line: 90
    Action: comment out
  • gcc-2.6.3/sdbout.c
    Line: 56
    Action: replace the whole line with ”#if 0”
  • gcc-2.6.3/gcc.c
    Line: 172
    Action: comment out

  • cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h  (To avoid error looking like "Fix these errors in the source :").
  • cp $IDIR/sslittle-na-sstrix/lib/libc.a $IDIR/lib/
  • cp $IDIR/sslittle-na-sstrix/lib/crt0.o $IDIR/lib/
  • Copy files ar & ranlib into $IDIR/sslittle-na-sstrix/bin (To avoid "buffer overflow" error involving ar or ranlib)

Step6: Install simplescalar utils
$cd ~/opt/simpleutils-990811
$./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
$make
$make install

Step7: Install simplescalar
$cd  simplesim-3.0
$make config-pisa
$make
You will see "my work is done!" here.
$mv ../simplesim-3.0 ~/opt/simplescalar

Step8: Install gcc2.6
$export PATH=$PATH:$IDIR/sslittle-na-sstrix/bin
$cd ~/opt/gcc-2.6.3

Edit Makefile and add -I/usr/include to the end of line 130.

$./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
$make LANGUAGE=c

after this, you would receive an error that lies in insn-output.c, here, once again you need to modify the source file of gcc-2.6.3
  • gcc-2.6.3/insn-output.c
    Line: 675 750 823
    Action: and a ‘\’ to the end of the line, and it will be

    675 return "FIXME\n\
    750 return "FIXME\n\
    823 return "FIXME\n\
note that insn-output.c is generated by flex automatically, and your modification would be lost every time you make clean
now, finally the gcc was able to compiled with no errors and there are two more steps.
$$IDIR/simplesim-3.0/sim-safe ./enquire -f >! float.h-cross
$ make install


Step9:Test
$opt/simplescalar/bin/sslittle-na-sstrix-gcc hello.c
$opt/simplescalar/simplesim-3.0/sim-safe a.out