Blame


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