zig: bumps to latest (#1080)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-01-30 16:30:52 +02:00
committed by GitHub
parent d04199d1c3
commit f9db80624d
12 changed files with 48 additions and 46 deletions

View File

@@ -18,7 +18,7 @@ on:
env:
EMSDK_VERSION: "3.1.24"
TINYGO_VERSION: "0.26.0"
ZIG_VERSION: "0.11.0-dev.725+9bcfe55b5"
ZIG_VERSION: "0.11.0-dev.1499+23b7d2889"
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

View File

@@ -19,7 +19,7 @@ defaults:
env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.19" # 1.xx == latest patch of 1.xx
ZIG_BUILD_VERSION: "0.11.0-dev.725+9bcfe55b5"
ZIG_VERSION: "0.11.0-dev.1499+23b7d2889"
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
@@ -35,12 +35,12 @@ jobs:
- name: Install Zig build
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c -q https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_BUILD_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c -q https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: Download Zig source code
run: |
sudo apt install xz-utils
wget -c -q https://ziglang.org/builds/zig-${{ env.ZIG_BUILD_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C .
wget -c -q https://ziglang.org/builds/zig-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C .
- name: Cache Zig test build artifacts
uses: actions/cache@v3
@@ -48,7 +48,7 @@ jobs:
path: |
zig-cache
zig-out
key: integration-test-zig-${{ env.ZIG_BUILD_VERSION }}
key: integration-test-zig-${{ env.ZIG_VERSION }}
- name: Build Stdlib test binary
# TODO: maybe uploading the built binary to GHA artifact would be helpful to reproduce the failure locally.
@@ -77,7 +77,9 @@ jobs:
tinygo:
name: TinyGo
# TODO: make it matrix over OSes once the next release is published.
runs-on: ubuntu-20.04
env:
# Until https://github.com/tinygo-org/tinygo/pull/3399 is released in 0.27.0,
# use the artifact from the GitHub Actions on the TinyGo repository.
@@ -92,7 +94,7 @@ jobs:
path:
~/.cache/go-build
~/.cache/tinygo
key: integration-test-tinygo-${{ env.TINYGO_RUN_ID }}-${{ env.GO_VERSION }}
key: integration-test-tinygo-${{ env.TINYGO_RUN_ID }}-${{ env.GO_VERSION }}-${{ matrix.os }}
- uses: actions/setup-go@v3
with:
@@ -125,7 +127,7 @@ jobs:
- name: Run all standard library tests
# Running all tests is pretty slow (~8min), so only do it on the main branch.
if: ${{ github.event_name == 'push' }}
# The list of packages are derived from:
# The following list of packages is derived from:
# https://github.com/tinygo-org/tinygo/blob/v0.26.0/Makefile#L271-L319
# Note: index/suffixarray is extremely slow, so skip it.
run: |

View File

@@ -71,17 +71,15 @@ wasm stack trace:
bin: dwarftestdata.ZigWasm,
exp: `module[] function[_start] failed: wasm error: unreachable
wasm stack trace:
.os.abort()
0x1b3: /os.zig:552:9
.builtin.default_panic(i32,i32,i32,i32)
0x86: /builtin.zig:787:25
0x37: /builtin.zig:858:17
.main.main() i32
0x25: main.zig:10:5 (inlined)
main.zig:6:5 (inlined)
main.zig:2:5
0x60: /main.zig:10:5 (inlined)
/main.zig:6:5 (inlined)
/main.zig:2:5
._start()
0x1c6: /start.zig:614:37 (inlined)
/start.zig:240:42`,
0x6a: /start.zig:616:37 (inlined)
/start.zig:232:5`,
},
{
name: "rust",
@@ -189,7 +187,7 @@ wasm stack trace:
}
sanitizedTraces := strings.Join(sanitizedLines, "\n")
require.Equal(t, sanitizedTraces, lang.exp)
require.Equal(t, lang.exp, sanitizedTraces)
})
}
})

View File

@@ -7,7 +7,8 @@ pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const lib = b.addSharedLibrary("greet", "greet.zig", .unversioned);
lib.setTarget(CrossTarget{ .cpu_arch = .wasm32, .os_tag = .freestanding });
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
lib.rdynamic = true;
lib.setBuildMode(mode);
lib.install();
}

View File

@@ -17,10 +17,10 @@ fn main() {
},
"stat" => {
main_stat();
},
}
_ => {
writeln!(io::stderr(), "unknown command: {}", args[1]).unwrap();
exit(1);
writeln!(io::stderr(), "unknown command: {}", args[1]).unwrap();
exit(1);
}
}
}
@@ -28,10 +28,10 @@ fn main() {
fn main_ls(dir_name: &String) {
match fs::read_dir(dir_name) {
Ok(paths) => {
for path in paths {
println!("{}", path.unwrap().path().display());
for ent in paths.into_iter() {
println!("{}", ent.unwrap().path().display());
}
},
}
Err(e) => {
if let Some(error_code) = e.raw_os_error() {
if error_code == ENOTDIR {
@@ -49,7 +49,7 @@ fn main_ls(dir_name: &String) {
extern crate libc;
fn main_stat() {
unsafe{
unsafe {
println!("stdin isatty: {}", libc::isatty(0) != 0);
println!("stdout isatty: {}", libc::isatty(1) != 0);
println!("stderr isatty: {}", libc::isatty(2) != 0);

View File

@@ -11,7 +11,8 @@ pub fn main() !void {
defer std.process.argsFree(allocator, args);
if (std.mem.eql(u8, args[1], "ls")) {
var dir = std.fs.openIterableDir(args[2], .{}) catch |err| switch (err) {
// TODO: This only looks at fd 3. See #1077
var dir = std.fs.cwd().openIterableDir(args[2], .{}) catch |err| switch (err) {
error.NotDir => {
try stdout.print("ENOTDIR\n", .{});
return;

View File

@@ -7,7 +7,10 @@ pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("main", "main.zig");
exe.setTarget(CrossTarget{ .cpu_arch = .wasm32, .os_tag = .wasi });
// 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);
exe.install();
}

View File

@@ -1,9 +1,9 @@
pub fn main() !void {
@call(.{ .modifier = .always_inline }, inlined_a, .{});
@call(.always_inline, inlined_a, .{});
}
fn inlined_a() void {
@call(.{ .modifier = .always_inline }, inlined_b, .{});
@call(.always_inline, inlined_b, .{});
}
fn inlined_b() void {

View File

@@ -74,7 +74,7 @@ func TestDWARFLines_Line_Zig(t *testing.T) {
// codeSecStart is the beginning of the code section in the Wasm binary.
// If dwarftestdata.ZigWasm has been changed, we need to inspect by `wasm-tools objdump`.
const codeSecStart = 0x108
const codeSecStart = 0x46
// These cases are crafted by matching the stack trace result from wasmtime. To verify, run:
//
@@ -85,32 +85,29 @@ func TestDWARFLines_Line_Zig(t *testing.T) {
// Caused by:
// 0: failed to invoke command default
// 1: error while executing at wasm backtrace:
// 0: 0x2bb - os.abort
// at /Users/mathetake/zig-macos-aarch64-0.11.0-dev.618+096d3efae/lib/std/os.zig:552:9
// 1: 0x18e - builtin.default_panic
// at /Users/mathetake/zig-macos-aarch64-0.11.0-dev.618+096d3efae/lib/std/builtin.zig:787:25
// 2: 0x12d - main.inlined_b
// at ././main.zig:10:5 - main.inlined_a
// at ././main.zig:6:5 - main.main
// at ././main.zig:2:5
// 3: 0x2ce - start.callMain
// at /Users/mathetake/zig-macos-aarch64-0.11.0-dev.618+096d3efae/lib/std/start.zig:614:37 - _start
// at /Users/mathetake/zig-macos-aarch64-0.11.0-dev.618+096d3efae/lib/std/start.zig:240:42
// 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
// 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:232:5
// 2: wasm trap: wasm `unreachable` instruction executed
for _, tc := range []struct {
offset uint64
exp []string
}{
{offset: 0x2bb - codeSecStart, exp: []string{"lib/std/os.zig:552:9"}},
{offset: 0x18e - codeSecStart, exp: []string{"lib/std/builtin.zig:787:25"}},
{offset: 0x12d - codeSecStart, exp: []string{
{offset: 0x7d - codeSecStart, exp: []string{"lib/std/builtin.zig:858:17"}},
{offset: 0xa6 - codeSecStart, exp: []string{
"main.zig:10:5 (inlined)",
"main.zig:6:5 (inlined)",
"main.zig:2:5",
}},
{offset: 0x2ce - codeSecStart, exp: []string{
"lib/std/start.zig:614:37 (inlined)",
"lib/std/start.zig:240:42",
{offset: 0xb0 - codeSecStart, exp: []string{
"lib/std/start.zig:616:37 (inlined)",
"lib/std/start.zig:232:5",
}},
} {
tc := tc