Skip to content

Commit

Permalink
examples: updates to the latest SDKs (#1169)
Browse files Browse the repository at this point in the history
This updates our examples to the latest SDKs as particularly this can
help reveal issues around fan-out stats.

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Feb 27, 2023
1 parent 5eab1a7 commit 75aa6b2
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 53 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'netlify.toml'

env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.19" # 1.xx == latest patch of 1.xx
GO_VERSION: "1.20" # 1.xx == latest patch of 1.xx

defaults:
run: # use bash for all operating systems unless overridden
Expand All @@ -28,7 +28,7 @@ concurrency:
jobs:
check:
name: Pre-commit check
# wabt requires a later version of libc than what's installed on ubuntu-20.04.
# wabt requires a later version of libc than what's installed on ubuntu-22.04.
runs-on: ubuntu-latest
steps:
- name: Install latest wast2json
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
os: [ubuntu-20.04, macos-12, windows-2022]
os: [ubuntu-20.04, macos-12, windows-2022] # TODO: update to 22.04 See #1171
go-version:
- "1.20" # Current Go version
- "1.18" # Floor Go version of wazero (current - 2)
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:

test_scratch:
name: ${{ matrix.arch }}, Linux (scratch), Go-${{ matrix.go-version }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:

bench:
name: Benchmark
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
# Unlike the other CGO libraries, WasmEdge requires offline installation.
Expand All @@ -169,7 +169,7 @@ jobs:
# run full-length fuzzing while trying to find low-hanging frontend bugs.
fuzz:
name: Minimal Fuzzing
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ on:
- 'Makefile'

env:
EMSDK_VERSION: "3.1.24"
EMSDK_VERSION: "3.1.32"
TINYGO_VERSION: "0.27.0"
ZIG_VERSION: "0.11.0-dev.1499+23b7d2889"
ZIG_VERSION: "0.11.0-dev.1797+d3c9bfada"

concurrency:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
Expand All @@ -30,11 +30,11 @@ jobs:
# in %.wasm as a part of this job.
examples:
name: Build examples
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix: # Use versions consistent with TinyGo.
go-version:
- "1.19" # Current Go version
- "1.20" # Current Go version
- "1.18" # Floor Go version of latest TinyGo

steps:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defaults:
shell: bash

env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.19" # 1.xx == latest patch of 1.xx
GO_VERSION: "1.20" # 1.xx == latest patch of 1.xx
ZIG_VERSION: "0.11.0-dev.1797+d3c9bfada"
TINYGO_VERSION: "0.27.0"

Expand All @@ -32,7 +32,7 @@ jobs:
# This saves time as we rarely update the zig version.
build_zig_test_binary:
name: Build Zig test binary
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
ZIG_INSTALL: ~/zig-install
ZIG_SOURCE: ~/zig-source
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
os: [ubuntu-22.04, macos-12, windows-2022]

steps:
- name: Checkout wazero
Expand All @@ -112,11 +112,12 @@ jobs:
# adding filter argument to the "Build Stdlib test binary" step.
# e.g. --test-filter "Dir.Iterator but dir is deleted during iteration"
- name: Run the test binary with wazero CLI
timeout-minutes: 10 # Prevent crashes from timing out
run: go run ./cmd/wazero run -mount=:/ test.wasm

build_tinygo_test_binary:
name: Build TinyGo test binary
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
BINARY_OUT: ~/out

Expand Down Expand Up @@ -219,7 +220,7 @@ jobs:
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
os: [ubuntu-22.04, macos-12, windows-2022]

steps:
- name: Checkout wazero
Expand Down Expand Up @@ -254,7 +255,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
os: [ubuntu-22.04, macos-12, windows-2022]

steps:
- uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spectest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ concurrency:
jobs:
test_amd64:
name: ${{ matrix.spec-version }} - linux/amd64, Go-${{ matrix.go-version }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
Expand All @@ -48,7 +48,7 @@ jobs:

test_scratch:
name: ${{ matrix.spec-version }} / ${{ matrix.arch }}, Go-${{ matrix.go-version }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ build.examples.as:
@cd ./imports/assemblyscript/example/testdata && npm install && npm run build

%.wasm: %.zig
@(cd $(@D); zig build -Drelease-small=true)
@(cd $(@D); zig build -Doptimize=ReleaseSmall)
@mv $(@D)/zig-out/*/$(@F) $(@D)

.PHONY: build.examples.zig
Expand Down
4 changes: 2 additions & 2 deletions dwarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func TestWithDebugInfo(t *testing.T) {
exp: `module[] function[_start] failed: wasm error: unreachable
wasm stack trace:
.builtin.default_panic(i32,i32,i32,i32)
0x37: /builtin.zig:858:17
0x37: /builtin.zig:861:17
.main.main() i32
0x60: /main.zig:10:5 (inlined)
/main.zig:6:5 (inlined)
/main.zig:2:5
._start()
0x6a: /start.zig:616:37 (inlined)
0x6a: /start.zig:617:37 (inlined)
/start.zig:232:5`,
},
{
Expand Down
Binary file modified examples/allocation/rust/testdata/greet.wasm
Binary file not shown.
Binary file modified examples/allocation/tinygo/testdata/greet.wasm
Binary file not shown.
14 changes: 8 additions & 6 deletions examples/allocation/zig/testdata/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const std = @import("std");
const CrossTarget = std.zig.CrossTarget;

pub fn build(b: *std.build.Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const target = .{.cpu_arch = .wasm32, .os_tag = .freestanding};
const optimize = b.standardOptimizeOption(.{});

const lib = b.addSharedLibrary("greet", "greet.zig", .unversioned);
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
const lib = b.addSharedLibrary(.{
.name = "greet",
.root_source_file = .{ .path = "greet.zig" },
.target = target,
.optimize = optimize,
});
lib.rdynamic = true;
lib.setBuildMode(mode);
lib.install();
}
Binary file modified examples/cli/testdata/cli.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion imports/assemblyscript/example/testdata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"build": "asc index.ts --debug -b none -o index.wasm"
},
"devDependencies": {
"assemblyscript": "^0.26.7"
"assemblyscript": "^0.27.0"
}
}
Binary file modified imports/emscripten/testdata/grow.wasm
Binary file not shown.
Binary file not shown.
Binary file modified imports/wasi_snapshot_preview1/example/testdata/tinygo/cat.wasm
Binary file not shown.
Binary file modified imports/wasi_snapshot_preview1/example/testdata/zig-cc/cat.wasm
Binary file not shown.
15 changes: 9 additions & 6 deletions imports/wasi_snapshot_preview1/example/testdata/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ const std = @import("std");
const CrossTarget = std.zig.CrossTarget;

pub fn build(b: *std.build.Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const target = .{.cpu_arch = .wasm32, .os_tag = .wasi};
const optimize = b.standardOptimizeOption(.{});

const exe = b.addExecutable(.{
.name = "cat",
.root_source_file = .{ .path = "cat.zig" },
.target = target,
.optimize = optimize,
});

const exe = b.addExecutable("cat", "cat.zig");
exe.setTarget(CrossTarget{ .cpu_arch = .wasm32, .os_tag = .wasi });
exe.setBuildMode(mode);
exe.install();
}
Binary file modified imports/wasi_snapshot_preview1/example/testdata/zig/cat.wasm
Binary file not shown.
Binary file modified imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.wasm
Binary file not shown.
Binary file modified imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.wasm
Binary file not shown.
15 changes: 9 additions & 6 deletions imports/wasi_snapshot_preview1/testdata/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ const std = @import("std");
const CrossTarget = std.zig.CrossTarget;

pub fn build(b: *std.build.Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const target = .{.cpu_arch = .wasm32, .os_tag = .wasi};
const optimize = b.standardOptimizeOption(.{});

const exe = b.addExecutable(.{
.name = "wasi",
.root_source_file = .{ .path = "wasi.zig" },
.target = target,
.optimize = optimize,
});

const exe = b.addExecutable("wasi", "wasi.zig");
exe.setTarget(CrossTarget{ .cpu_arch = .wasm32, .os_tag = .wasi });
exe.setBuildMode(mode);
exe.install();
}
4 changes: 2 additions & 2 deletions imports/wasi_snapshot_preview1/testdata/zig/wasi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn main() !void {
defer std.process.argsFree(allocator, args);

if (std.mem.eql(u8, args[1], "ls")) {
// TODO: This only looks at fd 3. See #1077
// TODO: This only looks at fd 3. See #14678
var dir = std.fs.cwd().openIterableDir(args[2], .{}) catch |err| switch (err) {
error.NotDir => {
try stdout.print("ENOTDIR\n", .{});
Expand All @@ -36,7 +36,7 @@ pub fn main() !void {
var wasi_preopens = try preopensAlloc(allocator);
// fs.wasi.Preopens does not have a free function

for (wasi_preopens.names) |preopen, i| {
for (wasi_preopens.names, 0..) |preopen, i| {
try stdout.print("{}: {s}\n", .{ i, preopen });
}
}
Expand Down
17 changes: 10 additions & 7 deletions internal/testing/dwarftestdata/testdata/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ const std = @import("std");
const CrossTarget = std.zig.CrossTarget;

pub fn build(b: *std.build.Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();

const exe = b.addExecutable("main", "main.zig");
// Don't use wasi because this calls os_exit on panic. An ExitError isn't
// wrapped due to logic in FromRecovered.
// TODO: Find another way to avoid re-wrapping!
exe.setTarget(CrossTarget{ .cpu_arch = .wasm32, .os_tag = .freestanding });
exe.setBuildMode(mode);
const target = .{.cpu_arch = .wasm32, .os_tag = .freestanding};
const optimize = b.standardOptimizeOption(.{});

const exe = b.addExecutable(.{
.name = "main",
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});

exe.install();
}
Binary file modified internal/testing/dwarftestdata/testdata/zig/main.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions internal/wasmdebug/dwarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ func TestDWARFLines_Line_Zig(t *testing.T) {
// 0: failed to invoke command default
// 1: error while executing at wasm backtrace:
// 0: 0x7d - builtin.default_panic
// at /Users/adrian/Downloads/zig-macos-x86_64-0.11.0-dev.1499+23b7d2889/lib/std/builtin.zig:858:17
// at /Users/adrian/Downloads/zig-macos-x86_64-0.11.0-dev.1499+23b7d2889/lib/std/builtin.zig:861:17
// 1: 0xa6 - main.inlined_b
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:10:5 - main.inlined_a
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:6:5 - main.main
// at /Users/adrian/oss/wazero/internal/testing/dwarftestdata/testdata/zig/main.zig:2:5
// 2: 0xb0 - start.callMain
// at /Users/adrian/Downloads/zig-macos-x86_64-0.11.0-dev.1499+23b7d2889/lib/std/start.zig:616:37 - _start
// at /Users/adrian/Downloads/zig-macos-x86_64-0.11.0-dev.1499+23b7d2889/lib/std/start.zig:617:37 - _start
// at /Users/adrian/Downloads/zig-macos-x86_64-0.11.0-dev.1499+23b7d2889/lib/std/start.zig:232:5
// 2: wasm trap: wasm `unreachable` instruction executed
for _, tc := range []struct {
offset uint64
exp []string
}{
{offset: 0x7d - codeSecStart, exp: []string{"lib/std/builtin.zig:858:17"}},
{offset: 0x7d - codeSecStart, exp: []string{"lib/std/builtin.zig:861:17"}},
{offset: 0xa6 - codeSecStart, exp: []string{
"main.zig:10:5 (inlined)",
"main.zig:6:5 (inlined)",
"main.zig:2:5",
}},
{offset: 0xb0 - codeSecStart, exp: []string{
"lib/std/start.zig:616:37 (inlined)",
"lib/std/start.zig:617:37 (inlined)",
"lib/std/start.zig:232:5",
}},
} {
Expand Down

0 comments on commit 75aa6b2

Please sign in to comment.