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

False positive your program contains effect handlers warning? #1375

Closed
johnridesabike opened this issue Jan 2, 2023 · 3 comments
Closed
Labels

Comments

@johnridesabike
Copy link
Contributor

Describe the bug

I recently tested a project with OCaml 5 and JSOO 5 and it printed this warning:

Warning: your program contains effect handlers; you should probably run js_of_ocaml with option '--enable=effects'

I'm almost certain that this is incorrect. None of the project's code has changed since using OCaml 4.14, and it only uses a few small dependencies. I opened the JavaScript output and saw that the Effect module functions are included, but do not seem to be called anywhere.

Expected behavior

The repository for my project: https://github.com/johnridesabike/acutis

Expected behavior:

  • Run dune build
  • Everything builds with no warnings.

Actual behavior: the above warning prints.

Versions

ocamlc: 5.0.0
js_of_ocaml: 5.0.1

@hhugo
Copy link
Member

hhugo commented Jan 2, 2023

This is due to the use of separate compilation. When compiling the stdlib to JS, we don't know yet whether the Effect module will be used or not later. Also, as tracked by #943, with separate compilation, we unconditionally link all modules of libraries.

In the short term, you can build with --profile release which disable separate compilation of JS. or change the compilation mode in the env stanza (see https://dune.readthedocs.io/en/stable/jsoo.html?highlight=separate#separate-compilation).

Once #943 is fixed, we should be able to improve the situation and only warn during the linking phase.

@johnridesabike
Copy link
Contributor Author

Thanks for the information! I can confirm that --profile release does indeed build without the warning.

It may be useful to include that information in the documentation and/or readme. I can imagine that other people may see the warning and incorrectly assume that they need to use --enable=effects when they actually do not.

@hhugo
Copy link
Member

hhugo commented Jan 7, 2023

This was fixed in #1378. We still need to wait for a dune release including ocaml/dune#6832 and then change the default value for auto-link in jsoo.

@hhugo hhugo closed this as completed Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants