Showing posts with label compile. Show all posts
Showing posts with label compile. Show all posts

Thursday, December 25, 2008

Compiling SimpleScalar Simulator on Linux

SimpleScalar.com provides "fast, flexible and extensible infrastructure for hardware modeling and software analysis."

Their code was last updated in late 2003, but based on 1997 code-base. I got a lot of warnings and errors that prevented the compilation. With some help from twkm from #c on DALnet (IRC), I was able to complete the compilation process (though with warnings still).

I will mention what I have modified in the files, then I'll provide you with a script and .diff files to do the whole patching and compilation process automatically. This also includes the compilation of the SPEC2000int package (compiled against simplesim-ALPHA only).

The files simplesim-3v0d.tgz and SPEC2000int.tgz are hosted on this site (which also provides a guide).

Changes


Open simplesim-3.0/target-alpha/alpha.h: Shift the line 224 to line 239.
-> "extern enum md_opcode md_mask2op[];"
Move it such that it's above this line: "/* enum md_opcode -> description string */"

After extracting SPEC2000int package, the Makefile inside needs one line to point at the directory containing the simplesim-3.0 directory.
-> "/home/students//"
Here's a sample directory hierarchy to understand:
-/
--home
---username
----tmp
-----simplesim-3.0
Your path will be: /home/username/tmp

Scripts & Automagic!


1) Create a directory in your home directory and call it: simtmp
2) Create a file called machine.diff inside simtmp
3) Put the following inside it:
--- simplesim-3.0/target-alpha/alpha.h 2003-10-09 05:14:23.000000000 +0300
+++ simplesim-3.0-fixed/machine.h 2008-12-24 14:02:22.000000000 +0300
@@ -221,7 +221,6 @@
#define MD_MAX_MASK 2048

/* internal decoder state */
-extern enum md_opcode md_mask2op[];
extern unsigned int md_opoffset[];
extern unsigned int md_opmask[];
extern unsigned int md_opshift[];
@@ -236,6 +235,8 @@
OP_MAX /* number of opcodes + NA */
};

+extern enum md_opcode md_mask2op[];
+
/* enum md_opcode -> description string */
#define MD_OP_NAME(OP) (md_op2name[OP])
extern char *md_op2name[];


4) Create a file called setup.sh inside simtmp and put this in it:
#!/bin/bash
echo Extracting simplesim
/bin/tar -xf simplesim-3v0d.tgz

echo Patching simplesim
cd `pwd`
patch -p0 < `pwd`/machine.diff

echo Extracting SPEC
/bin/tar -xf SPEC2000int.tgz

echo Creating results directory
mkdir Results

echo Compile simplesim ALPHA
cd simplesim-3.0
make config-alpha
make

echo Update SPEC Makefile
cd ../
THISDIR=`pwd`
cd SPEC2000int
sed '19s:/home/students/<YOUR USERNAME>/<PATH TO YOUR SIMPLESCALAR DIRECTORY>:'$THISDIR':' ./Makefile > specmake
rm Makefile
mv specmake Makefile

echo Compile SPEC
make


5) cd /home/username/simtmp
Make sure the two packages (simplesim & SPEC2000int) are downloaded here. Don't extract them!
6) chmod +x setup.sh
7) ./setup.sh

That's it. The setup file will extract, patch & compile the programs for you. The result of the spec2000int benchmark will be in a directory called Results in the etderr files.

Sunday, May 25, 2008

Compiling AVIDemux on 64-bit Linux distro

AVIDemux is the best tool to rip DVDs, re-encode videos and edit them on the fly.

Sometimes it's a pain in the neck to compile stuff, especially on a 64-bit distro that has 32-bit compatibility libraries. Thankfully, guys at the Slamd64 forums are quite helpful in these matters.

I had an old copy of avidemux (version 2.3.0) which I worked on. I tried compiling the latest (version 2.4.1) but it requires "cmake" which I didn't have install, and didn't feel like going through the headache of finding its dependencies.

magic lines:
export LDFLAGS="-L/usr/lib64"
CFLAGS="-O2 -fPIC" ./configure --prefix=/usr \
--sysconfdir=/etc --libdir=/lib64 --includedir=/usr/include \
--with-jsapi-include=/usr/include/seamonkey-1.0.7/js/ --with-include-gettext
make -j4
make install

Without exporting LDFLAGS properly, you'll get an error like this:
/usr/lib/libXext.so: could not read symbols: File in wrong format

It was picking up the 32-bit lib instead of the 64-bit one. Exporting LDFLAGS properly solved this issue.

If you get something like this:
rm -f cs.gmo && : -c --statistics -o cs.gmo cs.po
mv: cannot stat `t-cs.gmo': No such file or directory

Make sure you have this in your configure line:
--with-include-gettext

* Found this in a RedHat archived text from 2004.

Friday, May 23, 2008

Compiling MPlayer on 64-bit Linux Distro

I had one H264 video which prevented the location bar to move and at some point, the audio would lead the video, and if I attempt to skip that part, it would play from start.

I thought it was Xine's fault for not being able to run the file properly, so I check whether there's a newer version or not, and there was so I updated, and Xine stopped working. No big deal, I had mplayer, but unfortunately it had the same old problems as Xine with that file.

Some guys suggested that the version I had of the H264 codec was compiled for a 32-bit distro, and it doesn't play well under 64-bit ones. That could be fixed with a recompile.

After some poking around at Slamd64 forums, I found some things that can help and this configure line made all the magic happen:
CFLAGS="-O2 -fPIC" ./configure --confdir=/etc --prefix=/usr --libdir=/usr/lib64 \
--with-extralibdir=/usr/lib --enable-gui --enable-largefiles \
--win32codecsdir=/usr/lib/codecs --codecsdir=/usr/lib/codecs \
--xanimcodecsdir=/usr/lib/codecs --realcodecsdir=/usr/lib/codecs

MPlayer was compiled fine and worked fine, but I still have problems with that bloody video file. I tried re-encoding it using avidemux on my laptop (32-bit Kubuntu), but avidemux kept crashing.

Oh well, MPlayer works fine now, at least.