Skip to content

Commit

Permalink
Pass the linkall flag to jsoo in whole program compilation as well (#…
Browse files Browse the repository at this point in the history
…10935)

Signed-off-by: Hugo Heuzard <hugo.heuzard@gmail.com>
  • Loading branch information
hhugo authored Sep 28, 2024
1 parent c260802 commit 71db2d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/changes/10935.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Forward the linkall flag to jsoo in whole program compilation as well (#10935, @hhugo)
20 changes: 18 additions & 2 deletions src/dune_rules/jsoo/jsoo_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,25 @@ let standalone_runtime_rule cc ~javascript_files ~target ~flags =
~config:(Some config)
;;

let exe_rule cc ~javascript_files ~src ~target ~flags =
let exe_rule cc ~linkall ~javascript_files ~src ~target ~flags =
let dir = Compilation_context.dir cc in
let sctx = Compilation_context.super_context cc in
let libs = Compilation_context.requires_link cc in
let linkall =
let open Action_builder.O in
let+ linkall = linkall
and+ jsoo_version =
let* jsoo = jsoo ~dir sctx in
Action_builder.of_memo @@ Version.jsoo_version jsoo
in
Command.Args.As
(match jsoo_version, linkall with
| Some version, true ->
(match Version.compare version (5, 1) with
| Lt -> []
| Gt | Eq -> [ "--linkall" ])
| None, _ | _, false -> [])
in
let spec =
Command.Args.S
[ Resolve.Memo.args
Expand All @@ -303,6 +318,7 @@ let exe_rule cc ~javascript_files ~src ~target ~flags =
Command.Args.Deps (jsoo_runtime_files libs))
; Deps (List.map ~f:Path.build javascript_files)
; Dep (Path.build src)
; Dyn linkall
]
in
js_of_ocaml_rule sctx ~sub_command:Compile ~dir ~spec ~target ~flags ~config:None
Expand Down Expand Up @@ -549,7 +565,7 @@ let build_exe
in
()
| Whole_program ->
exe_rule cc ~javascript_files ~src ~target ~flags ~sourcemap
exe_rule cc ~linkall ~javascript_files ~src ~target ~flags ~sourcemap
|> Super_context.add_rule sctx ~loc ~dir ~mode
;;

Expand Down
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/jsoo/inline-tests.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Run inline tests using node js
inline tests (JS)

$ dune runtest --profile release
Warning: your program contains effect handlers; you should probably run js_of_ocaml with option '--enable=effects'
inline tests (JS)
inline tests (JS)
inline tests (Native)
Expand Down

0 comments on commit 71db2d4

Please sign in to comment.