Updates all 3rd party dependencies (#802)
wazero has no runtime deps. This updates tools we use as well as dependencies used in comparison with other runtimes. Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
2
.github/workflows/commit.yaml
vendored
2
.github/workflows/commit.yaml
vendored
@@ -192,7 +192,7 @@ jobs:
|
|||||||
# The version here is coupled to internal/integration_test/go.mod, but it
|
# The version here is coupled to internal/integration_test/go.mod, but it
|
||||||
# isn't always the same as sometimes the Go layer has a broken release.
|
# isn't always the same as sometimes the Go layer has a broken release.
|
||||||
env:
|
env:
|
||||||
WASMEDGE_VERSION: 0.9.1
|
WASMEDGE_VERSION: 0.11.0
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/examples.yaml
vendored
4
.github/workflows/examples.yaml
vendored
@@ -16,7 +16,7 @@ on:
|
|||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
EMSDK_VERSION: "3.1.16"
|
EMSDK_VERSION: "3.1.20"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Not all toolchains are idempotent when generating wasm, so we don't check
|
# Not all toolchains are idempotent when generating wasm, so we don't check
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
- name: Install Zig
|
- name: Install Zig
|
||||||
run: | # on laptop, use `brew install --build-from-source zig --HEAD`
|
run: | # on laptop, use `brew install --build-from-source zig --HEAD`
|
||||||
sudo apt install xz-utils
|
sudo apt install xz-utils
|
||||||
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3007+6ba2fb3db.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
|
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3880+e2bb92b2e.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
|
||||||
|
|
||||||
- name: Cache Emscripten
|
- name: Cache Emscripten
|
||||||
id: cache-emsdk
|
id: cache-emsdk
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -5,9 +5,9 @@ space :=
|
|||||||
space +=
|
space +=
|
||||||
|
|
||||||
goimports := golang.org/x/tools/cmd/goimports@v0.1.12
|
goimports := golang.org/x/tools/cmd/goimports@v0.1.12
|
||||||
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
|
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
|
||||||
# sync this with netlify.toml!
|
# sync this with netlify.toml!
|
||||||
hugo := github.com/gohugoio/hugo@v0.101.0
|
hugo := github.com/gohugoio/hugo@v0.102.3
|
||||||
|
|
||||||
# Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion.
|
# Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion.
|
||||||
all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go)
|
all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go)
|
||||||
@@ -44,15 +44,17 @@ build.bench:
|
|||||||
|
|
||||||
.PHONY: test.examples
|
.PHONY: test.examples
|
||||||
test.examples:
|
test.examples:
|
||||||
@go test ./examples/... ./imports/assemblyscript/example/... ./imports/go/example/... ./imports/wasi_snapshot_preview1/example/...
|
@go test ./examples/... ./imports/assemblyscript/example/... ./imports/emscripten/... ./imports/go/example/... ./imports/wasi_snapshot_preview1/example/...
|
||||||
|
|
||||||
.PHONY: build.examples.as
|
.PHONY: build.examples.as
|
||||||
build.examples.as:
|
build.examples.as:
|
||||||
@cd ./imports/assemblyscript/example/testdata && npm install && npm run build
|
@cd ./imports/assemblyscript/example/testdata && npm install && npm run build
|
||||||
|
|
||||||
|
# Use -fstage1 to avoid bugs in the new compiler
|
||||||
|
# https://github.com/ziglang/zig/wiki/Self-Hosted-Compiler-Upgrade-Guide#is-it-time-to-upgrade
|
||||||
.PHONY: build.examples.zig
|
.PHONY: build.examples.zig
|
||||||
build.examples.zig:
|
build.examples.zig:
|
||||||
@cd examples/allocation/zig/testdata/ && zig build -Drelease-small=true && mv zig-out/lib/greet.wasm .
|
@cd examples/allocation/zig/testdata/ && zig build -fstage1 -Drelease-small=true && mv zig-out/lib/greet.wasm .
|
||||||
|
|
||||||
tinygo_sources := examples/basic/testdata/add.go examples/allocation/tinygo/testdata/greet.go imports/wasi_snapshot_preview1/example/testdata/tinygo/cat.go
|
tinygo_sources := examples/basic/testdata/add.go examples/allocation/tinygo/testdata/greet.go imports/wasi_snapshot_preview1/example/testdata/tinygo/cat.go
|
||||||
.PHONY: build.examples.tinygo
|
.PHONY: build.examples.tinygo
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
## Zig allocation example
|
## Zig allocation example
|
||||||
|
|
||||||
This example shows how to pass strings in and out of a Wasm function defined in Zig, built with `zig build`.
|
This example shows how to pass strings in and out of a Wasm function defined in
|
||||||
|
Zig, built with `zig build`.
|
||||||
|
|
||||||
Ex.
|
Ex.
|
||||||
```bash
|
```bash
|
||||||
@@ -9,12 +10,21 @@ wasm >> Hello, wazero!
|
|||||||
go >> Hello, wazero!
|
go >> Hello, wazero!
|
||||||
```
|
```
|
||||||
|
|
||||||
Under the covers, [greet.zig](testdata/greet.zig) does a few things of interest:
|
[greet.zig](testdata/greet.zig) does a few things of interest:
|
||||||
* Uses `@ptrToInt` to change a Zig pointer to a numeric type
|
* Uses `@ptrToInt` to change a Zig pointer to a numeric type
|
||||||
* Uses `[*]u8` as an argument to take a pointer and slices it to build back a string
|
* Uses `[*]u8` as an argument to take a pointer and slices it to build back a
|
||||||
|
string
|
||||||
|
|
||||||
The Zig code exports "malloc" and "free", which we use for that purpose.
|
The Zig code exports "malloc" and "free", which we use for that purpose.
|
||||||
|
|
||||||
Note: This example uses `@panic()` rather than `unreachable` to handle errors
|
### Notes
|
||||||
since `unreachable` emits a call to panic only in `Debug` and `ReleaseSafe` mode.
|
|
||||||
In `ReleaseFast` and `ReleaseSmall` mode, it would lead into undefined behavior.
|
This example uses `@panic()` rather than `unreachable` to handle errors
|
||||||
|
since `unreachable` emits a call to panic only in `Debug` and `ReleaseSafe`
|
||||||
|
mode. In `ReleaseFast` and `ReleaseSmall` mode, it would lead into undefined
|
||||||
|
behavior.
|
||||||
|
|
||||||
|
If building wasm with a pre-release version of Zig 0.10.0, use `-fstage1` to
|
||||||
|
avoid [bugs in the new compiler][1].
|
||||||
|
|
||||||
|
[1]: https://github.com/ziglang/zig/wiki/Self-Hosted-Compiler-Upgrade-Guide#is-it-time-to-upgrade
|
||||||
|
|||||||
BIN
examples/allocation/zig/testdata/greet.wasm
vendored
BIN
examples/allocation/zig/testdata/greet.wasm
vendored
Binary file not shown.
BIN
imports/emscripten/testdata/grow.wasm
vendored
BIN
imports/emscripten/testdata/grow.wasm
vendored
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@ module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmedge
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/second-state/WasmEdge-go v0.9.2
|
github.com/second-state/WasmEdge-go v0.11.0
|
||||||
github.com/tetratelabs/wazero v0.0.0
|
github.com/tetratelabs/wazero v0.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
github.com/second-state/WasmEdge-go v0.9.2 h1:lwbhJY6/uV/hzHOqwKMEASD+GbqN9EmUQzlIR+qoDjM=
|
github.com/second-state/WasmEdge-go v0.11.0 h1:AJ9N2vzXTKQeut5LPxxUDaAKz/VpNk+OXkGSbLvJRkE=
|
||||||
github.com/second-state/WasmEdge-go v0.9.2/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
|
github.com/second-state/WasmEdge-go v0.11.0/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// Note: WasmEdge depends on manual installation of a shared library.
|
// Note: WasmEdge depends on manual installation of a shared library.
|
||||||
// Ex. wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | \
|
// Ex. wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | \
|
||||||
// sudo bash -s -- -p /usr/local -e all -v ${WASMEDGE_VERSION}
|
// sudo bash -s -- -p /usr/local -e none -v ${WASMEDGE_VERSION}
|
||||||
|
|
||||||
package wasmedge
|
package wasmedge
|
||||||
|
|
||||||
@@ -28,16 +28,17 @@ type wasmedgeRuntime struct {
|
|||||||
type wasmedgeModule struct {
|
type wasmedgeModule struct {
|
||||||
store *wasmedge.Store
|
store *wasmedge.Store
|
||||||
vm *wasmedge.VM
|
vm *wasmedge.VM
|
||||||
env *wasmedge.ImportObject
|
env *wasmedge.Module
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *wasmedgeRuntime) Name() string {
|
func (r *wasmedgeRuntime) Name() string {
|
||||||
return "wasmedge"
|
return "wasmedge"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *wasmedgeRuntime) log(_ interface{}, mem *wasmedge.Memory, params []interface{}) ([]interface{}, wasmedge.Result) {
|
func (r *wasmedgeRuntime) log(_ interface{}, callframe *wasmedge.CallingFrame, params []interface{}) ([]interface{}, wasmedge.Result) {
|
||||||
offset := params[0].(int32)
|
offset := params[0].(int32)
|
||||||
byteCount := params[1].(int32)
|
byteCount := params[1].(int32)
|
||||||
|
mem := callframe.GetMemoryByIndex(0)
|
||||||
buf, err := mem.GetData(uint(offset), uint(byteCount))
|
buf, err := mem.GetData(uint(offset), uint(byteCount))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err.Error())
|
fmt.Fprintln(os.Stderr, err.Error())
|
||||||
@@ -66,26 +67,26 @@ func (r *wasmedgeRuntime) Instantiate(_ context.Context, cfg *vs.RuntimeConfig)
|
|||||||
|
|
||||||
// Instantiate WASI, if configured.
|
// Instantiate WASI, if configured.
|
||||||
if cfg.NeedsWASI {
|
if cfg.NeedsWASI {
|
||||||
wasi := m.vm.GetImportObject(wasmedge.WASI)
|
wasi := m.vm.GetImportModule(wasmedge.WASI)
|
||||||
wasi.InitWasi(nil, nil, nil)
|
wasi.InitWasi(nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate the host module, "env", if configured.
|
// Instantiate the host module, "env", if configured.
|
||||||
if cfg.LogFn != nil {
|
if cfg.LogFn != nil {
|
||||||
r.logFn = cfg.LogFn
|
r.logFn = cfg.LogFn
|
||||||
m.env = wasmedge.NewImportObject("env")
|
m.env = wasmedge.NewModule("env")
|
||||||
logType := wasmedge.NewFunctionType([]wasmedge.ValType{wasmedge.ValType_I32, wasmedge.ValType_I32}, nil)
|
logType := wasmedge.NewFunctionType([]wasmedge.ValType{wasmedge.ValType_I32, wasmedge.ValType_I32}, nil)
|
||||||
m.env.AddFunction("log", wasmedge.NewFunction(logType, r.log, nil, 0))
|
m.env.AddFunction("log", wasmedge.NewFunction(logType, r.log, nil, 0))
|
||||||
if err = m.vm.RegisterImport(m.env); err != nil {
|
if err = m.vm.RegisterModule(m.env); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else if cfg.EnvFReturnValue != 0 {
|
} else if cfg.EnvFReturnValue != 0 {
|
||||||
m.env = wasmedge.NewImportObject("env")
|
m.env = wasmedge.NewModule("env")
|
||||||
fType := wasmedge.NewFunctionType([]wasmedge.ValType{wasmedge.ValType_I64}, []wasmedge.ValType{wasmedge.ValType_I64})
|
fType := wasmedge.NewFunctionType([]wasmedge.ValType{wasmedge.ValType_I64}, []wasmedge.ValType{wasmedge.ValType_I64})
|
||||||
m.env.AddFunction("f", wasmedge.NewFunction(fType, func(data interface{}, mem *wasmedge.Memory, params []interface{}) ([]interface{}, wasmedge.Result) {
|
m.env.AddFunction("f", wasmedge.NewFunction(fType, func(interface{}, *wasmedge.CallingFrame, []interface{}) ([]interface{}, wasmedge.Result) {
|
||||||
return []interface{}{int64(cfg.EnvFReturnValue)}, wasmedge.Result_Success
|
return []interface{}{int64(cfg.EnvFReturnValue)}, wasmedge.Result_Success
|
||||||
}, nil, 0))
|
}, nil, 0))
|
||||||
if err = m.vm.RegisterImport(m.env); err != nil {
|
if err = m.vm.RegisterModule(m.env); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,8 @@ func (r *wasmedgeRuntime) Close(_ context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *wasmedgeModule) Memory() []byte {
|
func (m *wasmedgeModule) Memory() []byte {
|
||||||
mem := m.store.FindMemory("memory")
|
mod := m.vm.GetActiveModule()
|
||||||
|
mem := mod.FindMemory("memory")
|
||||||
d, err := mem.GetData(0, mem.GetPageSize()*65536)
|
d, err := mem.GetData(0, mem.GetPageSize()*65536)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -171,7 +173,8 @@ func (m *wasmedgeModule) CallI64_I64(_ context.Context, funcName string, param u
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *wasmedgeModule) WriteMemory(_ context.Context, offset uint32, bytes []byte) error {
|
func (m *wasmedgeModule) WriteMemory(_ context.Context, offset uint32, bytes []byte) error {
|
||||||
mem := m.store.FindMemory("memory")
|
mod := m.vm.GetActiveModule()
|
||||||
|
mem := mod.FindMemory("memory")
|
||||||
if unsafeSlice, err := mem.GetData(uint(offset), uint(len(bytes))); err != nil {
|
if unsafeSlice, err := mem.GetData(uint(offset), uint(len(bytes))); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmtime
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytecodealliance/wasmtime-go v0.39.0
|
github.com/bytecodealliance/wasmtime-go v0.40.0
|
||||||
github.com/tetratelabs/wazero v0.0.0
|
github.com/tetratelabs/wazero v0.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
github.com/bytecodealliance/wasmtime-go v0.39.0 h1:35AXy5+py5ZXRSpfoxqh+dWJ7nJnIrW1avjDfaJinxU=
|
github.com/bytecodealliance/wasmtime-go v0.40.0 h1:7cGLQEctJf09JWBl3Ai0eMl1PTrXVAjkAb27+KHfIq0=
|
||||||
github.com/bytecodealliance/wasmtime-go v0.39.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI=
|
github.com/bytecodealliance/wasmtime-go v0.40.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI=
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
publish = "public"
|
publish = "public"
|
||||||
|
|
||||||
[build.environment]
|
[build.environment]
|
||||||
HUGO_VERSION = "0.101.0"
|
HUGO_VERSION = "0.102.3"
|
||||||
|
|
||||||
[context.production]
|
[context.production]
|
||||||
command = "git submodule update --init && hugo --gc --minify"
|
command = "git submodule update --init && hugo --gc --minify"
|
||||||
|
|||||||
Reference in New Issue
Block a user