diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-10 21:51:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 21:51:57 +0300 |
| commit | 425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch) | |
| tree | e52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/build/GhosttyLib.zig | |
| parent | 90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff) | |
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/build/GhosttyLib.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/build/GhosttyLib.zig | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/vendor/libghostty-vt/src/build/GhosttyLib.zig b/vendor/libghostty-vt/src/build/GhosttyLib.zig index b762da8b..529bb282 100644 --- a/vendor/libghostty-vt/src/build/GhosttyLib.zig +++ b/vendor/libghostty-vt/src/build/GhosttyLib.zig @@ -1,9 +1,11 @@ const GhosttyLib = @This(); const std = @import("std"); +const builtin = @import("builtin"); const RunStep = std.Build.Step.Run; const CombineArchivesStep = @import("CombineArchivesStep.zig"); const Config = @import("Config.zig"); +const LibsystemOverrideStep = @import("LibsystemOverrideStep.zig"); const SharedDeps = @import("SharedDeps.zig"); const LipoStep = @import("LipoStep.zig"); @@ -27,14 +29,14 @@ pub fn initStatic( .target = deps.config.target, .optimize = deps.config.optimize, .strip = deps.config.strip, - .omit_frame_pointer = deps.config.strip, + .omit_frame_pointer = deps.config.omitFramePointer(), .unwind_tables = if (deps.config.strip) .none else .sync, + .link_libc = true, }), // Fails on self-hosted x86_64 on macOS .use_llvm = true, }); - lib.linkLibC(); // These must be bundled since we're compiling into a static lib. // Otherwise, you get undefined symbol errors. @@ -57,9 +59,19 @@ pub fn initStatic( const combined = CombineArchivesStep.create(b, deps.config.target, "ghostty-internal", lib_list.items); combined.step.dependOn(&lib.step); + // On Darwin, prefer libSystem's libc/libm over the bundled + // compiler-rt for consumers of this archive. See + // libsystem_override.sh for details. This is a no-op elsewhere. + const override = LibsystemOverrideStep.create( + b, + deps.config.target, + combined.output, + "libghostty-internal.a", + ); + return .{ - .step = combined.step, - .output = combined.output, + .step = override.step orelse combined.step, + .output = override.output, // Static libraries cannot have dSYMs because they aren't linked. .dsym = null, @@ -72,6 +84,14 @@ pub fn initShared( b: *std.Build, deps: *const SharedDeps, ) !GhosttyLib { + // For dynamic linking, we prefer dynamic linking and to search by + // mode first. Mode first will search all paths for a dynamic library + // before falling back to static. + const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{ + .preferred_link_mode = .dynamic, + .search_strategy = .mode_first, + }; + const lib = b.addLibrary(.{ .name = "ghostty", .linkage = .dynamic, @@ -80,7 +100,7 @@ pub fn initShared( .target = deps.config.target, .optimize = deps.config.optimize, .strip = deps.config.strip, - .omit_frame_pointer = deps.config.strip, + .omit_frame_pointer = deps.config.omitFramePointer(), .unwind_tables = if (deps.config.strip) .none else .sync, }), @@ -99,12 +119,12 @@ pub fn initShared( { // The CRT initialization code in msvcrt.lib calls __vcrt_initialize // and __acrt_initialize, which are in the static CRT libraries. - lib.linkSystemLibrary("libvcruntime"); + lib.root_module.linkSystemLibrary("libvcruntime", dynamic_link_opts); // ucrt.lib is in the Windows SDK 'ucrt' dir. Detect the SDK // installation and add the UCRT library path. const arch = deps.config.target.result.cpu.arch; - const sdk = std.zig.WindowsSdk.find(b.allocator, arch) catch null; + const sdk = std.zig.WindowsSdk.find(b.allocator, b.graph.io, arch, &b.graph.environ_map) catch null; if (sdk) |s| { if (s.windows10sdk) |w10| { const arch_str: []const u8 = switch (arch) { @@ -120,11 +140,11 @@ pub fn initShared( ) catch null; if (ucrt_lib_path) |path| { - lib.addLibraryPath(.{ .cwd_relative = path }); + lib.root_module.addLibraryPath(.{ .cwd_relative = path }); } } } - lib.linkSystemLibrary("libucrt"); + lib.root_module.linkSystemLibrary("libucrt", dynamic_link_opts); } // Get our debug symbols |
