Update to Zig 0.16.0#12726
Conversation
jacobsandlund
left a comment
There was a problem hiding this comment.
uucode related changes look good!
|
Vexu/arocc#1010 has been opened to address the previously mentioned arocc issue. There now seems to be an issue with the translated Zig artifact. Will work on tracking this down next: |
|
Opened a couple of translate-c issues:
These two changes along with the Aro update seem to have unblocked us and I can proceed with fixing the full build again. 🙂 🤞 |
|
I'm now happy to say that the project builds, tests, and runs under Linux!
The pkg-config bits that we were using to work around the translate-c issues have been moved back to translate-c since the previously mentioned fixes unblock us there. Nothing particularly notable otherwise to mention (Vexu/arocc#1010 has been merged though!). I'm not going to say that there aren't any upgrade-related regressions yet, although I'm not aware of any, and I'm planning on driving this soon to check. My focus now will be moving to Darwin (testing/building on MacOS). There are also some issues with the translate-c fixes on Darwin and other platforms, so these need to be corrected too. |
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. At this point, the project builds, tests, and runs under Linux. More work may be necessary for other platforms, and possibly to fix any (currently unknown) upgrade regressions. Co-authored-by: Leah Amelia Chen <hi@pluie.me>

Closes #12228
Supersedes #12388
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0.
At this point, all tests pass under Linux, but more work may be necessary to get them to build and function on other platforms.
There are some parts of this update that deserve commentary, so that follows below:
Use of
std.Io.Threaded.global_single_threadedAll stdlib interactions that now require an I/O implementation due to the update of stdlib to 0.16.0 have had
std.Io.Threaded.global_single_threadedpassed in as their I/O implementation. This is just a static local instance of the single-threaded I/O implementation, so it saves us having to have.init_single_threadedeverywhere.This ultimately allows us to implement more complex and up-to-date I/O patterns piecemeal outside of the larger upgrade work.
There are a couple of uses of
std.process.spawnthat need to useIo.Threadedimplementations directly (via.init). This is because.spawnrequires an allocator to create args, and the single-threaded implementation, by default, assigns a failing allocator.The
lib/compatTreeSeveral stdlib features that have been removed but still either seem they would be valuable to us or outright complex to move away from (particularly
SegmentedList) have been extracted from 0.15.2, updated as needed, and placed insrc/lib/compat. The intention again is to allow for piecemeal migration to more modern implementations or possibly straight local versions.This paradigm has also allowed us to add
std.Io.Condition.waitTimeout, which incidentally was missed in the 0.16.0 shuffle and has been re-added for 0.17.0. We can remove this in favor of the upstream when we eventually migrate to that, obviously.Static local args and environment storage
Additionally, contained within the
lib/compattree is static local storage forstd.process.Argsandos_environinstances, along with any code we needed to work with these extracted. These are set on most entry points in various ways, but usually throughlib/compat/init.zig.run.Various parts of code in
lib/compatshim most of our interaction with the environment and work off of the aforementioned static local variables.translate-c Issues (functional on Linux, Darwin WIP)
UPDATE: Most of this is outdated, check progress below!
The biggest blocker to getting this fully built and functional
right now seems to bewas issues with Zig's migration to arocc for translate-c functionality. This is part of the transition to a standalone and LLVM-free translate-c (slated for 0.17.0, it seems, or at least that's whencImportis going away completely). Unfortunately, there have been issues with arocc's handling of GTK headers, see https://codeberg.org/ziglang/translate-c/issues/328 and Vexu/arocc#996. These had apparently been fixed, but it appears some issues still persist with use of translate-c for GTK, namely with#definehandling:This happens on the latest translate-c and arocc (on Zig master).
I am planning on looking into this further to see if we can move this along - namely, looking into what's causing this lingering issue in arocc/translate-c.
To fix this in some parts of
apprt/gtkthat only required access to version information from the GTK/libadwaita headers, I have just added some modules that build version data from call-outs topkg-config. I'm not too sure if the rest of the code could be shimmed out a similar way, but it seems there are at least two places that it may be more complex to or not feasible:pkg/gtk4-layer-shell)ghostty_resources.hfile (referencesgio/gio.hwhich contain similar#definestatements in nested files).That's about it for now. I'm still working on this; there's a number of things that still need updating otherwise due to the build failing due to the translate-c issues, but I wanted to get this work up so that folks new there was significant progress made. More updates when I have them - feel free to leave feedback on any of the work already done!