2 Installation
You need the following tools to build CIL:
-
A Unix-like shell environment (with bash, perl, make, mv, cp,
etc.). On Windows, you will need cygwin with those packages.
- An ocaml compiler. You will need OCaml release 3.08 or higher to build
CIL. CIL has been tested on Linux and on Windows (where it can behave as
either Microsoft Visual C or gcc). On Windows, you can build CIL both with the
cygwin version of ocaml (preferred) and with the Win32 version of ocaml.
- An underlying C compiler, which can be either gcc or Microsoft Visual C.
-
Get the source code.
-
Official distribution (Recommended):
-
Download the CIL distribution (latest version is
distrib/cil-1.3.7.tar.gz). See the Section 20 for recent changes to the CIL distribution.
- Unzip and untar the source distribution. This will create a directory
called cil whose structure is explained below.
tar xvfz cil-1.3.7.tar.gz
- Subversion Repository:
Alternately, you can download an up to the minute version of CIL
from our Subversion repository at:
svn co svn://hal.cs.berkeley.edu/home/svn/projects/trunk/cil
However, the Subversion version may be less stable than the released
version. See the Changes section of doc/cil.tex to see what’s
changed since the last release. There may be changes that aren’t yet
documented in the .tex file or this website.For those who were using the CVS server before we switched to
Subversion, revision 8603 in Subversion corresponds to the last CVS
version.
- Enter the cil directory and run the configure script and then
GNU make to build the distribution. If you are on Windows, at least the
configure step must be run from within bash.
cd cil
./configure
make
make quicktest
- You should now find cilly.asm.exe in a subdirectory of obj. The
name of the subdirectory is either x86_WIN32 if you are using cygwin
on Windows or x86_LINUX if you are using Linux (although you should be
using instead the Perl wrapper bin/cilly). Note that we do not have an
install make target and you should use Cil from the development directory.
- If you decide to use CIL, please
send us a note. This will help recharge
our batteries after a few years of development. And of course, do send us
your bug reports as well.
The configure script tries to find appropriate defaults for your system.
You can control its actions by passing the following arguments:
-
CC=foo Specifies the path for the gcc executable. By default
whichever version is in the PATH is used. If CC specifies the Microsoft
cl compiler, then that compiler will be set as the default one. Otherwise,
the gcc compiler will be the default.
CIL requires an underlying C compiler and preprocessor. CIL depends on the
underlying compiler and machine for the sizes and alignment of types. The
installation procedure for CIL queries the underlying compiler for
architecture and compiler dependent configuration parameters, such as the size
of a pointer or the particular alignment rules for structure fields. (This
means, of course, that you should re-run ./configure when you move CIL to
another machine.)
We have tested CIL on the following compilers:
-
On Windows, cl compiler version 12.00.8168 (MSVC 6),
13.00.9466 (MSVC .Net), and 13.10.3077 (MSVC .Net 2003). Run cl
with no arguments to get the compiler version.
- On Windows, using cygwin and gcc version 2.95.3, 3.0,
3.2, 3.3, and 3.4.
- On Linux, using gcc version 2.95.3, 3.0, 3.2, 3.3, 4.0, and 4.1.
Others have successfully used CIL on x86 processors with Mac OS X,
FreeBSD and OpenBSD; on amd64 processors with FreeBSD; on SPARC
processors with Solaris; and on PowerPC processors with Mac OS X. If
you make any changes to the build system in order to run CIL on your
platform, please send us a patch.
2.1 Building CIL on Windows with Microsoft Visual C
Some users might want to build a standalone CIL executable on Windows (an
executable that does not require cygwin.dll to run). You will need cygwin for
the build process only. Here is how we do it
-
Start with a clean CIL directory
- Start a command-line window setup with the environment variables for
Microsoft Visual Studio. You can do this by choosing Programs/Microsoft
Visual Studio/Tools/Command Prompt. Check that you can run cl.
- Ensure that ocamlc refers to a Win32 version of ocaml. Run ocamlc
-v and look at the path to the standard library. If you have several
versions of ocaml, you must set the following variables:
set OCAMLWIN=C:/Programs/ocaml-win
set OCAMLLIB=%OCAMLWIN%/lib
set PATH=%OCAMLWIN%/bin;%PATH%
set INCLUDE=%INCLUDE%;%OCAMLWIN%/inc
set LIB=%LIB%;%OCAMLWIN%/lib;obj/x86_WIN32
- Run bash -c "./configure CC=cl".
- Run bash -c "make WIN32=1 quickbuild"
- Run bash -c "make WIN32=1 NATIVECAML=1 cilly
- Run bash -c "make WIN32=1 doc
- Run bash -c "make WIN32=1 bindistrib-nocheck
The above steps do not build the CIL library, but just the executable. The
last step will create a subdirectory TEMP_cil-bindistrib that contains
everything that you need to run CIL on another machine. You will have to edit
manually some of the files in the bin directory to replace CILHOME.
The resulting CIL can be run with ActiveState Perl also.