Check link order when creating archive and when using ocamlopt #12084
Check link order when creating archive and when using ocamlopt #12084shindere merged 1 commit intoocaml:trunkfrom
Conversation
cc1e80c to
608b829
Compare
|
@shindere, you seemed to be interested by reviewing this PR. |
|
hhugo (2023/03/29 05:50 -0700):
@shindere, you seemed to be interested by reviewing this PR.
Yes, and still am. Apologies for having failed to do so until now. I'll
do my best to do it soon but if somebody else can do it's fine, too.
|
|
I've just rebased this PR on trunk. |
|
Here are a few rather shallow remarks: The In In I would find it helpfl if Also, the code refers to |
Moved
Done
Done
I've added some comments
I think they are compunits (and sub-units when using |
| Error: Wrong link order: "Lib" (lib.cmo) depends on "Main" (main.cmo) | ||
| File "_none_", line 1: | ||
| Error: No implementations provided for the following modules: | ||
| "Main" referenced from "Lib" (lib.cmo) |
There was a problem hiding this comment.
@Octachron, I've rebased the PR above your #12210. You're using Style.as_inline_code Location.print_filename to print filenames witch reads weird to me as filename is not code. How would you format the filename in the message above ? Should I change it to be from "Lib" ("lib.cmo") ?
There was a problem hiding this comment.
My precise semantic for the tag is : technical incise phrase that does not belong grammatically to its surrounding. In other words, since lib.cmo appears within an English sentence but is not supposed to be read as an English word, it should be quoted.
|
Very sorry about the delay, @hhugo. Apologies.
Overall: many thanks for the documentation you have written. It made it
significantly easier for me to get into the code.
It seems to me that the Copyright header as you have written it in the
linkcheck module is not yet good (it includes Xavier's name, for
instance). Perhpas you can take inspiration from e.g.
`ocamltest/main.ml`?
In an earlier comment, I have suggested to depart from the `globals`
terminology in your code. There are still leftovers, in the fields of
Linkcheck's t type. I think all these globals should be compunits.
I was also curious about why you use lists rather than sets in the
interface of linkcheck?
And also, for those types which are lists of lists I think more precise
comments would be helpful to give an insight about what exactly these
losts of lists represent.
I also had big name discussions with myself but the two of me couldn't
come to an agreement. I think `finish` could be better named, perhaps
validate or check. I understand that this second choice would repeat the
module name, and then I wondered whether the module could be renamed. I
wish `consistency` wouldn't be such a long word, because apart from its
length, a variation on `link_consistency` would have looked good to me.
Or perhaps, what about `linkdeps`? Aren't link dependencies what
we are dealing with, after all?
Then you could rename `finish` into `check` without any name clash or
redundancy.
I also wondered why you didn't use the newly introduced `Compunit` type.
Is it because that would have contaminated the native backend and you
wanted to avoid that?
Finally (for this round): is it mandatory to add all the units before
checking for consistency? Especially, in completemode, can't you check
for consistency as compunits get added? Or is it because the addition
has to be done in reverse topological order as you documented?
|
|
Am I correct that some reviews have not yet been taken into acocunt, or is |
I still need to look at @shindere 's last comments |
|
hhugo (2023/09/11 03:24 -0700):
> Am I correct that some reviews have not yet been taken into acocunt, or is this PR waiting for areview?
I still need to look at @shindere 's last comments
OK no problem, I just wanted to make sure this was not waiting for me
without me knowing.
|
I guess I\ve used list because input data uses list (e.g. cu_required_compunits, cu_reloc).
That's exactly the reason, I didn't want to deal with such an invasive change. Also, my initial patch predate the merge of your
Checking at the very end is more convenient to report all issues (and not just the first one) and deduplicated them. I'll try think about naming in the coming days |
|
@shindere, I've renamed the new file based on your suggestion. The PR should be ready for another round of review |
|
hhugo (2023/10/01 12:59 -0700):
Checking at the very end is more convenient to report all issues (and
not just the first one) and duplicated them.
You meant deduplicate them, didn't you?
|
Yes, I edited my answer on GitHub after the fact |
|
hhugo (2023/10/02 07:55 -0700):
@shindere, I've renamed the new file based on your suggestion. The PR
should be ready for another round of review
Thanks. I'll make sure to review as soon as posible.
|
|
This now needs a rebase because of #12586. The conflict should not be hard to resolve, though: add the line to the definition of There is also a conflict in In The docstring for I'm not sure the vertical alignment in the difinition of The docstring for The copyright in your linkdeps module is still not right, neither in the In In the definition of In the error reporting code, re:the message Shouldn't the constructor In all the files where it appears, how aobut renaming the I am wondering about In the testsuite, I think In the testfile: Why did you delete |
|
I would be happy to approve on @smuenzel's behalf if/when he himself feels good enough about the current state to approve it for merging -- maybe he already does. |
|
(I am assuming that this PR is not breaking programs that would work before, it only makes errors clearer and sometimes fails earlier. Is this indeed the case?) |
Very probably not. Unreferenced modules part of library files are removed before linking, so wrong dependencies in unreferenced modules don't cause errors today. With the proposed change, they will cause errors at library creation time. I think it's fine, but of course this is going to break existing code. |
Here is a comment from the deleted file: |
or creating archives with both ocamlopt and ocamlc
|
@shindere, I think I've finally addressed all your reviews. I've rebased and squashed all commits. |
|
Many thnaks for having taken into account most of the suggestions.
I write "most" because I believe that hte copyright header you have
added to `utils/ml{,i}` is still not correct: there is no company name,
whihc is minor, and I believe that the year you have written is wrong,
too.
However, I think the work is really nice and valuable and the PR has
been here for several months now so I am going to approve and merge as
it is so that we can move on and if you (or somebody else) wants to fix
the copyright header that can be done later.
Thanks again for the very nice work!
|
|
The compilation of Coccinelle is broken by this PR. The reason is that Coccinelle uses packs, but in a non-standard way: The internal libraries are built for a I see two main ways to fix this:
|
|
I have the impression that we could remove the pack prefix only when linking |
I don't think it is possible for another module to depend on Ideally I would like to make it clear that Coccinelle's use case is not supported, but it's hard to justify breaking something that has been working for so long. |
|
I can at least confirm that Octachron@1b9a4ef fixes the compilation of Coccinelle. |
|
I don't think your patch goes into the right direction (I don't even understand why you only pass the |
|
My reasoning for my test was mostly that I wanted to minimally fix cocinelle use case without allowing to store pack fragments inside a cmxa and I was worried to handle the case of packed module that "provides" multiple modules. However, since dependency doesn't traverse pack, I agree that using just Thus I agree that the real patch should just pass |
|
@lthls , do you prefer to open or review the fix PR? |
|
I would prefer reviewing. |
follow up on #12082.
Opening as a draft as tests are still missing.We currently only check link ordering when linking bytecode executables.
No implementations provided for the following modules.The PR proposes to detect wrong ordering in the 2 cases mentioned above.
The implementation of the check is shared in
utils/linkcheck.mlIn addition,
Wrong_link_orderhave been improved a bit by always mentioning the file an implementation comes from.