diff --git a/build.zig b/build.zig index 0b225e6d8..28b5c11ef 100644 --- a/build.zig +++ b/build.zig @@ -3,6 +3,7 @@ const builtin = @import("builtin"); const fs = std.fs; const CompileStep = std.Build.Step.Compile; const RunStep = std.Build.Step.Run; +const ResolvedTarget = std.Build.ResolvedTarget; const apprt = @import("src/apprt.zig"); const font = @import("src/font/main.zig"); @@ -706,10 +707,15 @@ pub fn build(b: *std.Build) !void { const test_step = b.step("test", "Run all tests"); const test_filter = b.option([]const u8, "test-filter", "Filter for test"); + // Force all Mac builds to use a `generic` CPU. This avoids + // potential issues with `highway` compile errors due to missing + // `arm_neon` features (see for example https://github.com/mitchellh/ghostty/issues/1640). + const test_target = if (target.result.os.tag == .macos and builtin.target.isDarwin()) genericMacOSTarget(b) else target; + const main_test = b.addTest(.{ .name = "ghostty-test", .root_source_file = .{ .path = "src/main.zig" }, - .target = target, + .target = test_target, .filter = test_filter, }); @@ -754,6 +760,16 @@ fn osVersionMin(tag: std.Target.Os.Tag) ?std.Target.Query.OsVersion { }; } +// Returns a ResolvedTarget for a mac with a `target.result.cpu.model.name` of `generic`. +// `b.standardTargetOptions()` returns a more specific cpu like `apple_a15`. +fn genericMacOSTarget(b: *std.Build) ResolvedTarget { + return b.resolveTargetQuery(.{ + .cpu_arch = .aarch64, + .os_tag = .macos, + .os_version_min = osVersionMin(.macos), + }); +} + /// Creates a universal macOS libghostty library and returns the path /// to the final library. /// @@ -781,11 +797,7 @@ fn createMacOSLib( const lib = b.addStaticLibrary(.{ .name = "ghostty", .root_source_file = .{ .path = "src/main_c.zig" }, - .target = b.resolveTargetQuery(.{ - .cpu_arch = .aarch64, - .os_tag = .macos, - .os_version_min = osVersionMin(.macos), - }), + .target = genericMacOSTarget(b), .optimize = optimize, }); lib.bundle_compiler_rt = true;