Skip to content

Pass -no-check-prims when js is the only listed linking mode#4213

Closed
nojb wants to merge 1 commit intoocaml:mainfrom
nojb:no-check-prims-js
Closed

Pass -no-check-prims when js is the only listed linking mode#4213
nojb wants to merge 1 commit intoocaml:mainfrom
nojb:no-check-prims-js

Conversation

@nojb
Copy link
Copy Markdown
Collaborator

@nojb nojb commented Feb 10, 2021

Fixes #4027

When js is the only listed linking mode for some executables, then -no-check-prims is automatically passed as a linking flag (it is made part of :standard).

Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
@nojb nojb requested a review from a user February 10, 2021 20:33
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I initially had in mind that the check would be "js is present but not byte". But in fact, if the user requests anything else that js then surely the C stubs have to be provided, so the more strict "modes ={js}" check seems better.

@ghost
Copy link
Copy Markdown

ghost commented Feb 11, 2021

it is made part of :standard

Just thinking about this again: why not make it part of the Linkage.t? It seems more like an option at the same level of -output-complete-exe to me. WDYT?

@nojb
Copy link
Copy Markdown
Collaborator Author

nojb commented Feb 11, 2021

it is made part of :standard

Just thinking about this again: why not make it part of the Linkage.t? It seems more like an option at the same level of -output-complete-exe to me. WDYT?

Thinking about your suggestion actually made me realize that there is a slight problem with how we handle the js mode. Today, when the user writes js in the (modes ...) field of an executable, we secretely add also the byte mode (if it is not already present). Later when these "link modes" (Link_mode.t) are translated into Linking.t's, byte gets promoted to byte_complete if shared libraries are not supported. But when using -output-complete-exe the resulting bytecode executable cannot be read by js_of_ocaml! (this is just from reading the code, haven't actually done the experiment)

This means that (modes js) is basically broken on systems without shared libraries... The only way I see to fix it is to actually write down a specific rule for js which always builds a pure bytecode executable, regardless of what is built for byte mode. What do you think?

Anyway, perhaps all this is better addressed in a different PR.

@ghost
Copy link
Copy Markdown

ghost commented Feb 15, 2021

This means that (modes js) is basically broken on systems without shared libraries... The only way I see to fix it is to actually write down a specific rule for js which always builds a pure bytecode executable, regardless of what is built for byte mode. What do you think?

That does seem like the most straightforward thing to do. It feels a bit sad to loose the sharing when everything lines up, but maybe we could try re-adding the sharing as an optimisation once we have a straightforward and working setup.

@nojb
Copy link
Copy Markdown
Collaborator Author

nojb commented Oct 25, 2021

This has bitrotted and needs to be looked afresh.

@nojb nojb closed this Oct 25, 2021
@nojb nojb mentioned this pull request Oct 25, 2021
9 tasks
@hhugo
Copy link
Copy Markdown
Collaborator

hhugo commented Dec 20, 2021

@nojb, #5049 doesn't works as expected it seems. See #5282.

Attempting to fix it in #5297 breaks my test. It is possible that the fix is correct and the test is wrong (simulating no shared library support with disable_dynamically_linked_foreign_archives=true).

Would you be able to test the fix ( #5297 ) please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when building js_of_ocaml program: "while linking cmo, the external function [...] is not available"

2 participants