Skip to content
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

Use of ffi in emscripten build #876

Open
deepankarsharma opened this issue Sep 27, 2024 · 2 comments
Open

Use of ffi in emscripten build #876

deepankarsharma opened this issue Sep 27, 2024 · 2 comments

Comments

@deepankarsharma
Copy link

I have native code on an amd64 machine where I am able to use SDL via Chez's excellent FFI. I am exploring options for making the same code working in the browser. I am able to compile Chez for emscripten using instructions provided in the BUILDING document. Separately I am able to compile SDL for the web. Would appreciate any pointers on whether I could load the SDL wasm at runtime in the browser and bind to it or alternatively if in the emscripten build I could include it in the boot image. If this isnt possible, knowing that would be helpful too.

@mflatt
Copy link
Contributor

mflatt commented Sep 29, 2024

I can imagine that linking SDL into an Emscripten build Chez Scheme could work, but only if the FFI shapes that you need fit into the subset that is supported directly by pb. Those shapes the ones enumerated by define-pb-prototypes in cmacros.ss: https://github.com/cisco/ChezScheme/blob/main/s/cmacros.ss#L3388. They're the shapes that Chez Scheme needs for itself to access kernel functionality.

If ithe supported set happens to be close and you just need to add one or two, then I think we could entertain the possibly of adding them. To try that yourself, you'd modify both s/cmacro.ss and c/pb.c at the pb_call case.

Edit: You'd probably also need to create a little more C code to register SDL functions using Sforeign_symbol, unless dlopen for Emscripten works better than my guess.

@deepankarsharma
Copy link
Author

Thanks for the pointers, let me dig a bit and will get back to you.

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

No branches or pull requests

2 participants