Showing posts with label ada. Show all posts
Showing posts with label ada. Show all posts

Friday, May 29, 2009

LLVM with Ada support

Our objective is to remove array bound checks. So we need a strongly typed language that will have array bound checks to remove all possible. Ada is an imperative language that is strongly typed.

This week I have been busy working out how to use LLVM to compile Ada. It was a little difficult on the beginning because I had to install an old version of the Ada compiler (GNAT), and I didn't realize it a first. But after that it went a little smother. I asked on the llvm-dev list for some help, and Duncan Sands helped me out. Below is a description of what I had to do to install llvm-gcc with support for Ada.

  • The build requires having a compiler that supports Ada, C and C++. The Ada front-end is written in Ada so an Ada compiler is needed to build it. Compilers known to work with the LLVM 2.4 release are gcc-4.2 and the 2005, 2006 and 2007 versions of the GNAT GPL Edition.
  • So first thing is to do is download GNAT 2007. Download it from here.
  • Export the download in a folder. Lets call it ada_folder. Then install it into /build.
  • Now we need to get llvm-gcc. Lest call llvm-gcc_folder the folder where llvm-gcc is downloaded.
svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc_folder
  • Make a build directory for llvm-gcc and make it the current directory:
cd
mkdir build
cd build
  • Now we need to configure it.
export CC=/build/bin/gcc
export CXX=PATH_TO_C++_COMPILER

../configure --enable-languages=c,c++,fortran,ada --disable-bootstrap --disable-nls --disable-multilib --enable-checking --program-prefix=llvm- --prefix=/build --enable-llvm=
  • Before we build the compiler we need to put gnat2007 in our classpath. Only while we build it, we can change it later.
export PATH=/build/bin:$PATH
  • Build and install the compiler:
make -j2
make install
  • Now we need to change the PATH:
export PATH=/build/bin:/build/libexec/gcc/i686-pc-linux-gnu/4.2.1:$PATH