Simplifying command-line usage of F* #3753
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two really annoying aspects of the F* command line that have to worked around:
1- To extract a module that we've already checked, we must still call F* on the source file. So if we have
.cache/A.fst.checked
we cannot dofstar.exe --codegen OCaml .cache/A.fst.checked
(complains about an invalid extension) and must instead call F* onA.fst
. The problem is thatA.fst
can be anywhere on the include path, and an F*-generated .depend file does not help us find it as the rules look like:This means we have some awful makefile rules like:
$(OUTPUT_DIR)/%.ml: $(FSTAR) $(subst .checked,,$(notdir $<)) --codegen OCaml --extract_module $(subst .fst.checked,,$(notdir $<))
where the
subst
turns the checked file into the source file name (not path!) and relies on F* finding paths in the command line across its include path, which we also want to remove (fstar.exe Prims.fst
should not just work anywhere, it should only work if Prims is in the current directory).The first patch allows F* to take a checked file as argument, by performing a simple rewriting of it into its source file (which F* can indeed find in its configured include path). This turns the rule into:
$(OUTPUT_DIR)/%.ml: $(FSTAR) $< --codegen OCaml --extract_module $(subst .fst.checked,,$(notdir $<))
2-
--codegen
will by default extract all modules, so we need to explicitly restrict in most makefiles, as we have rules to generate only the target we want. This also entails some chopping of the names involved to obtain only the module name, as above. The second patch makes F*, by default, only extract the modules that were given in the command line, though this behavior can be overriden with any of the--extract
toggles. The rule now becomes:$(OUTPUT_DIR)/%.ml: $(FSTAR) $< --codegen OCaml