Skip to content

Commit f55c77b

Browse files
authored
build: Use correct SDK for iOS Simulator shader build (ghostty-org#7636)
This PR makes the build script use the correct SDK and version flag for the iOS Simulator. Without this PR, the terminal fails to initialize on the iOS Simulator: ``` Compiler failed to build request metal error=Target OS is incompatible: library was not compiled for the simulator error initializing surface err=error.MetalFailed ``` <details> <summary>With the PR</summary> ![image](https://github.com/user-attachments/assets/13735334-1321-42d5-8f01-4d5f6a7660ba) </details> Fixes ghostty-org#7635.
2 parents d0e1452 + fda08a6 commit f55c77b

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

src/build/MetallibStep.zig

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,20 @@ output: LazyPath,
2424
pub fn create(b: *std.Build, opts: Options) ?*MetallibStep {
2525
const sdk = switch (opts.target.result.os.tag) {
2626
.macos => "macosx",
27-
.ios => "iphoneos",
27+
.ios => switch (opts.target.result.abi) {
28+
.simulator => "iphonesimulator",
29+
else => "iphoneos",
30+
},
2831
else => return null,
2932
};
33+
const platform_version_arg = switch (opts.target.result.os.tag) {
34+
.macos => "-mmacos-version-min",
35+
.ios => switch (opts.target.result.abi) {
36+
.simulator => "-mios-simulator-version-min",
37+
else => "-mios-version-min",
38+
},
39+
else => null,
40+
};
3041

3142
const self = b.allocator.create(MetallibStep) catch @panic("OOM");
3243

@@ -46,16 +57,11 @@ pub fn create(b: *std.Build, opts: Options) ?*MetallibStep {
4657
const output_ir = run_ir.addOutputFileArg(b.fmt("{s}.ir", .{opts.name}));
4758
run_ir.addArgs(&.{"-c"});
4859
for (opts.sources) |source| run_ir.addFileArg(source);
49-
switch (opts.target.result.os.tag) {
50-
.ios => run_ir.addArgs(&.{b.fmt(
51-
"-mios-version-min={s}",
52-
.{min_version},
53-
)}),
54-
.macos => run_ir.addArgs(&.{b.fmt(
55-
"-mmacos-version-min={s}",
56-
.{min_version},
57-
)}),
58-
else => {},
60+
if (platform_version_arg) |arg| {
61+
run_ir.addArgs(&.{b.fmt(
62+
"{s}={s}",
63+
.{ arg, min_version },
64+
)});
5965
}
6066

6167
const run_lib = RunStep.create(

0 commit comments

Comments
 (0)