Update to Zig 0.16.0

This commit represents the majority of the work necessary to upgrade
Ghostty to use Zig 0.16.0.

Key parts:

* In addition to its previous responsibilities, the global state now
  houses state for global I/O implementations and the process
  environment. It is now also utilized in the main application along
  with the C library. Where necessary, global state is isolated from key
  parts of the implementation (e.g., in libghostty subsystems), and it's
  expected that this list will grow.

* We currently manage our own C translation layer where necessary. In
  these cases, cImport has been removed in favor of the new external
  translate-c package. Due to fixes that have needed be made to properly
  translate the dependencies that were swapped out, as mentioned, we
  have had to backport fixes from the current translate-c package (and
  the upstream Arocc dependency). We will host this ourselves until Zig
  0.17.0 is released with these fixes.

* Where necessary (only a small number of cases), some stdlib code from
  0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in
  lib/compat.

Co-authored-by: Leah Amelia Chen <hi@pluie.me>
This commit is contained in:
Chris Marchesi
2026-05-07 09:11:14 -07:00
parent 74d0c72fd9
commit e8525c0fd9
357 changed files with 8958 additions and 6098 deletions

View File

@@ -14,7 +14,8 @@ pub const Thread = @This();
const std = @import("std");
const ArenaAllocator = std.heap.ArenaAllocator;
const builtin = @import("builtin");
const xev = @import("../global.zig").xev;
const global = @import("../global.zig");
const xev = global.xev;
const crash = @import("../crash/main.zig");
const internal_os = @import("../os/main.zig");
const termio = @import("../termio.zig");
@@ -147,8 +148,8 @@ pub fn threadMain(self: *Thread, io: *termio.Termio) void {
// the error to the surface thread and let the apprt deal with it
// in some way but this works for now. Without this, the user would
// just see a blank terminal window.
io.renderer_state.mutex.lock();
defer io.renderer_state.mutex.unlock();
io.renderer_state.mutex.lockUncancelable(global.io());
defer io.renderer_state.mutex.unlock(global.io());
const t = io.renderer_state.terminal;
// Hide the cursor
@@ -297,7 +298,7 @@ fn drainMailbox(
// If we're draining, we just drain the mailbox and return.
if (self.flags.drain) {
while (mailbox.pop()) |_| {}
while (mailbox.pop(global.io())) |_| {}
return;
}
@@ -305,7 +306,7 @@ fn drainMailbox(
// expectation is that all our message handlers will be non-blocking
// ENOUGH to not mess up throughput on producers.
var redraw: bool = false;
while (mailbox.pop()) |message| {
while (mailbox.pop(global.io())) |message| {
// If we have a message we always redraw
redraw = true;