Blob


1 [F*](https://fstar-lang.org) is a *general purpose functional
2 programming language with effects aimed at program verification.*
3 Recently I've been playing a bit with it, it's nice, and here's a
4 quick guide on how to compile it on OpenBSD.
6 -----
8 *Edit*: This "guide" is partially incomplete. Doing some re-install
9 after this guide was published, I noticed that not everything is as I
10 wrote it here. Things change, I suppose. Some problems have been
11 fixed, but not everything. In particular `ocamlfind` will complain
12 (probably multiple times) during the build that it cannot find the
13 `XXX` package, and a simple `opam install XXX` will amend.
15 -----
17 We'll need both `git` and GNU `make` from ports, and also ocaml (to
18 build F* and run F* programs), opam (the ocaml package manager),
19 ocaml-camlp4 and python 3 (to build `z3`, a theorem prover).
21 $ pkg_add git gmake ocaml ocaml-camlp4 opam python
23 *Note* I've installed camlp4 from the ports instead of through opam
24 because I was getting an error. I don't have much experience with
25 ocaml, but I've read *somewhere* that installing through the package
26 manager solved those problems.
28 ## Building z3
30 z3 is the engine that powers the verification system of F*
31 (AFAIK). It's not available through ports, so we'll need to build from
32 source. Even though is a project that came from Microsoft, it seems to
33 run on OpenBSD just fine. Building it is also straightforward:
35 $ git clone https://github.com/Z3Prover/z3
36 $ cd z3
37 $ CXX=clang++ python3 script/mk_make.py
38 $ cd build
39 $ make
40 $ cp z3 $SOMEWHERE_IN_PATH # (maybe?)
42 *Note* by default `script/mk_make.py` will try to use base g++ and the
43 build will fail. The version of g++ is too ancient and doesn't support
44 C++11.
46 ## Building F*
48 First of all, we need some ocaml dependencies, so make sure to
49 initialize opam (see `opam init`) and add the suggested stuff to your
50 shell init file.
52 $ opam install ocamlfind batteries stdint zarith ppx_deriving ppx_deriving_yojson ocaml-migrate-parsetree process
54 We can now build the F* compiler from the ocaml output present in the
55 repo. You can also build the ocaml output by yourself, but I've skip
56 this step.
58 $ gmake -j9 -C src/ocaml-output
60 The last step is to build the library. While the docs describes this
61 as an optional step, I wasn't able to compile F* programs without it.
63 $ gmake -j9 -C ulib/ml
65 This was all. Let's try the hello world now!
67 $ gmake -C examples/hello hello
69 It should take a decent amount of time to compile, output a *lot* of
70 text and, finally, at the end, a beautiful "Hello World".
72 Congrats, now you have a working F* installation!