diff options
| author | David Rubin <daviru007@icloud.com> | 2024-04-16 22:44:55 -0700 |
|---|---|---|
| committer | David Rubin <daviru007@icloud.com> | 2024-05-11 02:17:24 -0700 |
| commit | ffb63a05a3327e64bcf8ec7fd05c6aab8d304480 (patch) | |
| tree | 5284c825f8126f35d756599f524a2f612620ddd4 /lib | |
| parent | 2fd83d8c0a8dd28c2474b26ead8cb24d6bde0901 (diff) | |
| download | zig-ffb63a05a3327e64bcf8ec7fd05c6aab8d304480.tar.gz zig-ffb63a05a3327e64bcf8ec7fd05c6aab8d304480.zip | |
riscv: finally fix bug + `airAggregateInit`
i just hadn't realized that I placed the `riscv_start` branch in the non-simplified
starts
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/start.zig | 26 | ||||
| -rw-r--r-- | lib/std/testing.zig | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 5fad443956..ff97e3c8ae 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -22,7 +22,8 @@ pub const simplified_logic = builtin.zig_backend == .stage2_arm or builtin.zig_backend == .stage2_sparc64 or builtin.cpu.arch == .spirv32 or - builtin.cpu.arch == .spirv64; + builtin.cpu.arch == .spirv64 or + builtin.zig_backend == .stage2_riscv64; comptime { // No matter what, we import the root file, so that any export, test, comptime @@ -42,6 +43,10 @@ comptime { } else if (builtin.os.tag == .opencl) { if (@hasDecl(root, "main")) @export(spirvMain2, .{ .name = "main" }); + } else if (native_arch.isRISCV()) { + if (!@hasDecl(root, "_start")) { + @export(riscv_start, .{ .name = "_start" }); + } } else { if (!@hasDecl(root, "_start")) { @export(_start2, .{ .name = "_start" }); @@ -60,10 +65,6 @@ comptime { } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { @export(main, .{ .name = "main" }); } - } else if (native_arch.isRISCV()) { - if (!@hasDecl(root, "_start")) { - @export(riscv_start, .{ .name = "_start" }); - } } else if (native_os == .windows) { if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) @@ -208,7 +209,20 @@ fn wasi_start() callconv(.C) void { } fn riscv_start() callconv(.C) noreturn { - std.process.exit(@call(.always_inline, callMain, .{})); + std.process.exit(switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) { + .NoReturn => root.main(), + .Void => ret: { + root.main(); + break :ret 0; + }, + .Int => |info| ret: { + if (info.bits != 8 or info.signedness == .signed) { + @compileError(bad_main_ret); + } + break :ret root.main(); + }, + else => @compileError("expected return type of main to be 'void', 'noreturn', 'u8'"), + }); } fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize { diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 662351f153..4e895ef3a7 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -22,7 +22,7 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); pub var log_level = std.log.Level.warn; // Disable printing in tests for simple backends. -pub const backend_can_print = builtin.zig_backend != .stage2_spirv64 and builtin.zig_backend != .stage2_riscv64; +pub const backend_can_print = !(builtin.zig_backend == .stage2_spirv64 or builtin.zig_backend == .stage2_riscv64); fn print(comptime fmt: []const u8, args: anytype) void { if (@inComptime()) { |
