Skip to content

Instantly share code, notes, and snippets.

@id4ehsan
Last active April 9, 2023 15:31
Show Gist options
  • Save id4ehsan/ed6b344a2e8eced7034ad40f05b68dca to your computer and use it in GitHub Desktop.
Save id4ehsan/ed6b344a2e8eced7034ad40f05b68dca to your computer and use it in GitHub Desktop.
SimpleScalar simplesim-3v0e and GCC PISA Cross Compiler gcc-2.7.2.3.ss and Wattch sim-wattch-1.02e Auto Installer
#!/bin/sh
# SimpleScalar simplesim-3v0e and GCC PISA Cross Compiler gcc-2.7.2.3.ss and Wattch sim-wattch-1.02e Auto Installer
# Just run the script and enter your password when it needs
# XMMMWMMMMMMMMMMMMi
# 7MMMMMMMMMMMMMMMMMMW,
# MMMMMMMMMM0W@@80MMMMMMi
# SMMXrrri:, ,rWMMM7
# .MM2. ,8MMB
# XMW . iMM:
# SM2.. iBMM:
# rM0. . :MMM.
# MM:rXr;:. .;SZZZaS; XMM
# XW700MMMM2rXZMBMB22X..M7,.
# :77.r2r7Sr :7;2Xr7, ai,;
# rX; .,.. : . ... .;.i
# ,;i. ., , ..:,i,
# ;;:... :i ::, . ..,i:,.
# i;;:. . ;S77X;, ....,,:
# :;.... .:: ,.,.::
# i:.:r7;i:;;77:....:;,S
# ,;:,:::ii:,.:,,,,;r @B,
# r;:,,,::,,,..,iSr :MWM2:
# 87;,,. .:XWX BB08BM8X:
# :M7rrrr;;;;rXa0r 0W8ZZZZBMMMM0X,
# .XW ra8:;rXXSS2XXr;: ZW8ZZZZZBWB0WWM@
# .78MMM7 ;7MX,iiiiiii;,iS SM8ZZZ8880W000088
# ,rZMMMMMM7..:ZWii;i;i;;i rr;@088Z880ZBB0Z088Z
# XMMMMMWWWWWMM:,;SX;i;rr;r,,.r0Z08008888B8008ZZ
#.aMMWWWWWWWWMMrr: iiii::,;, aBZ88008Z0Z80008ZZZ
set -e # To stop as soon as an error occured
# This is the first line requiring root permission
sudo apt-get install -y build-essential bison flex gzip gcc-multilib g++-multilib libz1 libncurses5 libbz2-1.0 tar make
export IDIR=/opt/SimpleScalar
export HOST=i686-pc-linux
export TARGET=sslittle-na-sstrix
#(Assuming your host is also little endian. It could be ssbig-na-sstrix. If this is the case, all the following appeared "sslittle-na-sstrix" should be replaced by "ssbig-na-sstrix".)
#export TARGET=ssbig-na-sstrix
if [ ! -d "$IDIR" ]
then
sudo mkdir $IDIR
fi
sudo chown $USER:$USER ""$IDIR
# Will install SimpleScalar in /opt/SimpleScalar
cd $IDIR
### Download SimpleScalar Package ###
if [ ! -f "simpletools-2v0.tgz" ] && [ ! -f "simpletools-2v0.tar" ]
then
wget http://www.simplescalar.com/downloads/simpletools-2v0.tgz
fi
if [ ! -f "simpleutils-2v0.tgz" ] && [ ! -f "simpleutils-2v0.tar" ]
then
wget http://www.simplescalar.com/downloads/simpleutils-2v0.tgz
fi
if [ ! -f "simplesim-3v0e.tgz" ] && [ ! -f "simplesim-3v0e.tar" ]
then
wget -O simplesim-3v0e.tgz --referer http://www.simplescalar.com/agreement.php3?simplesim-3v0e.tgz 'www.simplescalar.com/gatedftp.php3?simplesim-3v0e.tgz'
fi
if [ ! -f "simpleutils-990811.tar.gz" ]
then
wget http://www.cse.iitd.ernet.in/~cs5070217/csl718/simpleutils-990811.tar.gz
fi
if [ ! -f "gcc-2.7.2.3.ss.tar.gz" ]
then
wget http://www.cse.iitd.ernet.in/~cs5070217/csl718/gcc-2.7.2.3.ss.tar.gz
fi
if [ ! -f "ar_and_ranlib.tar.gz" ]
then
wget http://www.cse.iitd.ernet.in/~cs5070217/csl718/ar_and_ranlib.tar.gz
fi
if [ ! -f "sim-wattch-1.02e.tar.gz" ]
then
wget http://www.eecs.harvard.edu/~dbrooks/sim-wattch-1.02e.tar.gz
fi
### Unzip Package ###
# To Be Compatible and I don't want to delete files
#gunzip *.tgz
if [ ! -d "binutils-2.5.2" ]
then
tar xzvf simpleutils-*.tgz
fi
if [ ! -d "sslittle-na-sstrix" ]
then
tar xzvf simpletools-*.tgz
fi
if [ ! -d "simplesim-3.0" ]
then
tar xzvf simplesim-*.tgz
fi
#
if [ ! -d "simpleutils-990811" ]
then
tar xzvf simpleutils-9*.tar.gz
fi
if [ ! -f "ar" ]
then
tar xzvf ar_and_ranlib.tar.gz
fi
if [ ! -d "gcc-2.7.2.3" ]
then
tar xzvf gcc-2.7.2.3.ss.tar.gz
fi
if [ ! -d "sim-wattch-1.02e" ]
then
tar xzvf sim-wattch-1.02e.tar.gz
fi
### binutils Compilation ###
set +e
cd $IDIR/simpleutils-9*
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
make
#find . -type f -print0 | xargs -0 sed -i -e 's,yy_current_buffer,YY_CURRENT_BUFFER,g'
sed -i -e "s/yy_current_buffer/YY_CURRENT_BUFFER/g" ld/ldlex.l
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
make
make install
set -e
### Compile SimpleSim ###
cd $IDIR/simplesim-3*
make config-pisa
make
./sim-safe tests/bin.little/test-math
### Compile SimWattch ###
cd $IDIR/sim-wattch-1*
make config-pisa
make
./sim-outorder $IDIR/simplesim-3*/tests/bin.little/test-math
### compile the old gcc-2.7 ###
cd $IDIR/gcc-2.7*
set +e
export PATH=$PATH:$IDIR/sslittle-na-sstrix/bin
./configure -host=$HOST -target=$TARGET -with-gnu-as -with-gnu-ld -prefix=$IDIR
chmod +w Makefile
sed -i -e "s/\-I\.\/include/-I\/usr\/include/g" Makefile
chmod +w protoize.c
sed -i -e "s/\#include <varargs\.h>/\#include <stdarg\.h>/g" protoize.c
chmod +w obstack.h
sed -i -e "s/\*((void \*\*)__o->next_free)++ = ((void \*)datum);/\*((void \*\*)__o->next_free++) = ((void \*)datum);/g" obstack.h
cp $IDIR/gcc-2.7*/patched/sys/cdefs.h $IDIR/sslittle-na-sstrix/include/sys/cdefs.h
cp $IDIR/sslittle-na-sstrix/lib/libc.a $IDIR/lib/
cp $IDIR/sslittle-na-sstrix/lib/crt0.o $IDIR/lib/
cd $IDIR/
mv ar ranlib $IDIR/sslittle-na-sstrix/bin/
cd $IDIR/sslittle-na-sstrix/bin/
chmod +wx ar as ld nm ranlib strip
cd $IDIR/gcc-2.7*/
make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
chmod +w insn-output.c
sed -i -e 's/return "FIXME\\n/return "FIXME\\n\\/g' insn-output.c
make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
cd objc
chmod +wx sendmsg.c
sed -i '35i #define\ STRUCT_VALUE\ 0' sendmsg.c
cd $IDIR/gcc-2.7*/
make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
sed -i 's/^inline$//g' cp/input.c
# lex.c:795: undefined reference to `is_reserved_word'
sed -i 's/^inline$//g' cp/hash.h
# parse.c:(.text+0x5e7): undefined reference to `yyprint'
sed -i 's/^__inline$//g' cp/lex.c
# except.c:(.text+0x416): undefined reference to `auto_function'
sed -i 's/^__inline$//g' cp/decl.c
make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
# Avoiding:
# cxxmain.c:2978: error: conflicting types for ‘malloc’ - uniquement pour gcc 2.7
cd $IDIR/gcc-2.7*/
chmod +w cplus-dem.c
sed -i -e "s#char \* malloc ();#\/\/char \* malloc ()#g" cplus-dem.c
sed -i -e "s#char \* realloc ();#\/\/char \* realloc ()#g" cplus-dem.c
make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
make install LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
cd $IDIR
chown $USER:$USER -R *
#cd $IDIR/..
#chown $USER:$USER -R *
echo 'PATH='$IDIR'/bin:'$IDIR'/simplesim-3.0:$PATH' >> ~/.bashrc
#cd ../simplesim-*
#echo 'PATH='$IDIR'/simplesim-3.0:$PATH' >> ~/.bashrc
echo "This is it! Please restart your session in order to update your global variables."
echo "or execute: source ~/.bashrc"
#chmod +x ~/.bashrc
#~/.bashrc
#chmod -x ~/.bashrc
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment