Skip to content

Remove createDyncallWrapper and its usage #22825

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

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 1, 2024

This change effectively reverts #17328.

IIUC the dynCall_xxx helpers for a given side module should always be exported by that side module. i.e. for all possible indirect calls a dynCall_xxx wrapper should already exist either in the main module or the side module.

This change effectively reverts emscripten-core#17328.

IIUC the `dynCall_xxx` helpers for a given side module should always be
exported by that side module.  i.e. for all possible indirect calls
a `dynCall_xxx` wrapper should already exist either in the main module
or the side module.
@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 1, 2024

@hoodmane, can you explain your use case a little more and why #17328 was needed in the first place? How were you able to create a side module without the corresponding dynCall_xxx exports? Is it possible you didn't use emcc to link the side module perhaps and therefore the binaryen pass for creating these exports was never run? If so, then I think the solution is to use binaryen to create them at build time, rather than this method of adding them at runtime.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 1, 2024

Its also possible that you were using RTLD_LOCAL, in which case you use case should have been fixed by #22625.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 4, 2024

@hoodmane, could you take a look? I don't want to remove this feature you added if its going to break your use case.

@sbc100 sbc100 requested a review from kripken November 4, 2024 20:40
@hoodmane
Copy link
Collaborator

hoodmane commented Nov 4, 2024

I'll try to look into it later this week, but if it causes a problem we can always just revert it downstream. Emscripten is quite easy to patch thankfully.

As far as I understand my original messages, the problem only comes up from Rust shared libraries when -sWASM_BIGINT isn't passed? Pyodide always uses -sWASM_BIGINT these days, so I don't think it will be negatively affected. And hopefully now that we've merged the -lc fix to rust-lang/libc we'll be able to switch Rust itself to link with -sWASM_BIGINT.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 4, 2024

I'll try to look into it later this week, but if it causes a problem we can always just revert it downstream. Emscripten is quite easy to patch thankfully.

As far as I understand my original messages, the problem only comes up from Rust shared libraries when -sWASM_BIGINT isn't passed? Pyodide always uses -sWASM_BIGINT these days, so I don't think it will be negatively affected. And hopefully now that we've merged the -lc fix to rust-lang/libc we'll be able to switch Rust itself to link with -sWASM_BIGINT.

Right, if that is the case I would hope we wouldn't have to support that use case upstream. i.e. linking side modules built with -sWASM_BIGINT and main modules built without (or vice versa). Its seems reasonable that flags such as -sWASM_BIGINT should agree across the whole program.

@hoodmane
Copy link
Collaborator

hoodmane commented Nov 4, 2024

flags such as -sWASM_BIGINT should agree across the whole program.

To be clear, I was never attempting to use .so files with a different setting than the main module. Using RUSTFLAGS=-Clink-arg=-sWASM_BIGINT -Clink-arg=-sSIDE_MODULE I make sure that Rust links a shared library with -sWASM_BIGINT. The original problem was coming up when both main module and (Rust) side module were not using -sWASM_BIGINT.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 4, 2024

flags such as -sWASM_BIGINT should agree across the whole program.

To be clear, I was never attempting to use .so files with a different setting than the main module. Using RUSTFLAGS=-Clink-arg=-sWASM_BIGINT -Clink-arg=-sSIDE_MODULE I make sure that Rust links a shared library with -sWASM_BIGINT. The original problem was coming up when both main module and (Rust) side module were not using -sWASM_BIGINT.

Ah, I think that should no longer be an issue after #22625. The side module should always export any dynCall helpers that it could need (same with the main module).

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 4, 2024

flags such as -sWASM_BIGINT should agree across the whole program.

To be clear, I was never attempting to use .so files with a different setting than the main module. Using RUSTFLAGS=-Clink-arg=-sWASM_BIGINT -Clink-arg=-sSIDE_MODULE I make sure that Rust links a shared library with -sWASM_BIGINT. The original problem was coming up when both main module and (Rust) side module were not using -sWASM_BIGINT.

Ah, I think that should no longer be an issue after #22625. The side module should always export any dynCall helpers that it could need (same with the main module).

To confirm do you use RTDL_LOCAL when loading these side module (#22625 was specifically for that mode).

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm if the current discussion does not find a remaining use for this.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 6, 2024

I'll wait to hear back from @hoodmane if RTDL_LOCAL was being used.

@hoodmane
Copy link
Collaborator

hoodmane commented Nov 6, 2024

Yeah we're using RTLD_LOCAL. So I think there are several reasons we don't need this.

@hoodmane
Copy link
Collaborator

hoodmane commented Nov 6, 2024

Thanks for checking @sbc100!

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 6, 2024

Yeah we're using RTLD_LOCAL. So I think there are several reasons we don't need this.

Awesome. In that case I feel pretty confident landing this change since I believe #22625 handled that case.

@sbc100 sbc100 merged commit b5ffb21 into emscripten-core:main Nov 6, 2024
28 checks passed
@sbc100 sbc100 deleted the remove_createDyncallWrapper branch November 6, 2024 17:54
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.

3 participants