Saturday, 23 May 2015

Building the compiler and a few essential libraries

Do not expect anything revolutionary in this article, but I will document it for the sake of completeness. So, here is a trivial how-to to compile and install an up-to-date gcc and an (hopefully) optimized version of the SDL library.

Compiling gcc 4.9.1 and its dependencies

I decided to use an up-to-date gcc version to benefit as much as possible from the improvements introduced on the ARM targets. Honestly, I am not sure this had a great impact. But, hey, I had time to do this, so why not?


Official link:

In some temporary folder:
tar -xjf gmp-5.1.3.tar.bz2
cd gmp-5.1.3
CFLAGS= ./configure --prefix=/media/BBB
make && make install    


In some temporary folder:
tar -xzf mpfr-3.1.2.tar.gz 
cd mpfr-3.1.2
CFLAGS= ./configure --with-gmp-include=/media/BBB/include/ --with-gmp-lib=/media/BBB/lib/ --prefix=/media/BBB
make && make install


In some temporary folder:
tar -xzf mpc-1.0.2.tar.gz
cd mpc-1.0.2
CFLAGS= ./configure --with-gmp-include=/media/BBB/include/ --with-gmp-lib=/media/BBB/lib/ --prefix=/media/BBB --with-mpfr-lib=/media/BBB/lib/ --with-mpfr-include=/media/BBB/include/
make && make install


In some temporary folder:
tar -xzf gcc-4.9.1.tar.gz
cd gcc-4.9.1
./configure  --enable-languages=c,c++ --prefix=/media/BBB --with-gmp-include=/media/BBB/include --with-mpc-include=/media/BBB/include --with-mpfr-include=/media/BBB/include --with-mpc-lib=/media/BBB/lib --with-gmp-lib=/media/BBB/lib --with-mpfr-lib=/media/BBB/lib --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf && make && make install

Tweaking the compilation flags

Aiming at getting the most of the BBB, I tested several benchmarks (e.g. himeno: to get an idea of the influence of several compilation flags on the actual performances of the compiler. I know this has its limits, as emulators are highly dependent on integer computation performance, and some benchmarks focus more on the FPU aspect for example (see himeno). I just used these results as a "hint" that the compiler was doing sensible things, and hoping everything would be for the best in the SDL/emulation world.

I ended up with the following flags, that I added to my /etc/profile./ script:
export CFLAGS="-O3  -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -ffast-math"

Compiling the SDL library and the required modules

I intended to compile the SDL library myself as this library is essential for the performance of lots of emulators. At least, I know how this has been compiled, and especially, that the hard float ABI has been used.


In some temporary folder:
tar -xzf SDL-1.2.15.tar.gz
cd SDL-1.2.15
./configure --prefix=/media/BBB/ && make && make install

SDL modules:

Do exactly the same for the following libraries:

No comments:

Post a Comment