I am trying to debug OCaml extracted from Coq. Adding some print statements to generated code probably would be enough. But if I modify .ml files extracted from Coq and do dune exec
it will re-generate them again from Coq. If there is a way to tell dune temporary not to re-run extraction step?
It's a bit clunky but maybe you could use copy files + promote?
copy the ml files to a debug dir
then set promote on the rule so they are only regenerated when you clean them
this seems like an interesting use case but I think we are stuck on a good user interface for it, so don't hesitate to open an issue
I am interested in any even hacky solution. I have a bug to find :) I wonder how promotion works for generated files? They are not explicitly mentioned in dune anywhere
you need to add them to the rule
the trick here is that the file in debug won't be the same than the generated one
like if you do
(library
(name debug))
(rule
(targets foo.ml)
(mode promote)
(action (copy ../orig/foo.ml)))
now you add the promote, and then dune will respect the file in the source tree
see https://dune.readthedocs.io/en/stable/dune-files.html#promote for more details
promotion means that the rule is only run _if_ the file needs to be generated
I have
(library
(name extracted)
(preprocessor_deps CRelationClasses.mli.patch patch.sh)
(preprocess (per_module
((action (run coq/extracted/patch.sh %{input-file})) CRelationClasses)
))
(public_name cerberus.coq)
(libraries zarith coq-core.kernel)
(wrapped false)
(flags (:standard -rectypes -w -27-32-33-39-67-37-20-34))
)
can I add promotion rule for single file in this library?
I tried to add rule and the problem is:
(rule
(targets CheriMemory.ml)
(mode promote)
(action (copy ../orig/CheriMemory.ml CheriMemory.ml)))
Error: Multiple rules generated for
_build/default/coq/extracted/CheriMemory.ml:
- coq/extracted/dune:7
- coq/extracted/dune:1
line 7 is rule I've added and line 1 is original coq.extraction
stanza
remove the extraction stanza and manually copy the file from _build
I see. It is one of 227 files generated :)
it looks like I need to find other way
is removing the one module from coq.extraction hard?
there are inter-dependecies. it worst case I can try
right now I am investigating alternative approach by mapping OCamls print_endline
to Coq via Extraction. This way I can try to print from Coq
You should promote them into a different directory and have another library stanza for debugging.
Last updated: Oct 13 2024 at 01:02 UTC