Skip to content

Commit cd406a5

Browse files
Merge PR #15745: toplevel: fix a bug in coqc -vok invocation
Reviewed-by: gares Reviewed-by: Blaisorblade Ack-by: SkySkimmer Ack-by: Alizter Co-authored-by: gares <[email protected]>
2 parents 01b7562 + 0b34b80 commit cd406a5

File tree

6 files changed

+61
-12
lines changed

6 files changed

+61
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- **Fixed:**
2+
a bug where :n:`coqc -vok` was not creating an empty '.vok' file.
3+
(`#15745 <https://github.com/coq/coq/pull/15745>`_,
4+
by Ramkumar Ramachandra).

stm/asyncTaskQueue.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module Make(T : Task) () = struct
111111
"-async-proofs-worker-priority";
112112
CoqworkmgrApi.(string_of_priority priority)]
113113
(* Options to discard: 0 arguments *)
114-
| ("-emacs" | "--xml_format=Ppcmds" | "-batch") :: tl ->
114+
| ("-emacs" | "--xml_format=Ppcmds" | "-batch" | "-vok" | "-vos") :: tl ->
115115
set_slave_opt tl
116116
(* Options to discard: 1 argument *)
117117
| ( "-async-proofs" | "-vio2vo" | "-o"
File renamed without changes.

test-suite/misc/coqc_dash_o.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
22

3-
DOUT=misc/tmp_coqc_dash_o/
4-
OUT=${DOUT}coqc_dash_o.vo
3+
DOUT=misc/tmp_coqc_cmdline/
4+
OUT=${DOUT}coqc_cmdline.vo
55

66

77
mkdir -p "${DOUT}"
88
rm -f "${OUT}"
9-
$coqc misc/coqc_dash_o.v -o "${OUT}"
9+
$coqc misc/coqc_cmdline.v -o "${OUT}"
1010
if [ ! -f "${OUT}" ]; then
1111
printf "coqc -o not working"
1212
exit 1

test-suite/misc/coqc_dash_vok.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
IN_V=misc/coqc_cmdline.v
4+
OUT_VO=misc/coqc_cmdline.vo
5+
OUT_VIO=misc/coqc_cmdline.vio
6+
OUT_VOS=misc/coqc_cmdline.vos
7+
OUT_VOK=misc/coqc_cmdline.vok
8+
OUT_GLOB=misc/coqc_cmdline.glob
9+
OUT="${OUT_VO} ${OUT_VIO} ${OUT_VOS} ${OUT_VOK} ${OUT_GLOB}"
10+
11+
rm -f ${OUT}
12+
13+
set -x
14+
15+
$coqc ${IN_V} -vos
16+
$coqc ${IN_V} -vok
17+
if [ ! -f ${OUT_VOK} ]; then
18+
echo "coqc -vok not working in -vos mode"
19+
rm -f ${OUT}
20+
exit 1
21+
fi
22+
23+
rm -f ${OUT}
24+
25+
$coqc ${IN_V} -o ${OUT_VO}
26+
if [ ! -f ${OUT_VOK} ]; then
27+
echo "vok not produced in -o mode"
28+
rm -f ${OUT}
29+
exit 1
30+
fi
31+
32+
rm -f ${OUT}
33+
34+
$coqc ${IN_V} -vio
35+
$coqc -vio2vo ${OUT_VIO}
36+
if [ ! -f ${OUT_VOK} ]; then
37+
echo "vok not produced in -vio2vo mode"
38+
rm -f ${OUT}
39+
exit 1
40+
fi
41+
42+
rm -f ${OUT}
43+
exit 0

toplevel/ccompile.ml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ let compile opts stm_options injections copts ~echo ~f_in ~f_out =
122122
let long_f_dot_in, long_f_dot_out =
123123
ensure_exists_with_prefix f_in f_out ext_in ext_out in
124124
let dump_empty_vos () =
125-
(* Produce an empty .vos file, as a way to ensure that a stale .vos can never be loaded *)
126125
let long_f_dot_vos = (chop_extension long_f_dot_out) ^ ".vos" in
127126
create_empty_file long_f_dot_vos in
127+
let dump_empty_vok () =
128+
let long_f_dot_vok = (chop_extension long_f_dot_out) ^ ".vok" in
129+
create_empty_file long_f_dot_vok in
128130
match mode with
129131
| BuildVo | BuildVok ->
130132
let doc, sid = Topfmt.(in_phase ~phase:LoadingPrelude)
@@ -147,19 +149,19 @@ let compile opts stm_options injections copts ~echo ~f_in ~f_out =
147149
let _doc = Stm.join ~doc:state.doc in
148150
let wall_clock2 = Unix.gettimeofday () in
149151
check_pending_proofs long_f_dot_in;
150-
(* In .vo production, dump a complete .vo file.
151-
In .vok production, only dump an empty .vok file. *)
152+
(* In .vo production, dump a complete .vo file. *)
152153
if mode = BuildVo
153154
then Library.save_library_to ~output_native_objects Library.ProofsTodoNone ldir long_f_dot_out;
154155
Aux_file.record_in_aux_at "vo_compile_time"
155156
(Printf.sprintf "%.3f" (wall_clock2 -. wall_clock1));
156157
Aux_file.stop_aux_file ();
157-
(* In .vo production, dump an empty .vos file to indicate that the .vo should be loaded,
158-
and dump an empty .vok file to indicate that proofs are ok. *)
159-
if mode = BuildVo then begin
158+
(* Additionally, dump an empty .vos file to make sure that
159+
stale ones are never loaded *)
160+
if mode = BuildVo then
160161
dump_empty_vos();
161-
create_empty_file (long_f_dot_out ^ "k");
162-
end;
162+
(* In both .vo, and .vok production mode, dump an empty .vok file to
163+
indicate that proofs are ok. *)
164+
dump_empty_vok();
163165
Dumpglob.end_dump_glob ()
164166

165167
| BuildVio | BuildVos ->

0 commit comments

Comments
 (0)