Skip to content

Js_of_ocaml separate compilation issue when using some jsoo flags. #6679

@hhugo

Description

@hhugo

Users can pass arbitrary flags to js_of_ocaml (since #5049).
When using separate compilation, js_of_ocaml needs to compile multiple bits (runtime.js, deps*.cma.js, and *cmo.js) separately and link everything together.

The isssue is that some jsoo flags (e.g --enable use-js-string, --enable effects) require that all individual bits are compiled the same way or the generated js might not work correctly. ocsigen/js_of_ocaml#1346 improves the situation a bit by having jsoo complain if this is not the case, instead of emitting invalid JS.

As far as I know, we mostly have an issue with how we compile cma files to js.
We currently setup a single rule per lib (in _build/default/.js/{LIB}/ for findlib libraries and in _build/default/{PATH_TO_LIB}/.{LIB}.objs/) but we would need to generate rules based on the jsoo flags used by executables.

One easy solution would be to declare all cma.js rules needed by an executable for each executables but we would lose sharing which kind of defeat the purpose of separate compilation.

Any suggestion ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions