Skip to content

Commit

Permalink
Merge pull request #19 from swiftwasm/update-toolchain
Browse files Browse the repository at this point in the history
Update toolchain
  • Loading branch information
kateinoigakukun authored Apr 6, 2022
2 parents 042b7b0 + 1dd22ce commit 1f63075
Show file tree
Hide file tree
Showing 6 changed files with 4,831 additions and 53 deletions.
46 changes: 38 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ on: [push]
jobs:
build-fixtures:
runs-on: macos-latest
strategy:
matrix:
toolchain-version:
- swift-wasm-5.3.0-RELEASE
- swift-wasm-5.4.0-RELEASE
- swift-wasm-5.5.0-RELEASE
- swift-wasm-5.6.0-RELEASE

steps:
- uses: actions/checkout@v2
- name: Install SwiftWasm toolchain
run: |
VERSION=swift-wasm-5.3.0-RELEASE
VERSION=${{ matrix.toolchain-version }}
TOOLCHAIN_URL="https://github.com/swiftwasm/swift/releases/download/$VERSION/$VERSION-macos_x86_64.pkg"
wget $TOOLCHAIN_URL
installer -target CurrentUserHomeDirectory -pkg $VERSION-macos_x86_64.pkg
Expand All @@ -21,17 +29,24 @@ jobs:
working-directory: Fixtures
- uses: actions/upload-artifact@v2
with:
name: test-fixtures
name: test-fixtures-${{ matrix.toolchain-version }}
path: Fixtures/build

ubuntu-unit-tests:
runs-on: ubuntu-latest
needs: build-fixtures
strategy:
matrix:
toolchain-version:
- swift-wasm-5.3.0-RELEASE
- swift-wasm-5.4.0-RELEASE
- swift-wasm-5.5.0-RELEASE
- swift-wasm-5.6.0-RELEASE
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: test-fixtures
name: test-fixtures-${{ matrix.toolchain-version }}
path: Fixtures/build
- name: Install dependencies
run: |
Expand All @@ -44,30 +59,45 @@ jobs:
macos-unit-tests:
runs-on: macos-latest
needs: build-fixtures
strategy:
matrix:
toolchain-version:
- swift-wasm-5.3.0-RELEASE
- swift-wasm-5.4.0-RELEASE
- swift-wasm-5.5.0-RELEASE
- swift-wasm-5.6.0-RELEASE
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: test-fixtures
name: test-fixtures-${{ matrix.toolchain-version }}
path: Fixtures/build
- name: Select Xcode toolchain
run: sudo xcode-select -s /Applications/Xcode_12.2.0.app/Contents/Developer/
run: sudo xcode-select -s /Applications/Xcode_13.2.1.app/Contents/Developer/
- name: Install dependencies
run: brew install wabt
- name: Run unit tests
run: swift test

integration-tests:
runs-on: macos-latest
runs-on: macos-12
needs: build-fixtures
strategy:
fail-fast: false
matrix:
toolchain-version:
- swift-wasm-5.3.0-RELEASE
- swift-wasm-5.4.0-RELEASE
- swift-wasm-5.5.0-RELEASE
- swift-wasm-5.6.0-RELEASE
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: test-fixtures
name: test-fixtures-${{ matrix.toolchain-version }}
path: Fixtures/build
- name: Select Xcode toolchain
run: sudo xcode-select -s /Applications/Xcode_12.2.0.app/Contents/Developer/
run: sudo xcode-select -s /Applications/Xcode_13.2.1.app/Contents/Developer/
- name: Install dependencies
run: |
sudo pip3 install selenium
Expand Down
29 changes: 27 additions & 2 deletions Fixtures/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import { WASI } from "@wasmer/wasi";
import { WasmFs } from "@wasmer/wasmfs";

const wrapWASI = (wasiObject) => {
for (const key in wasiObject.wasiImport) {
const func = wasiObject.wasiImport[key]
wasiObject.wasiImport[key] = function() {
console.log(`[tracing] WASI.${key}`);
return Reflect.apply(func, undefined, arguments);
}
}
// PATCH: @wasmer-js/[email protected] forgets to call `refreshMemory` in `clock_res_get`,
// which writes its result to memory view. Without the refresh the memory view,
// it accesses a detached array buffer if the memory is grown by malloc.
// But they wasmer team discarded the 0.x codebase at all and replaced it with
// a new implementation written in Rust. The new version 1.x is really unstable
// and not production-ready as far as katei investigated in Apr 2022.
// So override the broken implementation of `clock_res_get` here instead of
// fixing the wasi polyfill.
// Reference: https://github.com/wasmerio/wasmer-js/blob/55fa8c17c56348c312a8bd23c69054b1aa633891/packages/wasi/src/index.ts#L557
const original_clock_res_get = wasiObject.wasiImport["clock_res_get"];
wasiObject.wasiImport["clock_res_get"] = (clockId, resolution) => {
wasiObject.refreshMemory();
return original_clock_res_get(clockId, resolution)
};
return wasiObject.wasiImport;
}

window.I64ImportTransformerTests = async (bytes) => {
const wasmFs = new WasmFs();
const wasi = new WASI({
Expand All @@ -12,7 +37,7 @@ window.I64ImportTransformerTests = async (bytes) => {
});

const importObject = {
wasi_snapshot_preview1: wasi.wasiImport,
wasi_snapshot_preview1: wrapWASI(wasi),
};

const module = await WebAssembly.compile(bytes);
Expand All @@ -31,7 +56,7 @@ window.StackOverflowSanitizerTests = async (bytes) => {
});

const importObject = {
wasi_snapshot_preview1: wasi.wasiImport,
wasi_snapshot_preview1: wrapWASI(wasi),
__stack_sanitizer: {
report_stack_overflow: () => {
throw new Error("CATCH_STACK_OVERFLOW");
Expand Down
Loading

0 comments on commit 1f63075

Please sign in to comment.