-
Notifications
You must be signed in to change notification settings - Fork 455
fix(oxcaml): js_of_ocaml compile whole for parameterised instances #12762
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
Open
art-w
wants to merge
1
commit into
ocaml:main
Choose a base branch
from
art-w:instantiate-parameterized-jsoo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+135
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
test/blackbox-tests/test-cases/oxcaml/parameterised-jsoo.t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| Testing that js_of_ocaml works with the instantiation of parameterised libs. | ||
| At the moment, js_of_ocaml does not support the separate compilation of | ||
| parameterised instances, so only whole program compilation is available. | ||
|
|
||
| $ cat > dune-project <<EOF | ||
| > (lang dune 3.21) | ||
| > (using oxcaml 0.1) | ||
| > EOF | ||
|
|
||
| First define a parameter: | ||
|
|
||
| $ mkdir param | ||
| $ echo 'val param : string' > param/param.mli | ||
| $ cat > param/dune <<EOF | ||
| > (library_parameter (name param)) | ||
| > EOF | ||
|
|
||
| Then an implementation of this parameter: | ||
|
|
||
| $ mkdir impl | ||
| $ echo 'let param = Util.util' > impl/impl.ml | ||
| $ echo 'let util = "impl"' > impl/util.ml | ||
| $ cat > impl/dune <<EOF | ||
| > (library (name impl) (implements param)) | ||
| > EOF | ||
|
|
||
| And another implementation: | ||
|
|
||
| $ mkdir impl2 | ||
| $ echo 'let param = "impl2"' > impl2/impl2.ml | ||
| $ cat > impl2/dune <<EOF | ||
| > (library (name impl2) (implements param)) | ||
| > EOF | ||
|
|
||
| Then a parameterised library: | ||
|
|
||
| $ mkdir lib | ||
| $ echo 'let lib () = "lib(" ^ Param.param ^ ") " ^ Helper.helper' > lib/lib.ml | ||
| $ echo 'let helper = "helper(" ^ Param.param ^ ")"' > lib/helper.ml | ||
| $ cat > lib/dune <<EOF | ||
| > (library (name lib) (parameters param)) | ||
| > EOF | ||
|
|
||
| And another parameterised library: | ||
|
|
||
| $ mkdir lib2 | ||
| $ echo 'let lib2 () = "lib2(" ^ Lib_param.lib () ^ ", " ^ Lib_impl2.lib () ^ ")"' > lib2/lib2.ml | ||
| $ cat > lib2/dune <<EOF | ||
| > (library | ||
| > (name lib2) | ||
| > (parameters param) | ||
| > (libraries | ||
| > (instantiate lib :as lib_param) | ||
| > (instantiate lib impl2 :as lib_impl2))) | ||
| > EOF | ||
|
|
||
| Then an executable, with a couple more instantiations of parameterised libraries: | ||
|
|
||
| $ mkdir bin | ||
| $ echo 'let () = A.a (); B.b (); C.c ()' > bin/bin.ml | ||
| $ echo 'let a () = print_endline (Lib2_impl.lib2 ())' > bin/a.ml | ||
| $ echo 'let b () = print_endline (Lib2_impl2.lib2 ())' > bin/b.ml | ||
| $ echo 'let c () = print_endline (Lib_impl.lib ())' > bin/c.ml | ||
| $ cat > bin/dune <<EOF | ||
| > (executable | ||
| > (name bin) | ||
| > (modes byte js wasm) | ||
| > (libraries | ||
| > (instantiate lib2 impl :as lib2_impl) | ||
| > (instantiate lib2 impl2 :as lib2_impl2) | ||
| > (instantiate lib impl :as lib_impl))) | ||
| > EOF | ||
|
|
||
| $ dune exec ./bin/bin.exe | ||
| lib2(lib(impl) helper(impl), lib(impl2) helper(impl2)) | ||
| lib2(lib(impl2) helper(impl2), lib(impl2) helper(impl2)) | ||
| lib(impl) helper(impl) | ||
|
|
||
| Testing byte compilation: | ||
|
|
||
| $ dune exec ./bin/bin.bc | ||
| lib2(lib(impl) helper(impl), lib(impl2) helper(impl2)) | ||
| lib2(lib(impl2) helper(impl2), lib(impl2) helper(impl2)) | ||
| lib(impl) helper(impl) | ||
|
|
||
| Testing js_of_ocaml: | ||
|
|
||
| $ dune build ./bin/bin.bc.js | ||
| $ node _build/default/bin/bin.bc.js | ||
| lib2(lib(impl) helper(impl), lib(impl2) helper(impl2)) | ||
| lib2(lib(impl2) helper(impl2), lib(impl2) helper(impl2)) | ||
| lib(impl) helper(impl) | ||
|
|
||
| Testing wasm_of_ocaml: | ||
|
|
||
| $ dune build ./bin/bin.bc.wasm.js | ||
| $ node _build/default/bin/bin.bc.wasm.js | ||
| lib2(lib(impl) helper(impl), lib(impl2) helper(impl2)) | ||
| lib2(lib(impl2) helper(impl2), lib(impl2) helper(impl2)) | ||
| lib(impl) helper(impl) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this limitation permanent or will it be relaxed in a later
jsooversion?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to know if support is needed inside the jsoo compiler or if one just need to fix the dune rule ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some explanations in #12564 (comment) regarding the bytecode error I'm seeing when doing separate compilation in jsoo, so I think it requires an oxcaml-specific patch in jsoo before we can change the dune rules for separate compilation :)