-
Notifications
You must be signed in to change notification settings - Fork 188
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
Separate compilation: Link only what we need #1378
Conversation
73978a0
to
bfd6578
Compare
Dune integration discussed in ocaml/dune#6832 |
bfd6578
to
932fc94
Compare
932fc94
to
904cf10
Compare
This is an exciting patch. I can test this out, hopefully sometime today. |
904cf10
to
4b66609
Compare
I'm getting the following build warnings from this patch:
I'm assuming this patch has changed something to cause those messages to be printed, since we weren't getting these warnings before. Is this new warning expected? If so, what is the right response? One obvious answer is to add |
Oh, it's worth saying that I didn't get to the point of adding the |
This warning is not new. it used to trigger on empty cma but it was fixed quite sometime ago. I suspect that it now triggers because we compile module from a cma individually and one of the module doesn't have debug info. |
I see. If I understand right, this is a bug in this PR, since it is okay for individual modules to not have any debug info. |
It's ok but could result in worse sourcemap. One could argue that the warning is correct. Is there a good reason for omitting the -g for some modules only ? |
I'm assuming our build system doesn't selectively omit -g (I'll double-check this assumption; EDIT: assumption seems correct), so either
|
Compiling an empty module doesn't trigger the warning. Could you give details about the command triggering the warning ? |
Inside
Which spits out the warning twice. A lot of other commands have the same warning, but this one is representative. |
Are you still running ocaml 4.12 ? |
How is |
@pmwhite, looking at old jenga-rules available on github, I suspect that you still don't pass |
No, 4.14 now.
This is the slightly sanitize version of the command that the build system runs.
|
Check the command generating |
Yeah, this is probably it. The command that builds jsoo_testsuite.cmo was missing I'm now running into a different set of issues that I'll report if I can't figure them out myself. |
ea612b4
to
d901089
Compare
d901089
to
c948306
Compare
@pmwhite, My last commit disable the feature by default so that the PR can be release without silently breaking inline_tests with dune. For testing you can enable it with the |
I realized I may not be understanding what this PR actually does. I was under the impression that we already were trimming unnecessary files, and that this moved the granularity down to the module level instead (this is just based on the description - I haven't read the code in the PR). However, now I'm thinking that this actually merely extends the tree-shaking from whole-program compilation into separate compilation as well. Is that the right way to think about it? Are the inclusion semantics for whole and separate compilation now exactly the same? |
This is the intent
Both whole program compilation and separate compilation perform some deadcode elimination based on what they know. The DCE should not remove any side-effects. When doing whole program compilation, we rely on the link ouput of ocamlc which does drop unused compilations units present in cma files. This PR implement the same drop logic inside jsoo when doing separate compilation. |
Just as an update on the testing of this PR: I've not yet done all the testing I plan to, since it's a bit of work to get the build system to pass link-all in the right places. I'll update this thread when I eventually get to it. |
Any update? |
@hhugo No, not yet. It's on my stack of things to do, but I haven't gotten around to it yet. |
…s_of_ocaml-ppx_deriving_json, js_of_ocaml-ppx, js_of_ocaml-lwt and js_of_ocaml-compiler (5.1.0) CHANGES: ## Features/Changes * Lib: Added support for KeyboardEvent.getModifierState * Misc: bump min ocaml version to 4.08 * Misc: remove some old runtime files to support some external libs * Misc: switch to dune 3.7 * Effects: partial CPS transformation, resulting in much better performances, lower compilation time and smaller generated code * Compiler: separate compilation can now drops unused units when linking (similar to ocamlc). (ocsigen/js_of_ocaml#1378) * Compiler: specialize string to js-string conversion for all valid utf8 strings (previously just ascii) * Compiler: JavaScript files generated by `js_of_ocaml` are now UTF-8 encoded. * Compiler: use identifier for object literals when possible * Compiler: Cache function arity (the length prop of a function is slow with v8) * Compiler: The js lexer is now utf8 aware, recognize and emit utf8 ident * Compiler: Update the js lexer with new number literal syntax * Compiler: update js parser to support most es6 feature (ocsigen/js_of_ocaml#1391) * Compiler: stop parsing the builtin js runtime if not necessary * Compiler: improve js pretty printer (ocsigen/js_of_ocaml#1405) * Compiler: improve debug location and speedup compilation (ocsigen/js_of_ocaml#1407) * Toplevel: Enable separate compilation of toplevels * Runtime: js backtrace recording controled by OCAMLRUNPARAM * Runtime: support for zstd decompression of marshalled data (ocaml.5.1) (ocsigen/js_of_ocaml#12006) * Runtime: stub out custom runtime events symbols for OCaml 5.1 (ocsigen/js_of_ocaml#1414) ## Bug fixes * Effects: fix Js.export and Js.export_all to work with functions (ocsigen/js_of_ocaml#1417,ocsigen/js_of_ocaml#1377) * Sourcemap: fix incorrect sourcemap with separate compilation * Compiler: fix control flow analysis; some annotions were wrong in the runtime * Compiler: js backtrace recording respected in the js runtime and when using effects * Compiler: no longer fail on invalid source file (when the file is a directory) * Runtime: fix the compilation of some mutually recursive functions
…s_of_ocaml-ppx_deriving_json, js_of_ocaml-ppx, js_of_ocaml-lwt and js_of_ocaml-compiler (5.1.0) CHANGES: ## Features/Changes * Lib: Added support for KeyboardEvent.getModifierState * Misc: bump min ocaml version to 4.08 * Misc: remove some old runtime files to support some external libs * Misc: switch to dune 3.7 * Effects: partial CPS transformation, resulting in much better performances, lower compilation time and smaller generated code * Compiler: separate compilation can now drops unused units when linking (similar to ocamlc). (ocsigen/js_of_ocaml#1378) * Compiler: specialize string to js-string conversion for all valid utf8 strings (previously just ascii) * Compiler: JavaScript files generated by `js_of_ocaml` are now UTF-8 encoded. * Compiler: use identifier for object literals when possible * Compiler: Cache function arity (the length prop of a function is slow with v8) * Compiler: The js lexer is now utf8 aware, recognize and emit utf8 ident * Compiler: Update the js lexer with new number literal syntax * Compiler: update js parser to support most es6 feature (ocsigen/js_of_ocaml#1391) * Compiler: stop parsing the builtin js runtime if not necessary * Compiler: improve js pretty printer (ocsigen/js_of_ocaml#1405) * Compiler: improve debug location and speedup compilation (ocsigen/js_of_ocaml#1407) * Toplevel: Enable separate compilation of toplevels * Runtime: js backtrace recording controled by OCAMLRUNPARAM * Runtime: support for zstd decompression of marshalled data (ocaml.5.1) (ocsigen/js_of_ocaml#12006) * Runtime: stub out custom runtime events symbols for OCaml 5.1 (ocsigen/js_of_ocaml#1414) ## Bug fixes * Effects: fix Js.export and Js.export_all to work with functions (ocsigen/js_of_ocaml#1417,ocsigen/js_of_ocaml#1377) * Sourcemap: fix incorrect sourcemap with separate compilation * Compiler: fix control flow analysis; some annotions were wrong in the runtime * Compiler: js backtrace recording respected in the js runtime and when using effects * Compiler: no longer fail on invalid source file (when the file is a directory) * Runtime: fix the compilation of some mutually recursive functions
Fix #943 and #1375
js_of_ocaml link
now accept a--linkall
flags.ISSUE
-linkall
information. In practice, with this PR, it means that inline_tests are broken because the library containing the tests is no longer linked.TODO