Skip to content
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

Static binaries for the engine #696

Closed
franziskuskiefer opened this issue Jun 3, 2024 · 5 comments
Closed

Static binaries for the engine #696

franziskuskiefer opened this issue Jun 3, 2024 · 5 comments
Labels
engine Issue in the engine install

Comments

@franziskuskiefer
Copy link
Member

franziskuskiefer commented Jun 3, 2024

I (@W95Psp) investiguated that:

  • the JS build is quite slow, e.g. on libcrux node overflows, bun doesn't help
  • I tried a few hours to compile the engine statically, with no success
  • we can try is build under alpine with docker, but this will not help for MacOS

Other solutions:

  • arx (with nix bundle)
  • docker
  • find wether there is a big bottleneck when extracted in JS
  • ...
@W95Psp W95Psp added install engine Issue in the engine labels Jun 3, 2024
@W95Psp
Copy link
Collaborator

W95Psp commented Jun 20, 2024

Here is a small report on trying to produce distributable binaries for the hax-engine.

OCaml static binaries

After reading https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml/, I tried this approach but got some issues on linux.
Was not able to try anything on mac.

Js_of_ocaml

Ended up being either too slow or crashing because of stack overflow. There is no tail call optimization on node, I tried with bun wich has some, but got over performance issues.

I also had a issue about caml performances working on strings: parsing JSON was extremely slow, so I had to use JS's own JSON.parse and pipe that into the engine.

This solution works for running hax on small crates but performance is really really limiting.

nix bundle

The Nix build of the engine was shipping Rustc and was huge, #724 solves that.
With that PR, nix bundle --bundler github:ralismark/nix-appimage ".#hax-engine.bin" is building a small-ish portable AppImage linux binary. I think that's exactly what we need -- for linux!

Just ship dynamic binaries

On Mac, the only dynamic library we rely on is gmp, we can probably stop relying on zarith and thus get rid of that dependency.

Action items:

  • use nix bundle in the CI to release binaries
  • try to kill the dependency to gmp or copy the dylib over in case of MacOS

@franziskuskiefer
Copy link
Member Author

With #734 merged we should be good to go here?

@W95Psp
Copy link
Collaborator

W95Psp commented Jun 26, 2024

Yes, indeed! We should make a release and finish the small bit that downloads the engine from GH!

@W95Psp W95Psp closed this as completed Jun 26, 2024
@W95Psp
Copy link
Collaborator

W95Psp commented Jun 26, 2024

Shall I just increment the version in Cargo.toml, push on crates.io, and push a git ref to the repo?

@franziskuskiefer
Copy link
Member Author

Yeah, just make it a pre.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Issue in the engine install
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants