diff --git a/doc/changes/10935.md b/doc/changes/10935.md new file mode 100644 index 00000000000..d6b1a2bf0f8 --- /dev/null +++ b/doc/changes/10935.md @@ -0,0 +1 @@ +- Forward the linkall flag to jsoo in whole program compilation as well (#10935, @hhugo) \ No newline at end of file diff --git a/src/dune_rules/jsoo/jsoo_rules.ml b/src/dune_rules/jsoo/jsoo_rules.ml index 52f7941c75f..148479f7c78 100644 --- a/src/dune_rules/jsoo/jsoo_rules.ml +++ b/src/dune_rules/jsoo/jsoo_rules.ml @@ -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 @@ -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 @@ -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 ;; diff --git a/test/blackbox-tests/test-cases/jsoo/inline-tests.t/run.t b/test/blackbox-tests/test-cases/jsoo/inline-tests.t/run.t index fba35fdc48e..87386212671 100644 --- a/test/blackbox-tests/test-cases/jsoo/inline-tests.t/run.t +++ b/test/blackbox-tests/test-cases/jsoo/inline-tests.t/run.t @@ -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)