-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build F* with dune
instead of ocamlbuild
#2815
Conversation
The -warn-error +N option is used to turn warnings into errors, and -warn-error -N reverts that process, but still retains the warning. To ignore a warning, we need `-w -N`. cc @tahina-pro
I've been trying to build this branch from a clean state on Windows with cygwin, but it fails with the following log:
My |
I pulled the latest and tried again ... here's what I got.
|
Thanks Nik for reporting. There is an issue on Cygwin with running the bash script to generate FStar_Version.ml from dune. I just pushed a fix, can you please try again? |
If we call fstar.exe --cache_checked_modules --lax A.fst we now get a warning that A.fst.checked.lax does not exist. This does not really make sense as we are trying to build the file, but `should_verify` return false, as we are in lax mode. So, use the weaker `should_check` instead. This removes the flurry of warning we get when lax-building the libraries (though that process is about to disappear).
Hi @tahina-pro ... I have the same dune exception even with your latest changes. |
+$(MAKE) -C src ocaml | ||
+$(MAKE) dune-fstar | ||
|
||
3: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading to dune 3.5 solved my problem on cygwin |
because FStar_Version.ml depends on version.txt outside of the dune snapshot, cf. ocaml/dune#5572
Thanks Nik for reporting! I confirm F* successfully builds with dune 3.2.0 but not dune 3.1.x. I think this is related to ocaml/dune#5572, which was fixed in dune 3.2.0. So I updated the dependency requirements accordingly. |
For any F* maintainers who might still have outstanding branches with F* building with ocamlbuild, here is some process to merge master in your branches to convert to dune, adapted from my comment above (#2815 (comment)):
git pull origin _taramana_dune_step_2
make -C src/ocaml-output
make -j -C src ocaml
make -C src/ocaml-output
make clean-full-dune-snapshot
make -j dune-staged-bootstrap
git add ocaml/fstar*/*.ml ocaml/fstar*/generated/*.ml
git commit
rm -f src/ocaml-output/FStar_*
git add -u
git commit
git pull origin master
make clean-dune-snapshot
make -j dune-bootstrap
git add ocaml/fstar*/generated/*.ml
git commit |
Additionally, I've noticed that if you have changes to hand-written ML files in your branch, then you may need to copy those changes over to ocaml/fstar-lib manually. In _nik_steel_dsl for instance, we had changes to FStar_Tactics_Builtins.ml and FStar_Parsing_LexFStar.ml ... and these were dropped initially, leading to a successful build, but with strange failures in behavior (particularly with the parser) that had me confused for a while. |
When converting a given branch, this case should be covered by the |
tl;dr: What changes for the user
fstarlib
,fstar-tactics-lib
andfstar-compiler-lib
all becomefstar.lib
OCAMLPATH=$FSTAR_HOME/bin
becomesOCAMLPATH=$FSTAR_HOME/lib
$FSTAR_HOME/bin/fstarlib.cmx*
becomes$FSTAR_HOME/lib/fstar/lib/fstar_lib.cmx*
fstar.exe
lib/fstar
instead ofulib
(this was already the case with the OPAM package ormake install
)opam pin fstar --dev-repo
)The problem
Currently, the OCaml port of F*, both for Windows and Linux, relies on ocamlbuild, which leads to the following issues:
The solution: this PR
This PR builds F* with
dune
instead ofocamlbuild
. To this end:ulib
, is now included, currently in theocaml
subdirectory. Now, to build F*, it is only necessary to build that snapshot and verifyulib
. This is what the defaultmake
rule of the root Makefile now does. No extraction is needed as long as nothing in the F* sources or inulib
is changed, which is the case for most users. (In particular, lax-typechecking ofulib
is no longer needed!) As of now, the snapshot includesFStar_Parser_Parse.ml
file as generated by menhir/ocamlyacc, but no version ofparse.mly
file (so that we don't need to instruct dune to call menhir or ocamlyacc)fstar-lib
,fstar-tactics-lib
andfstar-compiler-lib
are now all merged into a single package,fstar.lib
, whose OCaml sources (including the generated and extracted files) are inocaml/fstar-lib
, which is now statically linked with the F* compiler. No need to dynamically load any "F* tactic library" anymore! No need to compute a list of "leftovers between fstarlib and fstartaclib" anymore! The library is now installed intolib/fstar
, instead of a subdirectory ofbin
.(With this solution, every application built with F* needs to be linked with the whole F* compiler/typechecker, etc., which may cause bloating of the produced binary executable. As discussed with @nikswamy and @mtzguido , we may need to change the way
--codegen Plugin
works, by making sure it produces a library disjoint from--codegen OCaml
, at least at the level of the module name.)ocaml
subdirectory, instead ofsrc/*/ml
,ulib/ml
orulib/tactics_ml
, with the exception ofparse.mly
. The entrypoint offstar.exe
is inocaml/fstar
, that offstar_tests.exe
is inocaml/fstar-tests
; everything else is inocaml/fstar-lib
. However, we distinguish them from the generated files, which are inocaml/fstar-lib/generated
(instead ofsrc/ocaml-output
). This is both to make sure there is only one copy of each file, and to satisfydune
's requirement that all OCaml files shall be in the same directory hierarchy.How to test: 3
make
rulesmake
src
orulib
, just domake dune-bootstrap
This rule now supports incrementality.
make dune-full-bootstrap
removes all generated files from the snapshot before generating them again. This shouldn't be necessary, except maybe if a file is renamed and we want to make sure the old file is removed.All those 3 rules support parallelism.
Remaining tasks before merging this PR
tests/ide/emacs/search.cons-snoc
unfold_tuples
) was not properly restored, cf. 0b02e48 . This bug was causing a diff intests/prettyprinting/Tuples
, with extra parentheses in the dune build as opposed to the ocambuild build.make install
rule (for binary packages and opam)ocaml/fstar.opam
is not needed, but we can benefit from the new snapshot to reduce the dependencies in the existingfstar.opam
make package
, rebuild and include the F# snapshot of ulibnix
rulesWhat this pull request DOES NOT do
dune
to generate the F* parser using menhir and/or ocamlyaccdune
instead ofocamlbuild
(hello/multifile
already does, but notsample_project
) (tracked by Discontinue ocamlbuild in OCaml extraction examples #2838)--lax
, benefitting from the.checked
files ofulib
ulib
tolib/fstar
in the F* sourcesulib
withdune
instead ofmake
(this would replacemake
withdune
as the build driver for F*)