Skip to content

Commit fc0fe1e

Browse files
authored
Rocq --config Fix (#14093)
Reflecting on the issue in #13774, I think a solution that is both forwards and backwards compatible is to just always use `rocq c --config`. This PR implements this change and allows compilation of `rocq.theory` stanzas for Rocq 9.0+. Documentation in the [Rocq CLI](https://rocq-prover.org/doc/master/refman/practical-tools/coq-commands.html#command-line-options) implies this will be recognized by `compile/c` and [the message for this commit](rocq-prover/rocq@da931cc) seems to imply that `--config` will need to access the environment regardless. Maybe there is some reason to utilize just `rocq --config` (note: missing the `c`), but it is not immediately obvious to me. <details> <summary>It working with PR dune vs. failing previous version</summary> ```bash $ rocq --version The Rocq Prover, version 9.0.1 compiled with OCaml 5.3.0 $ cat theories/dune (rocq.theory (name test_proj) (package test_proj) (theories Stdlib)) $ cat dune-project (lang dune 3.22) (using rocq 0.12) (generate_opam_files) (package (name test_proj) (depends rocq-core)) $ cat theories/Test.v From Stdlib Require Import Nat. Lemma test : forall (x : nat), x = x. Proof. reflexivity. Qed. $ ~/forks/dune/_boot/dune.exe build $ ~/forks/dune/_boot/dune.exe clean $ dune build Warning: Skipping installed theories due to 'rocq --config' failure: - .../.opam/package_dev/bin/rocq --config failed with exit code 1. Hint: Try running 'rocq --config' manually to see the error. Couldn't find Rocq standard library, and theory is not using (stdlib no) -> required by _build/default/theories/.test_proj.theory.d -> required by alias theories/all -> required by alias default File "theories/dune", line 4, characters 11-17: 4 | (theories Stdlib)) ^^^^^^ Theory "Stdlib" has not been found. -> required by theory test_proj in theories/dune:2 -> required by _build/default/theories/.test_proj.theory.d -> required by alias theories/all -> required by alias default ``` </details>
2 parents f30d21e + 2ee6319 commit fc0fe1e

11 files changed

Lines changed: 49 additions & 45 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ test-melange: $(BIN)
116116
$(BIN) build @runtest-melange
117117

118118
test-all: $(BIN)
119-
$(BIN) build @runtest @runtest-js @runtest-rocq @runtest-melange
119+
DUNE_ROCQ_TEST=enable $(BIN) build @runtest @runtest-js @runtest-rocq @runtest-melange
120120

121121
test-ox: $(BIN)
122122
$(BIN) runtest test/blackbox-tests/test-cases/oxcaml

doc/changes/fixed/14093.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fix Rocq configuration detection to use `rocq c --config` subcommand
2+
instead of `rocq --config` (#14093, fixes #13774, @Durbatuluk1701)

doc/rocq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Dune organises it's knowledge about Rocq theories in 3 databases:
283283
workspace-public theories, Dune will try to locate the theory in the list of
284284
installed locations Rocq knows about.
285285

286-
This list is built using the output of ``rocqc --config`` in order to infer
286+
This list is built using the output of ``rocq c --config`` in order to infer
287287
the ``ROCQLIB`` and ``ROCQPATH`` environment variables. Each path in ``ROCQPATH``
288288
and ``ROCQLIB/user-contrib`` is used to build the database of installed
289289
theories.
@@ -829,9 +829,9 @@ configuration. These are:
829829
- ``%{rocq:version.suffix}`` the suffix version of Rocq (e.g., ``9.1.2`` gives
830830
``.2`` and ``9.2+rc1`` gives ``+rc1``).
831831
- ``%{rocq:ocaml-version}`` the version of OCaml used to compile Rocq.
832-
- ``%{rocq:rocqlib}`` the output of ``ROCQLIB`` from ``rocqc -config``.
832+
- ``%{rocq:rocqlib}`` the output of ``ROCQLIB`` from ``rocq c --config``.
833833
- ``%{rocq:rocq_native_compiler_default}`` the output of
834-
``ROCQ_NATIVE_COMPILER_DEFAULT`` from ``rocqc -config``.
834+
``ROCQ_NATIVE_COMPILER_DEFAULT`` from ``rocq c --config``.
835835

836836
See :doc:`concepts/variables` for more information on variables supported by
837837
Dune.

src/dune_rules/rocq/rocq_config.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ let impl_config bin =
222222
~output_limit:Execution_parameters.Action_output_limit.default)
223223
Return
224224
bin
225-
[ "--config" ]
225+
[ "c"; "--config" ]
226226
;;
227227

228228
let config_memo = Memo.create "rocq-config" ~input:(module Path) impl_config
229229

230230
let make ~(rocq : Action.Prog.t) =
231231
let open Memo.O in
232232
let+ config_output =
233-
get_output_from_config_or_version ~rocq ~what:"--config" config_memo
233+
get_output_from_config_or_version ~rocq ~what:"c --config" config_memo
234234
in
235235
let open Result.O in
236236
let* config_output = config_output in
@@ -243,7 +243,7 @@ let make ~(rocq : Action.Prog.t) =
243243
let rocq_native_compiler_default = Vars.get_opt vars "COQ_NATIVE_COMPILER_DEFAULT" in
244244
Ok { rocqlib; rocq_native_compiler_default }
245245
| Error msg ->
246-
User_error.raise Pp.[ textf "Cannot parse output of rocq --config:"; msg ]
246+
User_error.raise Pp.[ textf "Cannot parse output of 'rocq c --config':"; msg ]
247247
;;
248248

249249
let by_name { rocqlib; rocq_native_compiler_default } name =

src/dune_rules/rocq/rocq_config.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ end
5656
(** Data of a Rocq configuration. *)
5757
type t
5858

59-
(** [make ~rocq] runs rocq --config and returns the configuration data. Exceptionally, one
59+
(** [make ~rocq] runs [rocq c --config] and returns the configuration data. Exceptionally, one
6060
of the following will happen:
6161
62-
- Return [Error message] if rocq --config exits with a non-zero code.
63-
- Throw a user error if rocq --config is not parsable.
62+
- Return [Error message] if rocq c --config exits with a non-zero code.
63+
- Throw a user error if rocq c --config is not parsable.
6464
- Throw an [Action.Prog.Not_found] exception if the rocq binary is not found. *)
6565
val make : rocq:Action.Prog.t -> (t, User_message.Style.t Pp.t) result Memo.t
6666

src/dune_rules/rocq/rocq_path.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ let config_path_exn rocq_config key =
3636
(* This should never happen *)
3737
Code_error.raise "key is not a path" [ key, Rocq_config.Value.to_dyn path ])
3838
| None ->
39-
(* This happens if the output of rocq --config doesn't include the key *)
39+
(* This happens if the output of rocq c --config doesn't include the key *)
4040
User_error.raise
4141
[ Pp.concat
4242
~sep:Pp.space
43-
[ Pp.text "key not found from"; User_message.command "rocq --config" ]
43+
[ Pp.text "key not found from"; User_message.command "rocq c --config" ]
4444
|> Pp.hovbox
4545
; Pp.text key
4646
]
@@ -144,7 +144,7 @@ let of_rocq_install rocq =
144144
[ Pp.concat
145145
~sep:Pp.space
146146
[ Pp.text "Skipping installed theories due to"
147-
; User_message.command "rocq --config"
147+
; User_message.command "rocq c --config"
148148
; Pp.text "failure:"
149149
]
150150
|> Pp.hovbox
@@ -154,7 +154,7 @@ let of_rocq_install rocq =
154154
[ Pp.concat
155155
~sep:Pp.space
156156
[ Pp.text "Try running"
157-
; User_message.command "rocq --config"
157+
; User_message.command "rocq c --config"
158158
; Pp.text "manually to see the error."
159159
]
160160
|> Pp.hovbox

test/blackbox-tests/test-cases/rocq/coqtop/coqtop-flags.t/run.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The flags passed to coqc:
66
{
77
"name": "rocq",
88
"args": [
9+
"c",
910
"--config"
1011
]
1112
}

test/blackbox-tests/test-cases/rocq/failed-config.t/run.t

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Here we test what happens when rocq --config or --print-version fails in an unexpected way
1+
Here we test what happens when rocq c --config or --print-version fails in an unexpected way
22
and how dune reacts to this failure.
33

44
First we create a wrapper around coqc so we can make it fail. It should only fail on
55
--config and --print-version.
66
$ mkdir bin
77
$ cat > bin/rocq <<'EOF'
88
> #!/bin/sh
9-
> if [ "$1" = --config ] && [ -n "$FAIL_CONFIG" ]; then
10-
> echo "rocq --config has failed for some reason" >&2
9+
> if [ "$1" = c ] && [ "$2" = --config ] && [ -n "$FAIL_CONFIG" ]; then
10+
> echo "rocq c --config has failed for some reason" >&2
1111
> exit 1
1212
> elif [ "$1" = --print-version ] && [ -n "$FAIL_VERSION" ]; then
1313
> echo "rocq --print-version has failed for some reason" >&2
@@ -23,13 +23,13 @@ To make sure these are working correctly we test them.
2323

2424
These should succeed.
2525
$ rocq --print-version > /dev/null
26-
$ rocq --config > /dev/null
26+
$ rocq c --config > /dev/null
2727
These should fail.
2828
$ FAIL_VERSION=1 \
2929
> rocq --print-version 2> /dev/null
3030
[1]
3131
$ FAIL_CONFIG=1 \
32-
> rocq --config 2> /dev/null
32+
> rocq c --config 2> /dev/null
3333
[1]
3434

3535
Now we create a simple project that uses this coqc wrapper, should
@@ -52,9 +52,9 @@ Should fail: first warning that installed theories are being skipped due to the
5252
failure, then, as the library requires the stdlib, it fails:
5353
$ FAIL_CONFIG=1 \
5454
> dune build
55-
Warning: Skipping installed theories due to 'rocq --config' failure:
56-
- $TESTCASE_ROOT/bin/rocq --config failed with exit code 1.
57-
Hint: Try running 'rocq --config' manually to see the error.
55+
Warning: Skipping installed theories due to 'rocq c --config' failure:
56+
- $TESTCASE_ROOT/bin/rocq c --config failed with exit code 1.
57+
Hint: Try running 'rocq c --config' manually to see the error.
5858
Couldn't find Rocq standard library, and theory is not using (stdlib no)
5959
-> required by _build/default/.foo.theory.d
6060
-> required by alias all
@@ -82,9 +82,9 @@ Should succeed, warning that installed theories are being skipped due to the
8282
failure (c.f. #8958):
8383
$ FAIL_CONFIG=1 \
8484
> dune build
85-
Warning: Skipping installed theories due to 'rocq --config' failure:
86-
- $TESTCASE_ROOT/bin/rocq --config failed with exit code 1.
87-
Hint: Try running 'rocq --config' manually to see the error.
85+
Warning: Skipping installed theories due to 'rocq c --config' failure:
86+
- $TESTCASE_ROOT/bin/rocq c --config failed with exit code 1.
87+
Hint: Try running 'rocq c --config' manually to see the error.
8888

8989
$ FAIL_VERSION=1 \
9090
> dune build
@@ -127,14 +127,14 @@ however a failing --print-version will not.
127127
> EOF
128128

129129
Should fail.
130-
$ export coqlib="$(rocq --config | grep COQLIB | sed 's/COQLIB=//')"
130+
$ export coqlib="$(rocq c --config | grep COQLIB | sed 's/COQLIB=//')"
131131
$ FAIL_CONFIG=1 \
132132
> dune build @config
133133
File "dune", line 4, characters 8-23:
134134
4 | (echo %{rocq:rocqlib})))
135135
^^^^^^^^^^^^^^^
136136
Error: Could not expand %{rocq:rocqlib} as running rocq failed.
137-
$TESTCASE_ROOT/bin/rocq --config failed with exit code 1.
137+
$TESTCASE_ROOT/bin/rocq c --config failed with exit code 1.
138138
[1]
139139

140140
Should succeed.

test/blackbox-tests/test-cases/rocq/flags.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Test case: default flags
2323
> }
2424

2525
$ runFlags
26-
{"name":"rocq","args":["--config"]}
26+
{"name":"rocq","args":["c","--config"]}
2727
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
2828
{"name":"rocq","args":["compile","-q","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
2929

@@ -36,7 +36,7 @@ TC: :standard
3636
> EOF
3737

3838
$ runFlags
39-
{"name":"rocq","args":["--config"]}
39+
{"name":"rocq","args":["c","--config"]}
4040
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
4141
{"name":"rocq","args":["compile","-q","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
4242

@@ -49,7 +49,7 @@ TC: override :standard
4949
> EOF
5050

5151
$ runFlags
52-
{"name":"rocq","args":["--config"]}
52+
{"name":"rocq","args":["c","--config"]}
5353
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
5454
{"name":"rocq","args":["compile","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
5555

@@ -62,7 +62,7 @@ TC: add to :standard
6262
> EOF
6363

6464
$ runFlags
65-
{"name":"rocq","args":["--config"]}
65+
{"name":"rocq","args":["c","--config"]}
6666
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
6767
{"name":"rocq","args":["compile","-q","-type-in-type","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
6868

@@ -80,7 +80,7 @@ TC: extend in workspace + override standard
8080
> EOF
8181

8282
$ runFlags
83-
{"name":"rocq","args":["--config"]}
83+
{"name":"rocq","args":["c","--config"]}
8484
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
8585
{"name":"rocq","args":["compile","-type-in-type","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
8686

@@ -92,7 +92,7 @@ TC: extend in workspace + override standard
9292
> EOF
9393

9494
$ runFlags
95-
{"name":"rocq","args":["--config"]}
95+
{"name":"rocq","args":["c","--config"]}
9696
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
9797
{"name":"rocq","args":["compile","-q","-type-in-type","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
9898

@@ -105,7 +105,7 @@ TC: extend in dune (env) + override standard
105105
> EOF
106106

107107
$ runFlags
108-
{"name":"rocq","args":["--config"]}
108+
{"name":"rocq","args":["c","--config"]}
109109
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
110110
{"name":"rocq","args":["compile","-type-in-type","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
111111

@@ -118,7 +118,7 @@ TC: extend in dune (env) + standard
118118
> EOF
119119

120120
$ runFlags
121-
{"name":"rocq","args":["--config"]}
121+
{"name":"rocq","args":["c","--config"]}
122122
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
123123
{"name":"rocq","args":["compile","-q","-type-in-type","-type-in-type","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}
124124

@@ -136,6 +136,6 @@ TC: extend in dune (env) + workspace + standard
136136
> EOF
137137

138138
$ runFlags
139-
{"name":"rocq","args":["--config"]}
139+
{"name":"rocq","args":["c","--config"]}
140140
{"name":"rocq","args":["dep","-boot","-R","coq/theories","Corelib","-R",".","foo","-dyndep","opt","-vos","foo.v"]}
141141
{"name":"rocq","args":["compile","-q","-type-in-type","-bt","-w","-deprecated-native-compiler-option","-w","-native-compiler-disabled","-native-compiler","ondemand","-boot","-R","coq/theories","Corelib","-R",".","foo","foo.v"]}

test/blackbox-tests/test-cases/rocq/rocq-native/coqtop/coqtop-flags.t/run.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The flags passed to coqc:
66
{
77
"name": "rocq",
88
"args": [
9+
"c",
910
"--config"
1011
]
1112
}

0 commit comments

Comments
 (0)