-
Couldn't load subscription status.
- Fork 5.5k
Add WASI based WebAssembly support #5407
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
kateinoigakukun
merged 20 commits into
ruby:master
from
kateinoigakukun:wasm-wasi-upstream-pr
Jan 19, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1a4fd55
[wasm] configure.ac: disable stack-protector
kateinoigakukun 413dc9d
[wasm] configure.ac: setup platform specific libraries
kateinoigakukun 55f3538
[wasm] add asyncify based setjmp, fiber, register scan emulation
kateinoigakukun ffc4ffe
[wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc
kateinoigakukun da06fa1
[wasm] add coroutine/asyncify implementation
kateinoigakukun 386d592
[wasm] eval_inter.h gc.c vm_core.h: include wasm/setjmp.h instead of …
kateinoigakukun 64c0c55
[wasm] gc.c: disable read signal barrier for wasi
kateinoigakukun 619d06e
[wasm] gc.c: scan wasm locals and c stack to mark living objects
kateinoigakukun 144102d
thread.c: put platform specific part in each impl file
kateinoigakukun c14ae65
[wasm] add no thread variant for freestanding environment
kateinoigakukun c48991a
dir.c: ignore ENOTCAPABLE while glob similar to EACCES
kateinoigakukun 1a0a32f
ruby.c: initialize extra optional extensions linked statically
kateinoigakukun 14fe5bf
configure.ac: stop overwriting cc wrapper by darwin-cc everytime
kateinoigakukun 48ee91b
[wasm] add unit test suite for fiber, register scan, sjlj in platform…
kateinoigakukun 0f9faad
[wasm] configure.ac: don't require dup and dup2 only for wasi
kateinoigakukun 8e55f98
[wasm] bootstraptest, basictest: disable backquote literal tests
kateinoigakukun 8875093
[wasm] configure.ac: disable mjit on wasi by default
kateinoigakukun 4b56ef8
[wasm] wasm/README.md: write a brief instruction to cross build
kateinoigakukun 28b492d
[wasm] include/ruby/io.h: define RB_WAITFD_PRI by ourselves for wasi
kateinoigakukun f91b794
[wasm] add ci workflow .github/workflows/wasm.yml
kateinoigakukun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: WebAssembly | ||
| on: | ||
| push: | ||
| paths-ignore: | ||
| - 'doc/**' | ||
| - '**.md' | ||
| - '**.rdoc' | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'doc/**' | ||
| - '**.md' | ||
| - '**.rdoc' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }} | ||
| cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }} | ||
|
|
||
| jobs: | ||
| make: | ||
| strategy: | ||
| matrix: | ||
| entry: | ||
| # # wasmtime can't compile non-optimized Asyncified binary due to locals explosion | ||
| # - { name: O0-debuginfo, optflags: "-O0", debugflags: "-g", wasmoptflags: "-O1" } | ||
| # - { name: O1, optflags: "-O1", debugflags: "" , wasmoptflags: "-O1" } | ||
| - { name: O2, optflags: "-O2", debugflags: "" , wasmoptflags: "-O2" } | ||
| # - { name: O3, optflags: "-O3", debugflags: "" , wasmoptflags: "-O3" } | ||
| # # -O4 is equivalent to -O3 in clang, but it's different in wasm-opt | ||
| # - { name: O4, optflags: "-O3", debugflags: "" , wasmoptflags: "-O4" } | ||
| # - { name: Oz, optflags: "-Oz", debugflags: "" , wasmoptflags: "-Oz" } | ||
| fail-fast: false | ||
| env: | ||
| RUBY_TESTOPTS: '-q --tty=no' | ||
| GITPULLOPTIONS: --no-tags origin ${{github.ref}} | ||
| WASI_SDK_VERSION_MAJOR: 14 | ||
| WASI_SDK_VERSION_MINOR: 0 | ||
| # Use older version, which uses glibc instead of musl, to avoid https://github.com/WebAssembly/binaryen/issues/4401 | ||
| BINARYEN_VERSION: 91 | ||
| WASMTIME_VERSION: v0.33.0 | ||
| runs-on: ubuntu-20.04 | ||
| if: ${{ !startsWith(github.event.head_commit.message, '[DOC]') }} | ||
| steps: | ||
| - run: mkdir build | ||
| working-directory: | ||
| - name: git config | ||
| run: | | ||
| git config --global advice.detachedHead 0 | ||
| git config --global init.defaultBranch garbage | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| path: src | ||
| - name: Install libraries | ||
| run: | | ||
| set -ex | ||
| sudo apt-get update -q || : | ||
| sudo apt-get install --no-install-recommends -q -y ruby bison make autoconf git wget | ||
|
|
||
| wasi_sdk_deb="wasi-sdk_${WASI_SDK_VERSION_MAJOR}.${WASI_SDK_VERSION_MINOR}_amd64.deb" | ||
| wget "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION_MAJOR}/${wasi_sdk_deb}" | ||
| sudo dpkg -i "$wasi_sdk_deb" | ||
| rm -f "$wasi_sdk_deb" | ||
|
|
||
| mkdir build-sdk | ||
| pushd build-sdk | ||
|
|
||
| wasmtime_url="https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-x86_64-linux.tar.xz" | ||
| wget -O - "$wasmtime_url" | tar xJf - | ||
| sudo ln -fs "$PWD/wasmtime-${WASMTIME_VERSION}-x86_64-linux/wasmtime" /usr/local/bin/wasmtime | ||
|
|
||
| binaryen_tarball="binaryen-version_${BINARYEN_VERSION}-x86-linux.tar.gz" | ||
| binaryen_url="https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/${binaryen_tarball}" | ||
| wget -O - "$binaryen_url" | tar xfz - | ||
| sudo ln -fs "$PWD/binaryen-version_${BINARYEN_VERSION}/wasm-opt" /usr/local/bin/wasm-opt | ||
| working-directory: src | ||
| - name: Set ENV | ||
| run: | | ||
| echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV | ||
| echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV | ||
| - run: ./autogen.sh | ||
| working-directory: src | ||
| - name: Run configure | ||
| run: | | ||
| ../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 }}" | ||
|
|
||
| - run: make ruby | ||
| - name: Run basictest | ||
| run: wasmtime run ./../build/miniruby --mapdir /::./ -- basictest/test.rb | ||
| working-directory: src | ||
| - name: Run bootstraptest (no thread) | ||
| run: | | ||
| NO_THREAD_TESTS="$(grep -L Thread -R ./bootstraptest | awk -F/ '{ print $NF }' | uniq | sed -n 's/test_\(.*\).rb/\1/p' | paste -s -d, -)" | ||
| ruby ./bootstraptest/runner.rb --ruby="$(which wasmtime) run $PWD/../build/ruby --mapdir /::./ -- " --verbose "--sets=$NO_THREAD_TESTS" | ||
| working-directory: src | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #include "Context.h" | ||
|
|
||
| void coroutine_trampoline(void * _start, void * _context) | ||
| { | ||
| coroutine_start start = (coroutine_start)_start; | ||
| struct coroutine_context * context = _context; | ||
| rb_wasm_set_stack_pointer(context->current_sp); | ||
|
|
||
| start(context->from, context); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.