mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00

This fixes an issue where Ghostty would not build against the macOS 15.5 SDK. What was happening was that Zig was adding its embedded libc paths to the clang command line, which included old headers that were incompatible with the latest (macOS 15.5) SDK. Ghostty was adding the newer paths but they were being overridden by the embedded libc paths. The reason this was happening is because Zig was using its own logic to find the libc paths and this was colliding with the paths we were setting manually. To fix this, we now use a `libc.txt` file that explicitly tells Zig where to find libc, and we base this on our own SDK search logic.
111 lines
3.0 KiB
Zig
111 lines
3.0 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const upstream = b.dependency("highway", .{});
|
|
|
|
const module = b.addModule("highway", .{
|
|
.root_source_file = b.path("main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const lib = b.addStaticLibrary(.{
|
|
.name = "highway",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
lib.linkLibCpp();
|
|
lib.addIncludePath(upstream.path(""));
|
|
module.addIncludePath(upstream.path(""));
|
|
|
|
if (target.result.os.tag.isDarwin()) {
|
|
const apple_sdk = @import("apple_sdk");
|
|
try apple_sdk.addPaths(b, lib);
|
|
}
|
|
|
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
|
defer flags.deinit();
|
|
try flags.appendSlice(&.{
|
|
// Avoid changing binaries based on the current time and date.
|
|
"-Wno-builtin-macro-redefined",
|
|
"-D__DATE__=\"redacted\"",
|
|
"-D__TIMESTAMP__=\"redacted\"",
|
|
"-D__TIME__=\"redacted\"",
|
|
|
|
// Optimizations
|
|
"-fmerge-all-constants",
|
|
|
|
// Warnings
|
|
"-Wall",
|
|
"-Wextra",
|
|
|
|
// These are not included in Wall nor Wextra:
|
|
"-Wconversion",
|
|
"-Wsign-conversion",
|
|
"-Wvla",
|
|
"-Wnon-virtual-dtor",
|
|
|
|
"-Wfloat-overflow-conversion",
|
|
"-Wfloat-zero-conversion",
|
|
"-Wfor-loop-analysis",
|
|
"-Wgnu-redeclared-enum",
|
|
"-Winfinite-recursion",
|
|
"-Wself-assign",
|
|
"-Wstring-conversion",
|
|
"-Wtautological-overlap-compare",
|
|
"-Wthread-safety-analysis",
|
|
"-Wundefined-func-template",
|
|
|
|
"-fno-cxx-exceptions",
|
|
"-fno-slp-vectorize",
|
|
"-fno-vectorize",
|
|
});
|
|
if (target.result.os.tag != .windows) {
|
|
try flags.appendSlice(&.{
|
|
"-fmath-errno",
|
|
"-fno-exceptions",
|
|
});
|
|
}
|
|
|
|
lib.addCSourceFiles(.{ .flags = flags.items, .files = &.{"bridge.cpp"} });
|
|
lib.addCSourceFiles(.{
|
|
.root = upstream.path(""),
|
|
.flags = flags.items,
|
|
.files = &.{
|
|
"hwy/abort.cc",
|
|
"hwy/aligned_allocator.cc",
|
|
"hwy/nanobenchmark.cc",
|
|
"hwy/per_target.cc",
|
|
"hwy/print.cc",
|
|
"hwy/targets.cc",
|
|
"hwy/timer.cc",
|
|
},
|
|
});
|
|
lib.installHeadersDirectory(
|
|
upstream.path("hwy"),
|
|
"hwy",
|
|
.{ .include_extensions = &.{".h"} },
|
|
);
|
|
|
|
b.installArtifact(lib);
|
|
|
|
{
|
|
const test_exe = b.addTest(.{
|
|
.name = "test",
|
|
.root_source_file = b.path("main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
test_exe.linkLibrary(lib);
|
|
|
|
var it = module.import_table.iterator();
|
|
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
|
const tests_run = b.addRunArtifact(test_exe);
|
|
const test_step = b.step("test", "Run tests");
|
|
test_step.dependOn(&tests_run.step);
|
|
}
|
|
}
|