Files
zig/test/incremental/change_panic_handler
T
Pavel Verigo ad7a028228 stage2-wasm: pass incremental tests
This PR enables all incremental tests under the `test/incremental` directory, except one: `change_exports`, which is currently ignored as it requires a non-trivial amount of work on the linker, since we do not currently support exporting data symbols.

To enable the other tests, the following fixes were needed:

1. `src/link/Wasm.zig`: instead of chasing function type through Nav, get it directly.
2. `src/target.zig`: `.panic_fn` appears to work fine with the wasm backend.
3. `src/codegen/wasm/CodeGen.zig`: there was a liveness related bug that caused some `ArenaAllocator` code to crash the backend.

More info on (3), the liveness and local reuse code in the backend for years in unfinished state. For example there is currently no branch merging and reuse happens only when inst die in same block level. I initially considered doing a large refactor to implement everything correctly, but aborted due to its sheer size and currently! no clear idea about how to do this efficiently.

Instead, I fixed the bug with minimal changes and removed useless code, keeping the old solution otherwise intact.
2026-04-04 15:21:35 +02:00

60 lines
1.8 KiB
Plaintext

#target=x86_64-linux-selfhosted
#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
pub const panic = std.debug.FullPanic(myPanic);
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="panic message: integer overflow\n"
#update=change the panic handler body
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
pub const panic = std.debug.FullPanic(myPanic);
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="new panic message: integer overflow\n"
#update=change the panic handler function value
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
pub const panic = std.debug.FullPanic(myPanicNew);
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="third panic message: integer overflow\n"