Skip to content

wasm/README.md: Add a note about the Ruby built for wasm. [ci skip] #6707

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 10, 2022

Conversation

junaruga
Copy link
Member

@junaruga junaruga commented Nov 10, 2022

Hello,
I would like to update the current document about wasm, WebAssembly. Because I needed extra info to explain to other people that "the WASI feature only works with the WebAssembly runtime, but can't be used like normal Ruby without the WebAssembly runtime" .

The modified README.md is here.

The Ruby built for wasm cannot be executed without a WebAssembly runtime.

$ ruby-wasm32-wasi/usr/local/bin/ruby -e 'puts "a"'
bash: ruby-wasm32-wasi/usr/local/bin/ruby: cannot execute binary file: Exec format error

Because the Ruby's file type is different from the one built normally, that is the /usr/local/ruby-3.2.0-preview2/bin/ruby below.

$ file ruby-wasm32-wasi/usr/local/bin/ruby
ruby-wasm32-wasi/usr/local/bin/ruby: WebAssembly (wasm) binary module version 0x1 (MVP)

$ file /usr/local/ruby-3.2.0-preview2/bin/ruby
/usr/local/ruby-3.2.0-preview2/bin/ruby: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a37822085e285c0971159982e7642dda88cea606, for GNU/Linux 3.2.0, with debug_info, not stripped

Though perhaps this might be for another PR, I think another possible improvement is the following part in the current document - Steps. I have no idea what the --with-ext=ripper,monitor is dong.

$ ./configure LDFLAGS="-Xlinker -zstack-size=16777216" \
  --host wasm32-unknown-wasi \
  --with-destdir=./ruby-wasm32-wasi \
  --with-static-linked-ext \
  --with-ext=ripper,monitor

I did see the explanation.

$ ./configure --help
...
  --with-ext=EXTS         pass to --with-ext option of extmk.rb
...

I think adding one more configure script example as a typically used command example with the minimal configure options in the document is helpful for users. This could be like this?

$ ./configure LDFLAGS="-Xlinker -zstack-size=16777216" \
  --prefix=/path/to/ruby-wasi \
  --host wasm32-unknown-wasi \
  --with-static-linked-ext \

I just checked the current CI for wasm, and the --with-ext is not used.

../src/configure \
--host wasm32-unknown-wasi \
--with-static-linked-ext \
LDFLAGS=" \
-Xlinker --stack-first \
-Xlinker -z -Xlinker stack-size=16777216 \
" \
optflags="${{ matrix.entry.optflags }}" \
debugflags="${{ matrix.entry.debugflags }}" \
wasmoptflags="${{ matrix.entry.wasmoptflags }} ${{ matrix.entry.debugflags }}"

So, what do you think?

The Ruby built for wasm cannot be execute without a WebAssembly runtime.

```
$ ruby-wasm32-wasi/usr/local/bin/ruby -e 'puts "a"'
bash: ruby-wasm32-wasi/usr/local/bin/ruby: cannot execute binary file: Exec format error
```

Because the Ruby's file type is different from the one built normally, that is
the `/usr/local/ruby-3.2.0-preview2/bin/ruby` below.

```
$ file ruby-wasm32-wasi/usr/local/bin/ruby
ruby-wasm32-wasi/usr/local/bin/ruby: WebAssembly (wasm) binary module version 0x1 (MVP)

$ file /usr/local/ruby-3.2.0-preview2/bin/ruby
/usr/local/ruby-3.2.0-preview2/bin/ruby: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a37822085e285c0971159982e7642dda88cea606, for GNU/Linux 3.2.0, with debug_info, not stripped
```
@kateinoigakukun
Copy link
Member

kateinoigakukun commented Nov 10, 2022

Though perhaps this might be for another PR, I think another possible improvement is the following part in the current document - Steps. I have no idea what the --with-ext=ripper,monitor is dong.

I intentionally selected them to make require "rubygems" succeed at the prelude. Without them, users have to pass --disable-gems. But I think it makes sense to select unavailable exts by --with-out-ext=. As far as I've checked, only pty fails at make-time, so --with-out-ext=pty would be enough as a minimal configuration.

I just checked the current CI for wasm, and the --with-ext is not used.

That's because the current CI only builds miniruby.

@kateinoigakukun kateinoigakukun merged commit 4c55409 into ruby:master Nov 10, 2022
@junaruga junaruga deleted the wip/wasm-doc branch November 23, 2022 11:52
@junaruga
Copy link
Member Author

Thank you for clarifying your intent!

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.

2 participants