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

native gems via webassembly #18

Open
ngsankha opened this issue Mar 27, 2020 · 2 comments
Open

native gems via webassembly #18

ngsankha opened this issue Mar 27, 2020 · 2 comments

Comments

@ngsankha
Copy link

Hey! Amazing project and it got me thinking about how to build playgrounds for Ruby projects online without a server side Ruby process.

#9 mentions that we can use Emscripten's filesystem API to ship the standard library and other gems that we need. But what if some gem has C extensions, how would we compile that to webassembly and load them via Ruby?

@willglynn
Copy link
Collaborator

🤔

I'm pretty sure the approach requiring the least surgery would be to compile and link the gem's C sources into the Ruby executable and to merge the gem's Ruby sources into the filesystem. At this point it's not so much a gem as it is a distribution of Ruby which incorporates the gem.

Emscripten supports dlopen() so in principle gems could be loaded from external .wasm modules at runtime, but I strongly suspect getting gem to produce output which a WebAssembly ruby can dynamically link would be more difficult than incorporating extra native code into the existing build.

@ngsankha
Copy link
Author

Thanks for the response! The first approach seems like the way to go here. I'll try it out soon.

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