authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-25 20:39:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-26 16:06:05-07:00
logfcfbedc2f06ba5700092a2cb444261133944be01
tree759749fc494189073c1087cba2d05251564d050c
parent231783f2078bca02a8b861f2d750a61db0c4d581

work around riscv64 backend deficiencies


2 files changed, 25 insertions(+), 0 deletions(-)

lib/std/builtin.zig+20
...@@ -833,6 +833,10 @@ pub const PanicCause = union(enum) {...@@ -833,6 +833,10 @@ pub const PanicCause = union(enum) {
833833
834pub fn panicSentinelMismatch(expected: anytype, found: @TypeOf(expected)) noreturn {834pub fn panicSentinelMismatch(expected: anytype, found: @TypeOf(expected)) noreturn {
835 @branchHint(.cold);835 @branchHint(.cold);
836 if (builtin.zig_backend == .stage2_riscv64) {
837 // https://github.com/ziglang/zig/issues/21519
838 @trap();
839 }
836 switch (@typeInfo(@TypeOf(expected))) {840 switch (@typeInfo(@TypeOf(expected))) {
837 .int => |int| switch (int.signedness) {841 .int => |int| switch (int.signedness) {
838 .unsigned => if (int.bits <= @bitSizeOf(usize)) panic(.{ .sentinel_mismatch_usize = .{842 .unsigned => if (int.bits <= @bitSizeOf(usize)) panic(.{ .sentinel_mismatch_usize = .{
...@@ -864,11 +868,19 @@ pub fn panicSentinelMismatch(expected: anytype, found: @TypeOf(expected)) noretu...@@ -864,11 +868,19 @@ pub fn panicSentinelMismatch(expected: anytype, found: @TypeOf(expected)) noretu
864868
865pub fn panicUnwrapError(ert: ?*StackTrace, err: anyerror) noreturn {869pub fn panicUnwrapError(ert: ?*StackTrace, err: anyerror) noreturn {
866 @branchHint(.cold);870 @branchHint(.cold);
871 if (builtin.zig_backend == .stage2_riscv64) {
872 // https://github.com/ziglang/zig/issues/21519
873 @trap();
874 }
867 panic(.{ .unwrap_error = err }, ert, @returnAddress());875 panic(.{ .unwrap_error = err }, ert, @returnAddress());
868}876}
869877
870pub fn panicOutOfBounds(index: usize, len: usize) noreturn {878pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
871 @branchHint(.cold);879 @branchHint(.cold);
880 if (builtin.zig_backend == .stage2_riscv64) {
881 // https://github.com/ziglang/zig/issues/21519
882 @trap();
883 }
872 panic(.{ .index_out_of_bounds = .{884 panic(.{ .index_out_of_bounds = .{
873 .index = index,885 .index = index,
874 .len = len,886 .len = len,
...@@ -877,6 +889,10 @@ pub fn panicOutOfBounds(index: usize, len: usize) noreturn {...@@ -877,6 +889,10 @@ pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
877889
878pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {890pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {
879 @branchHint(.cold);891 @branchHint(.cold);
892 if (builtin.zig_backend == .stage2_riscv64) {
893 // https://github.com/ziglang/zig/issues/21519
894 @trap();
895 }
880 panic(.{ .start_index_greater_than_end = .{896 panic(.{ .start_index_greater_than_end = .{
881 .start = start,897 .start = start,
882 .end = end,898 .end = end,
...@@ -885,6 +901,10 @@ pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {...@@ -885,6 +901,10 @@ pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {
885901
886pub fn panicInactiveUnionField(active: anytype, accessed: @TypeOf(active)) noreturn {902pub fn panicInactiveUnionField(active: anytype, accessed: @TypeOf(active)) noreturn {
887 @branchHint(.cold);903 @branchHint(.cold);
904 if (builtin.zig_backend == .stage2_riscv64) {
905 // https://github.com/ziglang/zig/issues/21519
906 @trap();
907 }
888 panic(.{ .inactive_union_field = .{908 panic(.{ .inactive_union_field = .{
889 .active = @tagName(active),909 .active = @tagName(active),
890 .accessed = @tagName(accessed),910 .accessed = @tagName(accessed),
lib/std/debug.zig+5
...@@ -629,6 +629,11 @@ pub fn fmtPanicCause(buffer: []u8, cause: std.builtin.PanicCause) usize {...@@ -629,6 +629,11 @@ pub fn fmtPanicCause(buffer: []u8, cause: std.builtin.PanicCause) usize {
629 },629 },
630 .sentinel_mismatch_other => i += fmtBuf(buffer[i..], "sentinel mismatch"),630 .sentinel_mismatch_other => i += fmtBuf(buffer[i..], "sentinel mismatch"),
631 .unwrap_error => |err| {631 .unwrap_error => |err| {
632 if (builtin.zig_backend == .stage2_riscv64) {
633 // https://github.com/ziglang/zig/issues/21519
634 i += fmtBuf(buffer[i..], "attempt to unwrap error");
635 return i;
636 }
632 i += fmtBuf(buffer[i..], "attempt to unwrap error: ");637 i += fmtBuf(buffer[i..], "attempt to unwrap error: ");
633 i += fmtBuf(buffer[i..], @errorName(err));638 i += fmtBuf(buffer[i..], @errorName(err));
634 },639 },