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

Making js_of_ocaml compiler self-contained ? #966

Closed
nojb opened this issue Feb 18, 2020 · 8 comments
Closed

Making js_of_ocaml compiler self-contained ? #966

nojb opened this issue Feb 18, 2020 · 8 comments

Comments

@nojb
Copy link
Contributor

nojb commented Feb 18, 2020

Currently the js_of_ocaml compiler requires the runtime.js to be installed alongside it. dune uses ocamlfind to locate runtime.js. This means that one needs to have ocamlfind to use js_of_ocaml and it means that you need to install js_of_ocaml in order to use it.

To avoid the dependency on ocamlfind on Windows I implemented a workaround for dune (ocaml/dune#1467). However, I was wondering if you had given any thought to the idea of getting rid of the runtime.js file and simply including it as a string in the compiled compiler binary. A flags could be added to produce the file on standard output in case it is needed.

This would make the binary completely self-contained. If there is interest in this proposal I could look into implementing it (together with the necessary adaptations for dune). I recently implemented something very similar for menhir (which also depends on a "runtime" file like runtime.js) and it worked nicely.

@hhugo
Copy link
Member

hhugo commented Feb 18, 2020

This seems reasonable.

Note that there are other runtime files sometime required and not included in runtime.js: dynlink.js, toplevel.js

@hhugo
Copy link
Member

hhugo commented Apr 4, 2020

Work in progress #978

@hhugo
Copy link
Member

hhugo commented Apr 15, 2020

This is now done. I'll open a PR to cleanup dune rules later

@hhugo hhugo closed this as completed Apr 15, 2020
@nojb
Copy link
Contributor Author

nojb commented Apr 15, 2020

Great, thanks! I will try to test it in a bit.

@hhugo
Copy link
Member

hhugo commented Apr 15, 2020

ocaml/dune#3375

@bobzhang
Copy link
Contributor

@hhugo this looks great.
It seems that jsoo compile xx.byte still relies on something from findlib so that I can not copy jsoo byte code to a different machine.
There are two places where I found depend on findb:

  • findlib.ml resolves findlib.conf directly, we can fake findlib.conf using OCAMLFINDLIBCONF though
  • jsoo calls Findlib.find_pkg_dir "stdlib", can this be called in a lazy style when it is really needed -- otherwise I guess this still brings in dependencies on findlib/stdlib/META file

@hhugo
Copy link
Member

hhugo commented May 11, 2020

@bobzhang, the findlib dependency is optional ! You should be able to build without it.
Just remove the following lines in the dune file

    (select findlib_support.ml from
     ;; Only link js_of_ocaml-compiler.findlib-support if it exists
     (js_of_ocaml-compiler.findlib-support -> findlib_support.empty.ml)
     (                                     -> findlib_support.empty.ml))

@bobzhang
Copy link
Contributor

@hhugo that's exactly what I need. FYI, we have successful stories using the bytecode compiler rescript-lang/rescript#4372 -- the motivation is less dependencies for the CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants