Zig-PSP
Zig-PSP copied to clipboard
Update to Zig 0.12.0 Nightly
Currently requires fixing the tooling
Updated the tooling here: https://github.com/zPSP-Dev/zPBPTool/pull/2 and here: https://github.com/zPSP-Dev/zSFOTool/pull/2
For this PR to compile for both 0.12.0 and current 0.13.0, the only real change you need is mostly updating things like this:
.{ .path = build_info.path_to_sdk ++ "tools/linkfile.ld" }
to this:
b.path(build_info.path_to_sdk ++ "tools/linkfile.ld")
Currently the tool Zig-PSP tool fails with the following on 0.13.0-dev.267+793f820b3 if the Zig compiler is built with Debug, otherwise it just exits silently. I've raised an issue against the Zig compiler here: https://github.com/ziglang/zig/issues/20083
$ /c/zig/zig/stage3/bin/zig build
install
└─ install generated to EBOOT.PBP
└─ run pbptool (EBOOT.PBP)
└─ run prxgen (app.prx)
└─ zig build-exe main ReleaseSafe mipsel-freestanding failure
error: thread 18488 panic: attempt to use null value
C:\zig\zig\src\codegen\llvm.zig:4857:79: 0x11d8976 in resolveInst (zig.exe.obj)
const llvm_val = try self.resolveValue((try self.air.value(inst, mod)).?);
^
C:\zig\zig\src\codegen\llvm.zig:5260:45: 0x1220e6f in airCall (zig.exe.obj)
const llvm_fn = try self.resolveInst(pl_op.operand);
^
C:\zig\zig\src\codegen\llvm.zig:5041:55: 0xe77cbe in genBody (zig.exe.obj)
.call => try self.airCall(inst, .auto),
^
C:\zig\zig\src\codegen\llvm.zig:5234:25: 0x1205e85 in genBodyDebugScope (zig.exe.obj)
try self.genBody(body);
^
C:\zig\zig\src\codegen\llvm.zig:6009:35: 0x120ad75 in airCondBr (zig.exe.obj)
try self.genBodyDebugScope(null, then_body);
^
C:\zig\zig\src\codegen\llvm.zig:5021:54: 0xe76fd9 in genBody (zig.exe.obj)
.cond_br => try self.airCondBr(inst),
^
C:\zig\zig\src\codegen\llvm.zig:5234:25: 0x1205e85 in genBodyDebugScope (zig.exe.obj)
try self.genBody(body);
^
C:\zig\zig\src\codegen\llvm.zig:5950:35: 0x12043ca in lowerBlock (zig.exe.obj)
try self.genBodyDebugScope(maybe_inline_func, body);
^
C:\zig\zig\src\codegen\llvm.zig:5920:31: 0x1206c1b in airBlock (zig.exe.obj)
return self.lowerBlock(inst, null, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
^
C:\zig\zig\src\codegen\llvm.zig:5014:53: 0xe76bd4 in genBody (zig.exe.obj)
.block => try self.airBlock(inst),
^
C:\zig\zig\src\codegen\llvm.zig:1740:19: 0xe70e7e in updateFunc (zig.exe.obj)
fg.genBody(air.getMainBody()) catch |err| switch (err) {
^
C:\zig\zig\src\link\Elf.zig:2993:70: 0x11c48d7 in updateFunc (zig.exe.obj)
if (self.llvm_object) |llvm_object| return llvm_object.updateFunc(mod, func_index, air, liveness);
^
C:\zig\zig\src\link.zig:422:82: 0xe8003f in updateFunc (zig.exe.obj)
return @as(*tag.Type(), @fieldParentPtr("base", base)).updateFunc(module, func_index, air, liveness);
^
C:\zig\zig\src\Module.zig:3219:22: 0xbe5dc9 in ensureFuncBodyAnalyzed (zig.exe.obj)
lf.updateFunc(zcu, func_index, air, liveness) catch |err| switch (err) {
^
C:\zig\zig\src\Compilation.zig:3414:42: 0xbe2bdb in processOneJob (zig.exe.obj)
module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
^
C:\zig\zig\src\Compilation.zig:3354:30: 0xa17a2e in performAllTheWork (zig.exe.obj)
try processOneJob(comp, work_item, main_progress_node);
^
C:\zig\zig\src\Compilation.zig:2132:31: 0xa132e3 in update (zig.exe.obj)
try comp.performAllTheWork(main_progress_node);
^
C:\zig\zig\src\main.zig:4091:36: 0xa8f039 in serve (zig.exe.obj)
try comp.update(main_progress_node);
^
C:\zig\zig\src\main.zig:3368:22: 0xaac79f in buildOutputType (zig.exe.obj)
try serve(
^
C:\zig\zig\src\main.zig:262:31: 0x8e93f9 in mainArgs (zig.exe.obj)
return buildOutputType(gpa, arena, args, .{ .build = .Exe });
^
C:\zig\zig\src\main.zig:208:20: 0x8e6aae in main (zig.exe.obj)
return mainArgs(gpa, arena, args);
^
C:\zig\zig\lib\std\start.zig:497:75: 0x8e67da in main (zig.exe.obj)
return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp);
^
C:\zig\zig\lib\libc\mingw\crt\crtexe.c:267:0: 0x32089a1 in __tmainCRTStartup (crt2.obj)
mainret = _tmain (argc, argv, envp);
C:\zig\zig\lib\libc\mingw\crt\crtexe.c:188:0: 0x32089fb in mainCRTStartup (crt2.obj)
ret = __tmainCRTStartup ();
???:?:?: 0x7ff95cc87343 in ??? (KERNEL32.DLL)
???:?:?: 0x7ff95df426b0 in ??? (ntdll.dll)
error: the following command exited with error code 3:
C:\zig\zig\stage3\bin\zig.exe build-exe -OReleaseSafe -target mipsel-freestanding -mcpu mips2+single_float -Mroot=D:\ZigProjects\Zig-PSP\src\main.zig --eh-frame-hdr --emit-relocs --cache-dir D:\ZigProjects\Zig-PSP\zig-cache --global-cache-dir C:\Users\User\AppData\Local\zig --name main --script D:\ZigProjects\Zig-PSP\tools\linkfile.ld --listen=-
install
└─ install generated to EBOOT.PBP
└─ run pbptool (EBOOT.PBP)
└─ run sfotool (PARAM.SFO) stderr
warning: SFO Saved!
Build Summary: 6/11 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install generated to EBOOT.PBP transitive failure
└─ run pbptool (EBOOT.PBP) transitive failure
└─ run prxgen (app.prx) transitive failure
└─ zig build-exe main ReleaseSafe mipsel-freestanding failure
error: the following build command failed with exit code 1:
D:\ZigProjects\Zig-PSP\zig-cache\o\50fa40c0e6e280076fa8b7abaf8bf600\build.exe C:\zig\zig\stage3\bin\zig.exe D:\ZigProjects\Zig-PSP D:\ZigProjects\Zig-PSP\zig-cache C:\Users\User\AppData\Local\zig --seed 0xbafe9bae -Zda7aa504a23a6674
Have also updated code / build to get to the point where an EBOOT.pbp can be created via this branch: https://github.com/silbinarywolf/Zig-PSP/tree/feature/update-to-zig-0.13-and-more
Unfortunately, while it currently boots, it just shows this instead of the spinning cube, at least via emulation:
Apologies for not responding sooner / being inactive -- thank you for the changes! I would be comfortable merging at this point and debugging the issue. I am aware that there is a bug mentioned in issue #6 that might be causing this.
Side note for the tooling -- I am going to work on merging and refreshing the tooling at some point.