aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig')
-rw-r--r--vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig b/vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig
new file mode 100644
index 00000000..3e1cafa5
--- /dev/null
+++ b/vendor/libghostty-vt/src/build/LibsystemOverrideStep.zig
@@ -0,0 +1,51 @@
+//! Wraps a Darwin static archive with the libsystem_override.sh
+//! post-processing step so that consumers linking the archive bind
+//! well-known libc/libm symbols (memcpy, memmove, memset, cos, sin,
+//! ...) to Apple's libSystem instead of the bundled Zig compiler-rt.
+//! See src/build/libsystem_override.sh for the full rationale.
+//!
+//! This applies to every static archive we produce, public
+//! (e.g. libghostty-vt) and app-internal alike: the compiler-rt
+//! bundle must stay because the few symbols libSystem does not
+//! provide (f128 conversions, *q math, sincos*, ___zig_probe_stack)
+//! have live references, e.g. from the bundled ubsan runtime and
+//! x86_64 stack probing in Debug builds.
+//!
+//! Note shared libraries can't use either approach: Zig 0.16 links
+//! compiler-rt as an eagerly-included object, so its definitions are
+//! already bound into the dylib at link time and cannot be repaired
+//! post-hoc. That needs an upstream Zig fix.
+const std = @import("std");
+const builtin = @import("builtin");
+
+pub const Result = struct {
+ /// The step performing the override, or null if the override
+ /// doesn't apply to this target/host (in which case `output` is
+ /// the unmodified input).
+ step: ?*std.Build.Step,
+ output: std.Build.LazyPath,
+};
+
+/// Post-process the given static archive on Darwin. Requires a Darwin
+/// host for the Apple toolchain (nmedit); in all other configurations
+/// this is a no-op and the input is returned unmodified, which is
+/// functional (the bundled compiler-rt symbols are used), just slower.
+pub fn create(
+ b: *std.Build,
+ target: std.Build.ResolvedTarget,
+ input: std.Build.LazyPath,
+ out_name: []const u8,
+) Result {
+ if (!target.result.os.tag.isDarwin() or
+ comptime !builtin.os.tag.isDarwin())
+ {
+ return .{ .step = null, .output = input };
+ }
+
+ const run = b.addSystemCommand(&.{"/bin/sh"});
+ run.setName("libsystem override");
+ run.addFileArg(b.path("src/build/libsystem_override.sh"));
+ run.addFileArg(input);
+ const output = run.addOutputFileArg(out_name);
+ return .{ .step = &run.step, .output = output };
+}