Compiling SPEC Benchmarks tools on ARM

Some of the SPEC benchmarks come for a variety of architectures but not for ARM, which is not surprising anyway. The easiest way to execute the benchmarks is by using the provided scripts, which is pretty much straight forward operation. The benchmarks come with pre-compiled tools and libraries that are needed by the benchmarks. Among them is Perl, which will fail to compile on ARM systems because of some invalid object definitions in its makefile. These definitions get in the makefile by the Configure script which is called before calling make. Instead of messing around with Configure, I added a couple of lines in the buildtools file, which is responsible for building the SPEC tools on a new architecture or after having modified the host system, in order to remove the unnecessary lines from the corresponding makefiles.

The buildtools script can be found under tools/src/ in the SPEC benchmarks directoy. What is needed is to go in the Perl building section, line 103, and replace the fist part of the building phase with the following oneliner:

./Configure -dOes $PERLFLAGS -Ddosuid=undef -Dprefix=$INSTALLDIR 
-Dd_bincompat3=undef; cat makefile | grep -v built-in 
| grep -v "command line" >; cp makefile; 
cat x2p/makefile | grep -v built-in | grep -v "command line" > x2p/; 
cp x2p/ x2p/makefile; make; ./perl installperl ) 
|| die "Can't build perl"

Running Fortran on ARM

Generally and very briefly, there is no official Fortran compiler available for the ARM architecture. The easiest way to get Fortran code (specifically Fortran 77) to run on the ARM architecture, or any other architecture that doesn’t have a Fortran compiler, is to convert the Fortran code to C. In order to do that efficiently, we can use Netlib’s f2c command line tool, available for Linux, Unix and Windows.

The steps that need to be followed are:

1) Compile the library – source at
Rename makefile.u to makefile and do make. Copy the generated libf2c.a to /usr/lib and the f2c.h header under /usr/include.
2) Compile the binary – source at
Rename makefile.u to makefile and do make. Copy the binary f2c under /usr/local/bin.

Supposing we have the foo.f file we can generate the C version by running f2c foo.f, giving us foo.c. It can now be compiled using ‘gcc foo.c -o foo -lf2c‘.

In order to automate this process a while, the following script can be used. It accepts only one argument, the Fortran source file.

fileName=`echo $1 | sed 's/\(.*\)\..*/\1/'`
echo $fileName
f2c $fortranFile
gcc ${fileName}.c -o $fileName -lf2c

UPDATE: There is GCC Fortran compiler for ARM Fedora and Debian and I presume for other distros as well. The issue now is that these distributions are compiled for ARMv5, while the latest ARM processors (Cortex-A8, A9, A15) are of the ARMv7 architecture. The compilers, and the OS in general is therefore unable to make use of the additional instructions sets and FPU. Other distros, such as Slackware, are compiled on even older architecture, ARMv4.