diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-07-17 08:39:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-17 08:39:44 +0200 |
| commit | 9d9b5a11e873cc15e3f1b6e506ecf22c8380c87d (patch) | |
| tree | f9fbf35c57d927db32236129c8dbd24550edee7b /lib/std/start.zig | |
| parent | ddc399440dd8bcb814c288e43a30f873bfbaca39 (diff) | |
| parent | 5a4fe39fbbf9668b7fa14da774cb3de1c49604e7 (diff) | |
| download | zig-9d9b5a11e873cc15e3f1b6e506ecf22c8380c87d.tar.gz zig-9d9b5a11e873cc15e3f1b6e506ecf22c8380c87d.zip | |
Merge pull request #20474 from Rexicon226/riscv
more RISC-V backend progress
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 0f169f112d..adcfb9d71b 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -221,7 +221,26 @@ fn riscv_start() callconv(.C) noreturn { } break :ret root.main(); }, - else => @compileError("expected return type of main to be 'void', 'noreturn', 'u8'"), + .ErrorUnion => ret: { + const result = root.main() catch { + const stderr = std.io.getStdErr().writer(); + stderr.writeAll("failed with error\n") catch { + @panic("failed to print when main returned error"); + }; + break :ret 1; + }; + switch (@typeInfo(@TypeOf(result))) { + .Void => break :ret 0, + .Int => |info| { + if (info.bits != 8 or info.signedness == .signed) { + @compileError(bad_main_ret); + } + return result; + }, + else => @compileError(bad_main_ret), + } + }, + else => @compileError(bad_main_ret), }); } |
