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

[Documentation] non-docker way to build wasm? #11

Closed
rubyFeedback opened this issue May 3, 2022 · 5 comments
Closed

[Documentation] non-docker way to build wasm? #11

rubyFeedback opened this issue May 3, 2022 · 5 comments

Comments

@rubyFeedback
Copy link

The documentation currently states:

"It's recommended building on a builder Docker container, which installs all dependencies and provides environment variables:"

However had, I have not used docker so far myself.

I compile stuff from source, including ruby. Is it possible to use ruby-wasm without docker, or is docker mandatory?

If docker is optional then perhaps the main README could mention how to get ruby.wasm installed.

I have compiled node-js from source successfully; npm works fine. So all that would be necessary is a better
clarification how to get ruby-wasm to work without being dependent on docker (I'd prefer to not add another
dependency if that is possible, e. g. keep stuff as much as "ruby" as possible).

I had a look at ruby-wasm due to that: https://bugs.ruby-lang.org/issues/18761 but I did not even get to the
part where I could test the other instructions given, since I failed at the docker step. ("rake" does not work
for me in general, no idea why; "gem install" on the other hand works almost always. "rake" only gave
me a useless message such as "Don't know how to build task 'default'", which of course, as is typical for
rake, doesn't tell the user anything at all. Hopefully we can improve the ruby ecosystem in general - gem
is really the best from all the alternatives, in my opinion.).

@kateinoigakukun
Copy link
Member

The build steps for setting up tools are a little bit complicated, so it's recommended to use docker image, but it's optional.
If you want to build outside of the image, you need to install tools and set environment variables correctly following the section: https://github.com/ruby/ruby.wasm#dependencies

Since the step is complicated, I don't want to write it down in a natural language for maintainability. I hope the Dockerfile script and CI configuration would help you to understand the build steps.

@rkh
Copy link

rkh commented May 23, 2022

Running rake build:head-wasm32-unknown-wasi-full is absurdly slow for me (probably due to virtualization, this is on a MacBook M1 Max). The command has been running for hours (still showing progress). Once I made sure it works I'll try to build without docker and can report back.

@kateinoigakukun
Copy link
Member

@rkh Thank you for your try:) Just FYI, adding -e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" to docker run would speed up the ruby build.

@rkh
Copy link

rkh commented May 24, 2022

@kateinoigakukun Oh great. FYI running it in Docker works like a charm, not a single hick up, other than it being slow (for us this isn't a deal breaker, can move it to a beefy build system).

@rubyFeedback unless you want to patch Ruby or compile a native extension, you shouldn't need to install Docker at all to build a wasm. Instead follow the wasi-vfs steps in the readme. Significantly faster as well. You can also selectively include the standard library, add your own Ruby files, etc.

@kateinoigakukun
Copy link
Member

I've updated the build system to install dependencies automatically on demand, and it's now docker-free. Also added build instructions in CONTRIBUTING.md.

Feel free to re-open this issue if there is something missed.

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

No branches or pull requests

3 participants