mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
SJLJ roc_panic on AArch64
``` $ uname -m arm64 $ cargo test -p test_gen gen_num::abs_min_int_overflow Finished test [unoptimized + debuginfo] target(s) in 0.09s Running src/tests.rs (target/debug/deps/test_gen-b2041868d2cf26f3) running 1 test test gen_num::abs_min_int_overflow - should panic ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 933 filtered out; finished in 0.14s ```
This commit is contained in:
parent
d8d3d7b30c
commit
fa8108e3a8
4 changed files with 55 additions and 107 deletions
|
@ -163,6 +163,27 @@ comptime {
|
|||
@export(utils.panic, .{ .name = "roc_builtins.utils." ++ "panic", .linkage = .Weak });
|
||||
}
|
||||
|
||||
// Utils continued - SJLJ
|
||||
// For tests (in particular test_gen), roc_panic is implemented in terms of
|
||||
// setjmp/longjmp. LLVM is unable to generate code for longjmp on AArch64 (https://github.com/rtfeldman/roc/issues/2965),
|
||||
// so instead we ask Zig to please provide implementations for us, which is does
|
||||
// (seemingly via musl).
|
||||
pub usingnamespace @import("std").c.builtins;
|
||||
pub extern fn setjmp([*c]c_int) c_int;
|
||||
pub extern fn longjmp([*c]c_int, c_int) noreturn;
|
||||
pub extern fn _setjmp([*c]c_int) c_int;
|
||||
pub extern fn _longjmp([*c]c_int, c_int) noreturn;
|
||||
pub extern fn sigsetjmp([*c]c_int, c_int) c_int;
|
||||
pub extern fn siglongjmp([*c]c_int, c_int) noreturn;
|
||||
pub extern fn longjmperror() void;
|
||||
// Zig won't expose the externs (and hence link correctly) unless we force them to be used.
|
||||
pub export fn __roc_force_setjmp(it: [*c]c_int) c_int {
|
||||
return setjmp(it);
|
||||
}
|
||||
pub export fn __roc_force_longjmp(a0: [*c]c_int, a1: c_int) noreturn {
|
||||
longjmp(a0, a1);
|
||||
}
|
||||
|
||||
// Export helpers - Must be run inside a comptime
|
||||
fn exportBuiltinFn(comptime func: anytype, comptime func_name: []const u8) void {
|
||||
@export(func, .{ .name = "roc_builtins." ++ func_name, .linkage = .Strong });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue