libbinaryen

Libbinaryen packaged for OCaml
README

Libbinaryen packaged for OCaml.

This is just the low-level C library. If you are looking for OCaml bindings to Binaryen, check out Binaryen.ml!

Usage

Inside your dune file, you can depend on libbinaryen as such:

(library
 (name binaryen)
 (public_name binaryen)
 (libraries libbinaryen.c)
 (foreign_stubs
  (language c)
  (names binaryen_stubs)
  (flags :standard -O2 -Wall -Wextra)))

MacOS C++ Compiler

When including this library in your dune MacOS executables, you'll need to specify -cc clang++ in your (flags) stanza. This is required because Binaryen will throw errors for itself to catch and using clang++ is the only way to handle them correctly. You can find more info on this ocaml issue.

Your stanza could look something like this:

 (executable
  (name example)
  (public_name example)
  (package example)
+ (flags -cc clang++)
  (modules example)
  (libraries binaryen))

These flags likely won't work on other operating systems, so you'll probably need to use dune-configurator to vary the flags per platform. You can see an example of this in our tests/.

Static Linking

If you are planning to create portable binaries for Windows, it will try to find Cygwin/MinGW locations in your PATH. To avoid this, you probably want to add this to your (executable) stanzas:

 (executable
  (name example)
  (public_name example)
  (package example)
+ (flags (:standard -ccopt -- -ccopt -static))
  (modules example)
  (libraries binaryen))

These flags might not work on other operating systems (like MacOS), so you'll probably need to use dune-configurator to vary the flags per platform. You can see an example of this in our tests/.

JavaScript

When compiling to JavaScript with js_of_ocaml, you'll need to add the --disable share flag. This is needed until we can depend on the bug fix from ocsigen/js_of_ocaml#1249. In the meantime, you can change your dune file:

 (executable
  (name example)
  (public_name example)
  (modes
   (byte js))
+ (js_of_ocaml
+  (flags --disable share))
  (modules example)
  (libraries binaryen))

Contributing

You'll need Node.js and esy to build this project.
You should be able to use Opam if you are more comfortable with it, but the core team does all development using esy.

dune will take care of compiling Binaryen, so to build the project you'll only need to run:

esy

This will take a while. Once it's done, you can run the tests:

esy test
Install
Published
28 Jun 2022
Sources
libbinaryen-v108.0.0.tar.gz
md5=cb9031112295364fd898ec478fd8f853
sha512=305195eba075a79f1064d51f8ab416ee74690927689390aecbb75042646962d56917041cb65ff0b1a1c5ce27cf96c70238cf540da3830b4a8e44ab5046299c06
Dependencies
ocaml
>= "4.12"
js_of_ocaml-compiler
with-test & >= "3.10.0"
dune
>= "2.9.1"
Reverse Dependencies