zig
zig copied to clipboard
Invalid instruction on Raspberry pi 4B
Zig Version
0.11.0
Steps to Reproduce and Observed Behavior
zig build run this code (extracted from std.http.Client):
const std = @import("std");
pub fn main() void {
var x = std.crypto.hash.sha2.Sha256.init(.{});
const msg: []const u8 = "hello" ** 100;
x.update(msg);
}
Will crash because of illegal instuction sha256h in the feature set crypto is not supported. Note that -Dcpu=cortex_a72-crypto does not make a difference:
pi@raspberrypi ~/t/zig [1]> zig build run
Illegal instruction at address 0x233f8c
/home/pi/zig-linux-aarch64-0.11.0/lib/std/crypto/sha2.zig:223:29: 0x233f8c in round (zig)
asm volatile (
^
/home/pi/zig-linux-aarch64-0.11.0/lib/std/crypto/sha2.zig:129:24: 0x231f6f in update (zig)
d.round(b[off..][0..64]);
^
/home/pi/http-client/zig/src/main.zig:6:13: 0x22ffe7 in main (zig)
x.update(msg);
^
/home/pi/zig-linux-aarch64-0.11.0/lib/std/start.zig:564:22: 0x22f827 in posixCallMainAndExit (zig)
root.main();
^
???:?:?: 0x0 in ??? (???)
run zig: error: the following command terminated unexpectedly:
/home/pi/http-client/zig/zig-out/bin/zig
Build Summary: 3/5 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run zig failure
error: the following build command failed with exit code 1:
/home/pi/http-client/zig/zig-cache/o/c25f175c465c808ad54850e1950017ca/build /home/pi/zig-linux-aarch64-0.11.0/zig /home/pi/http-client/zig /home/pi/http-client/zig/zig-cache /home/pi/.cache/zig -Dcpu=cortex_a72-crypto run
Edit: -Dcpu=cortex_a72-sha2 works.
Expected Behavior
The code above should not crash.