# LLVM tutorial with Dune (Part 2)

**URL:** <https://discuss.ocaml.org/t/llvm-tutorial-with-dune-part-2/3419>\
**Category:** Learning\
**Tags:** c, llvm, menhir, build, dune\
**Created:** [March 1, 2019, 2:50am UTC](https://discuss.ocaml.org/t/llvm-tutorial-with-dune-part-2/3419 "2019-03-01T02:50:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/abk/32/1016_2.png) [@abk](https://discuss.ocaml.org/u/abk)\
**Post date:** [March 1, 2019, 2:50am UTC](https://discuss.ocaml.org/t/llvm-tutorial-with-dune-part-2/3419/1 "2019-03-01T02:50:54Z")

</div>

Hi everyone, I just made an updated version of the [OCaml LLVM](https://llvm.org/docs/tutorial/index.html) since the posted one is pretty out of date. Check it out here: [https://github.com/adamrk/llvm-ocaml-tutorial](https://github.com/adamrk/llvm-ocaml-tutorial). The main changes are:

- switch build system to dune from ocamlbuild
- switch lexing and parsing to use ocamllex/menhir instead of camlp4
- update to newer LLVM API (version 6.0.0)

There are also a couple outstanding issues that I can’t figure out, so if you have any ideas how to fix these it’d be really helpful:

- Menhir is generated files which cause warnings during compilation:

```auto
ocamlc lib/parser__mock.mli.inferred
  File "parser__mock.ml.mock", line 388, characters 9-18:
  Warning 3: deprecated: Not_found
ocamlopt lib/.kaleidoscope_lib.objs/kaleidoscope_lib__Parser.{cmx,o}
  File "parser.ml", line 161, characters 45-612:
  Warning 9: the following labels are not bound in this record pattern: state

```

Are there any ways to prevent Menhir from causing these warnings? I’m currently handling it by suppressing the warnings with

```auto
(env
 (dev
  (flags (:standard -warn-error -3-9))))

```

in the dune file. Alternatively, is there a way to suppress the warnings only for these specific files?

- The cstubs are currently printing to stderr because when I set them to print to stdout, those calls don’t occur until the program exists. Any ideas on why that happens and if there is a better fix?
- I’m currently linking the cstubs dynamically which is annoying. Does anyone know if there’s a way to statically link them in?

Edit: actually it appears that the Warning 9 problem was fixed in the latest version of Menhir (20181113). `Not_found` is actually only deprecated in Base/Core so I got rid of that error by not opening Core at the toplevel. I’m still curious about if there’s an easy way to suppress warnings only for specific files though.

---

<div class="post-metadata">

**Author:** ![mseri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mseri/32/91_2.png) [@mseri](https://discuss.ocaml.org/u/mseri)\
**Post date:** [March 1, 2019, 7:09am UTC](https://discuss.ocaml.org/t/llvm-tutorial-with-dune-part-2/3419/2 "2019-03-01T07:09:08Z")

</div>

You can locally disable the warnings with `[@ocaml.warning “-9”]` or `[@@ocaml.warning “-9”]`. If you use a version of ocaml prior to 4.06, you may be better off by wrapping the module with

```
[@@@ocaml.warning “-9”]
...
[@@@ocaml.warning “+9”]
```
