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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
#######################################################################
# #
# The Compcert verified compiler #
# #
# Xavier Leroy, INRIA Paris-Rocquencourt #
# #
# Copyright Institut National de Recherche en Informatique et en #
# Automatique. All rights reserved. This file is distributed #
# under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 2 of the License, or #
# (at your option) any later version. This file is also distributed #
# under the terms of the INRIA Non-Commercial License Agreement. #
# #
#######################################################################
include Makefile.config
DIRS=lib common $(ARCH) backend cfrontend driver \
flocq/Core flocq/Prop flocq/Calc flocq/Appli exportclight \
cparser cparser/validator
RECDIRS=lib common $(ARCH) backend cfrontend driver flocq exportclight cparser
COQINCLUDES=$(foreach d, $(RECDIRS), -R $(d) -as compcert.$(d))
CAMLINCLUDES=$(patsubst %,-I %, $(DIRS)) -I extraction
MENHIR=menhir
COQC="$(COQBIN)coqc" -q $(COQINCLUDES)
COQDEP="$(COQBIN)coqdep" $(COQINCLUDES)
COQDOC="$(COQBIN)coqdoc"
COQEXEC="$(COQBIN)coqtop" $(COQINCLUDES) -batch -load-vernac-source
COQCHK="$(COQBIN)coqchk" $(COQINCLUDES)
OCAMLBUILD=ocamlbuild
OCB_OPTIONS=\
-j 2 \
-no-hygiene \
-no-links \
$(CAMLINCLUDES)
OCB_OPTIONS_CHECKLINK=\
$(OCB_OPTIONS) \
-I checklink \
-use-ocamlfind
OCB_OPTIONS_CLIGHTGEN=\
$(OCB_OPTIONS) \
-I exportclight
VPATH=$(DIRS)
GPATH=$(DIRS)
# Flocq
FLOCQ=\
Fcore_Raux.v Fcore_Zaux.v Fcore_defs.v Fcore_digits.v \
Fcore_float_prop.v Fcore_FIX.v Fcore_FLT.v Fcore_FLX.v \
Fcore_FTZ.v Fcore_generic_fmt.v Fcore_rnd.v Fcore_rnd_ne.v \
Fcore_ulp.v Fcore.v \
Fcalc_bracket.v Fcalc_digits.v Fcalc_div.v Fcalc_ops.v \
Fcalc_round.v Fcalc_sqrt.v \
Fprop_div_sqrt_error.v Fprop_mult_error.v Fprop_plus_error.v \
Fprop_relative.v Fprop_Sterbenz.v \
Fappli_rnd_odd.v Fappli_IEEE.v Fappli_IEEE_bits.v
# General-purpose libraries (in lib/)
LIB=Axioms.v Coqlib.v Intv.v Maps.v Heaps.v Lattice.v Ordered.v \
Iteration.v Integers.v Archi.v Fappli_IEEE_extra.v Floats.v \
Parmov.v UnionFind.v Wfsimpl.v \
Postorder.v FSetAVLplus.v IntvSets.v
# Parts common to the front-ends and the back-end (in common/)
COMMON=Errors.v AST.v Events.v Globalenvs.v Memdata.v Memtype.v Memory.v \
Values.v Smallstep.v Behaviors.v Switch.v Determinism.v Unityping.v
# Back-end modules (in backend/, $(ARCH)/, $(ARCH)/$(VARIANT))
BACKEND=\
Cminor.v Op.v CminorSel.v \
SelectOp.v SelectDiv.v SelectLong.v Selection.v \
SelectOpproof.v SelectDivproof.v SelectLongproof.v Selectionproof.v \
Registers.v RTL.v \
RTLgen.v RTLgenspec.v RTLgenproof.v \
Tailcall.v Tailcallproof.v \
Inlining.v Inliningspec.v Inliningproof.v \
Renumber.v Renumberproof.v \
RTLtyping.v \
Kildall.v Liveness.v \
ValueDomain.v ValueAOp.v ValueAnalysis.v \
ConstpropOp.v Constprop.v ConstpropOpproof.v Constpropproof.v \
CSEdomain.v CombineOp.v CSE.v CombineOpproof.v CSEproof.v \
NeedDomain.v NeedOp.v Deadcode.v Deadcodeproof.v \
Machregs.v Locations.v Conventions1.v Conventions.v LTL.v \
Allocation.v Allocproof.v \
Tunneling.v Tunnelingproof.v \
Linear.v Lineartyping.v \
Linearize.v Linearizeproof.v \
CleanupLabels.v CleanupLabelsproof.v \
Mach.v \
Bounds.v Stacklayout.v Stacking.v Stackingproof.v \
Asm.v Asmgen.v Asmgenproof0.v Asmgenproof1.v Asmgenproof.v
# C front-end modules (in cfrontend/)
CFRONTEND=Ctypes.v Cop.v Csyntax.v Csem.v Cstrategy.v Cexec.v \
Initializers.v Initializersproof.v \
SimplExpr.v SimplExprspec.v SimplExprproof.v \
Clight.v ClightBigstep.v SimplLocals.v SimplLocalsproof.v \
Cshmgen.v Cshmgenproof.v \
Csharpminor.v Cminorgen.v Cminorgenproof.v
# LR(1) parser validator
PARSERVALIDATOR=Alphabet.v Interpreter_complete.v Interpreter.v \
Validator_complete.v Automaton.v Interpreter_correct.v Main.v \
Validator_safe.v Grammar.v Interpreter_safe.v Tuples.v
# Parser
PARSER=Cabs.v Parser.v
# Putting everything together (in driver/)
DRIVER=Compopts.v Compiler.v Complements.v
# All source files
FILES=$(LIB) $(COMMON) $(BACKEND) $(CFRONTEND) $(DRIVER) $(FLOCQ) \
$(PARSERVALIDATOR) $(PARSER)
# Symbolic links vs. copy
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
SLN=cp
else
SLN=ln -s
endif
all:
$(MAKE) proof
$(MAKE) extraction
$(MAKE) ccomp
ifeq ($(HAS_RUNTIME_LIB),true)
$(MAKE) runtime
endif
ifeq ($(CCHECKLINK),true)
$(MAKE) cchecklink
endif
proof: $(FILES:.v=.vo)
extraction: extraction/STAMP
extraction/STAMP: $(FILES:.v=.vo) extraction/extraction.v $(ARCH)/extractionMachdep.v
rm -f extraction/*.ml extraction/*.mli
$(COQEXEC) extraction/extraction.v
touch extraction/STAMP
ccomp: extraction/STAMP driver/Configuration.ml
$(OCAMLBUILD) $(OCB_OPTIONS) Driver.native \
&& rm -f ccomp && $(SLN) _build/driver/Driver.native ccomp
ccomp.prof: extraction/STAMP driver/Configuration.ml
$(OCAMLBUILD) $(OCB_OPTIONS) Driver.p.native \
&& rm -f ccomp.prof && $(SLN) _build/driver/Driver.p.native ccomp.prof
ccomp.byte: extraction/STAMP driver/Configuration.ml
$(OCAMLBUILD) $(OCB_OPTIONS) Driver.d.byte \
&& rm -f ccomp.byte && $(SLN) _build/driver/Driver.d.byte ccomp.byte
runtime:
$(MAKE) -C runtime
cchecklink: driver/Configuration.ml
$(OCAMLBUILD) $(OCB_OPTIONS_CHECKLINK) Validator.native \
&& rm -f cchecklink && $(SLN) _build/checklink/Validator.native cchecklink
cchecklink.byte: driver/Configuration.ml
$(OCAMLBUILD) $(OCB_OPTIONS_CHECKLINK) Validator.d.byte \
&& rm -f cchecklink.byte && $(SLN) _build/checklink/Validator.d.byte cchecklink.byte
clightgen: extraction/STAMP driver/Configuration.ml exportclight/Clightdefs.vo
$(OCAMLBUILD) $(OCB_OPTIONS_CLIGHTGEN) Clightgen.native \
&& rm -f clightgen && $(SLN) _build/exportclight/Clightgen.native clightgen
clightgen.byte: extraction/STAMP driver/Configuration.ml exportclight/Clightdefs.vo
$(OCAMLBUILD) $(OCB_OPTIONS_CLIGHTGEN) Clightgen.d.byte \
&& rm -f clightgen.byte && $(SLN) _build/exportclight/Clightgen.d.byte clightgen.byte
.PHONY: proof extraction ccomp ccomp.prof ccomp.byte runtime cchecklink cchecklink.byte clightgen clightgen.byte
documentation: doc/coq2html $(FILES)
mkdir -p doc/html
rm -f doc/html/*.html
doc/coq2html -o 'doc/html/%.html' doc/*.glob \
$(filter-out doc/coq2html cparser/Parser.v, $^)
cp doc/coq2html.css doc/coq2html.js doc/html/
doc/coq2html: doc/coq2html.ml
ocamlopt -o doc/coq2html str.cmxa doc/coq2html.ml
doc/coq2html.ml: doc/coq2html.mll
ocamllex doc/coq2html.mll
tools/ndfun: tools/ndfun.ml
ocamlopt -o tools/ndfun str.cmxa tools/ndfun.ml
latexdoc:
cd doc; $(COQDOC) --latex -o doc/doc.tex -g $(FILES)
%.vo: %.v
@rm -f doc/glob/$(*F).glob
@echo "COQC $*.v"
@$(COQC) -dump-glob doc/$(*F).glob $*.v
%.v: %.vp tools/ndfun
@rm -f $*.v
@echo "Preprocessing $*.vp"
@tools/ndfun $*.vp > $*.v || { rm -f $*.v; exit 2; }
@chmod -w $*.v
driver/Configuration.ml: Makefile.config VERSION
(echo let stdlib_path = "\"$(LIBDIR)\""; \
echo let prepro = "\"$(CPREPRO)\""; \
echo let asm = "\"$(CASM)\""; \
echo let linker = "\"$(CLINKER)\""; \
echo let arch = "\"$(ARCH)\""; \
echo let variant = "\"$(VARIANT)\""; \
echo let system = "\"$(SYSTEM)\""; \
echo let has_runtime_lib = $(HAS_RUNTIME_LIB); \
echo let asm_supports_cfi = $(ASM_SUPPORTS_CFI); \
version=`cat VERSION`; \
echo let version = "\"$$version\"") \
> driver/Configuration.ml
cparser/Parser.v: cparser/Parser.vy
$(MENHIR) --coq cparser/Parser.vy
depend: $(FILES) exportclight/Clightdefs.v
$(COQDEP) $^ \
| sed -e 's|$(ARCH)/|$$(ARCH)/|g' \
> .depend
install:
install -d $(BINDIR)
install ./ccomp $(BINDIR)
ifeq ($(CCHECKLINK),true)
install ./cchecklink $(BINDIR)
endif
ifeq ($(HAS_RUNTIME_LIB),true)
$(MAKE) -C runtime install
endif
clean:
rm -f $(patsubst %, %/*.vo, $(DIRS))
rm -f ccomp ccomp.byte cchecklink cchecklink.byte clightgen clightgen.byte
rm -rf _build
rm -rf doc/html doc/*.glob
rm -f doc/coq2html.ml doc/coq2html doc/*.cm? doc/*.o
rm -f driver/Configuration.ml
rm -f extraction/STAMP extraction/*.ml extraction/*.mli
rm -f tools/ndfun tools/*.cm? tools/*.o
rm -f $(ARCH)/ConstpropOp.v $(ARCH)/SelectOp.v backend/SelectDiv.v backend/SelectLong.v
$(MAKE) -C runtime clean
$(MAKE) -C test clean
distclean:
$(MAKE) clean
rm -f Makefile.config
check-admitted: $(FILES)
@grep -w 'admit\|Admitted\|ADMITTED' $^ || echo "Nothing admitted."
# Problems with coqchk (coq 8.4.pl2):
# Integers.Int.Z_mod_modulus_range takes forever to check
# Floats.Float.double_of_bits_of_double takes forever to check
# AST.external_function gives "Failure: impredicative Type inductive type"
# Asm.instruction gives "Failure: impredicative Type inductive type"
# Mach.instruction gives "Failure: impredicative Type inductive type"
# UnionFind.UF.elt gives "Anomaly: Uncaught exception Reduction.NotConvertible"
check-proof: $(FILES)
$(COQCHK) -admit Integers -admit Floats -admit AST -admit Asm -admit Mach -admit UnionFind Complements
print-includes:
@echo $(COQINCLUDES)
include .depend
FORCE:
|