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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
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, ARM and x86
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, 2010, 2011 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, 10.5 or 10.6 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.
- IA32 / Linux or MacOS or Windows+Cygwin [experimental]
For Intel/AMD x86 processors with SSE2 extensions
(i.e. Pentium 4 and later), running either Linux, MacOS 10.6,
or Windows with the Cygwin environment (http://www.cygwin.com/).
- 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
or on http://developer.apple.com/. For Microsoft Windows,
install the Cygwin environment http://www.cygwin.com/.
* The Coq proof assistant, version 8.3pl1.
Coq is free software, available from http://coq.inria.fr/
The original version 8.3 is not compatible, nor any of the 8.2 versions.
* The Caml functional language, version 3.10 or later.
Caml is free software, available from http://caml.inria.fr/
* Under MacOS 10.5 and 10.6, some standard C include files in /usr/include/
contain gcc-isms that cause errors when compiling with CompCert.
Symptoms include:
- references to undefined types uint16_t and uint32_t
- a type error when using the "assert" macro.
These issues have been reported through Apple Developer's Connection.
Until Apple fixes them, you can apply the patch available from
http://compcert.inria.fr/release/MacOSX-includes.patch
Download this file, then do:
sudo /bin/bash
cd /
patch -p0 < ..../MacOSX-includes.patch
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)
ia32-linux (x86 SSE2 32 bits, Linux)
ia32-macosx (x86 SSE2 32 bits, MacOS X)
ia32-cygwin (x86 SSE2 32 bits, Cygwin environment for Windows)
This generates the Makefile.config file in the top directory.
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
(needed only under MacOS X)
-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 supporting hand-written Caml
code to generate the executable for Compcert. This step takes 20
minutes or so on a recent machine; 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
.s Assembly file
.S Assembly file, to be run through the C preprocessor
.o Object code file
.a Library file
The "ccomp" command recognizes the following options:
Processing options:
-E Preprocess only, send result to standard output
-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
Language support options (use -fno-<opt> to turn off -f<opt>) :
-fbitfields Emulate bit fields in structs [off]
-flonglong Partial emulation of 'long long' types [on]
-fstruct-passing Emulate passing structs and unions by value [off]
-fstruct-assign Emulate assignment between structs or unions [off]
-fvararg-calls Emulate calls to variable-argument functions [on]
Code generation options:
-fmadd Use fused multiply-add and multiply-sub instructions
-fsmall-data <n> Set maximal size <n> for allocation in small data area
-fsmall-const <n> Set maximal size <n> for allocation in small constant area
Tracing options:
-dparse Save C file after parsing and elaboration in <file>.parse.c
-dc Save generated Compcert C in <file>.compcert.c
-dclight Save generated Clight in <file>.light.c
-dcminor Save generated Cminor in <file>.cm
-drtl Save unoptimized generated RTL in <file>.rtl
-dtailcall Save RTL after tail call optimization in <file>.tailcall.rtl
-dcastopt Save RTL after cast optimization in <file>.castopt.rtl
-dconstprop Save RTL after constant propagation in <file>.constprop.rtl
-dcse Save RTL after CSE optimization in <file>.cse.rtl
-dalloc Save LTL after register allocation in <file>.alloc.ltl
-dmach Save generated Mach in <file>.mach
-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 stdlib wrappers
-v Print external commands before invoking them
CONTACT:
The authors can be contacted by e-mail at compcert@yquem.inria.fr
|