Skip to content

Commit

Permalink
jsoo: forward linkall flag in whole program compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Hugo Heuzard <hugo.heuzard@gmail.com>
  • Loading branch information
hhugo committed Sep 25, 2024
1 parent 1a8b43f commit 635c1d9
Show file tree
Hide file tree
Showing 2 changed files with 19 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

0 comments on commit 635c1d9

Please sign in to comment.