summaryrefslogtreecommitdiff
path: root/README
blob: 42f0443c704feb36eeb1fc3c4c46a0058d85c383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
                The Compcert verified compiler

OVERVIEW:

The Compcert verified compiler is a compiler for a large subset of the
C programming language that generates code for the PowerPC and ARM
processors.

The distinguishing feature of Compcert is that it has been formally
verified using the Coq proof assistant: the generated assembly code is
formally guaranteed to behave as prescribed by the semantics of the
source C code.

Compcert is an ongoing research project.  The present release is an
advanced prototype intended for research, educational and evaluation
purposes.


COPYRIGHT:

The Compcert verified compiler is Copyright 2004, 2005, 2006, 2007,
2008, 2009 Institut National de Recherche en Informatique et en
Automatique (INRIA).  It is distributed under the conditions stated in
file LICENSE.


SUPPORTED PLATFORMS:

- PowerPC / MacOS   [stable]
    For Apple Macs running the MacOS 10.4 or 10.5 operating system.
    Both PowerPC-based and Intel-based Macs are supported.
    The PowerPC code generated by the Compcert compiler runs
    natively at full speed on PowerPC-based Macs, and runs under
    software emulation at reduced speed on Intel-based Macs.

- PowerPC / Linux   [somewhat experimental]
    For PowerPC machines running the Linux operating system.

- ARM / Linux       [experimental]
   For ARM machines running the Linux operating system.


PREREQUISITES:

* The "gcc", "as" and "make" tools must be installed and accessible in
  the search path.  For MacOS X, you can get them by installing the
  XCode development tools, as found on the installation DVDs.

* The Coq proof assistant, version 8.2-1 or later.
  Coq is free software, available from http://coq.inria.fr/

* The Caml functional language, version 3.10 or later.
  Caml is free software, available from http://caml.inria.fr/


INSTALLATION:

1- Configure the system.  From the top directory, do:

             ./configure <target>

where <target> is one of:

            ppc-macosx       (PowerPC, MacOS X)
            ppc-linux        (PowerPC, Linux)
            arm-linux        (ARM, Linux)

This generates the Makefile.config file in the top directory
and prepares and configures the CIL library in the cil/ subdirectory.

The "configure" script accepts the following options:

-bindir <dir>                   (default: /usr/local/bin)
        Directory where the binaries will be installed

-libdir <dir>                   (default: /usr/local/lib/compcert)
        Directory where the Compcert support library will be installed

-prefix <dir>                   (default: /usr/local)
        Set bindir and libdir to
        <dir>/bin and <dir>/lib/compcert, respectively.

2- Build the system.  From the top directory, do

             make all

This re-checks all the Coq proofs, then extracts Caml code from the
Coq specification and combines it with the CIL library and supporting
hand-written Caml code to generate the executable for Compcert.  This
step takes 10 to 15 minutes on a recent Mac computer; be patient.

3- You can now install Compcert.  This will create the "ccomp" command
in the binary directory selected during configuration, and install
supporting .h and .a files in the library directory.  Become superuser
if necessary and do

             make install


USAGE:

The executable for Compcert is called "ccomp".  It has the standard
command-line interface for a Unix C compiler.  For instance, to
compile the single-file program "src.c" and create an executable
called "exec", just do

       ccomp -o exec src.c

To compile a two-file program "src1.c" and "src2.c", do

       ccomp -c src1.c
       ccomp -c src2.c
       ccomp -o exec src1.o src2.o

To see the generated assembly code for "src1.c", do

       ccomp -S src1.c

The generated assembly code is left in file src1.s

The subset of the C language accepted by Compcert is quite large.
The main features of C that are not supported are:
  - The "long long" and "long double" types.
  - Non-structured forms of the "switch" statement (Duff's device).
  - Variable-argument functions.
The "ccomp" command will issue errors and diagnostics if it encounters
a C construct that it cannot process.

The "ccomp" command recognizes the following classes of input files:
  .c             C source file
  .cm            Cminor source file
  .o             Object code file
  .a             Library file

The "ccomp" command recognizes the following options:

Processing options:
  -E             Preprocess only, save result in <file>.i
  -S             Compile to assembler only, save result in <file>.s
  -c             Compile to object file only (no linking), result in <file>.o
Preprocessing options:
  -I<dir>        Add <dir> to search path for #include files
  -D<symb>=<val> Define preprocessor symbol
  -U<symb>       Undefine preprocessor symbol
Compilation options:
  -flonglong     Treat 'long long' as 'long' and 'long double' as 'double'
  -dclight       Save generated Clight in <file>.light.c
  -dasm          Save generated assembly in <file>.s
Linking options:
  -l<lib>        Link library <lib>
  -L<dir>        Add <dir> to search path for libraries
  -o <file>      Generate executable in <file> (default: a.out)
General options:
  -stdlib <dir>  Set the path of the Compcert run-time library
  -v             Print external commands before invoking them


CONTACT:

The authors can be contacted by e-mail at compcert@yquem.inria.fr