feat(macos): port Ghostty's macOS code paths (Metal, CoreText, Darwin)

Ports the macOS-specific Zig code behind cfg(target_os = "macos"):
- renderer: a GraphicsApi trait with generic::Renderer<G>; Metal backend
  (all renderer/metal/* files, shaders.metal verbatim, runtime library
  compile, IOSurface layer, CVDisplayLink), shadertoy -> MSL via naga;
  OpenGL remains the backend elsewhere.
- font: CoreText face, shaper and discovery with build.rs backend
  selection (coretext default; coretext-freetype / coretext-harfbuzz /
  coretext-noshape features), no fontconfig/freetype/harfbuzz on Apple.
- input: KeymapDarwin via UCKeyTranslate, option-as-alt, mac keycodes.
- os: macos, mach, cf_release_thread, NSProcessInfo args and macOS
  branches; config: macOS defaults, keybinds, Application Support paths.
- termio/core: login(1) wrapping, openpty/execvpe, Darwin child exit
  handling, os_log logging.

Compile-checked for aarch64/x86_64-apple-darwin (clippy -D warnings
clean) using the cross setup in docs/rewrite/notes/macos-M1.md; cannot
run here. The embedded runtime/C API (embedded.zig) is the next step.

Also includes the cross-platform integration edits shared by the crash,
verification, Windows and macOS work (Cargo target-gating, thread
crash-context hooks, apprt-gtk surface/IME refactor, termio/os cfg
gates), a cfg fix so ghostty-config builds on wasm32, and an allow for
the intentional recursion in the crash overflow test.

Test Plan:
- cargo test --workspace (3224 passed)
- cargo clippy --workspace --all-targets -- -D warnings
- cargo check --target aarch64-apple-darwin -p ghostty-renderer (with
  the documented cross env)
This commit is contained in:
ddidderr committed 2026-10-12 06:02:39 +02:00
1 parent 3c8fae1089
commit 452b782149
124 files changed
+14936 -1242

No files matched your search

Generated
+263
View File
@@ -341,6 +341,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
dependencies = [
"objc2",
]
[[package]]
name = "blocking"
version = "1.7.0"
@@ -784,6 +793,18 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "dispatch2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
]
[[package]]
name = "dlib"
version = "0.5.3"
@@ -1291,6 +1312,7 @@ dependencies = [
"wayland-client",
"wayland-protocols",
"wayland-protocols-plasma",
"wayland-sys",
]
[[package]]
@@ -1321,6 +1343,7 @@ dependencies = [
"flate2",
"ghostty-apprt",
"ghostty-config",
"ghostty-crash",
"ghostty-font",
"ghostty-input",
"ghostty-os",
@@ -1355,6 +1378,7 @@ dependencies = [
"crossbeam-channel",
"ghostty-apprt",
"ghostty-config",
"ghostty-crash",
"ghostty-datastruct",
"ghostty-font",
"ghostty-input",
@@ -1367,10 +1391,23 @@ dependencies = [
"ghostty-vt",
"log",
"onig",
"oslog",
"png",
"thiserror 2.0.21",
]
[[package]]
name = "ghostty-crash"
version = "0.1.0"
dependencies = [
"ghostty-os",
"libc",
"log",
"serde_json",
"tempfile",
"thiserror 2.0.21",
]
[[package]]
name = "ghostty-datastruct"
version = "0.1.0"
@@ -1387,11 +1424,17 @@ dependencies = [
"freetype-sys",
"ghostty-config",
"ghostty-datastruct",
"ghostty-os",
"ghostty-terminal",
"ghostty-unicode",
"ghostty-vt",
"harfbuzz-sys",
"log",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-text",
"objc2-foundation",
"png",
"thiserror 2.0.21",
"tiny-skia",
@@ -1405,6 +1448,8 @@ dependencies = [
"ghostty-unicode",
"ghostty-vt",
"indexmap",
"log",
"objc2-core-foundation",
"thiserror 2.0.21",
]
@@ -1433,13 +1478,20 @@ dependencies = [
name = "ghostty-os"
version = "0.1.0"
dependencies = [
"crossbeam-channel",
"gettext-rs",
"ghostty-vt",
"libc",
"log",
"nix 0.31.3",
"objc2",
"objc2-app-kit",
"objc2-core-foundation",
"objc2-foundation",
"rustix",
"temp-env",
"thiserror 2.0.21",
"windows-sys",
"zbus",
]
@@ -1447,12 +1499,16 @@ dependencies = [
name = "ghostty-renderer"
version = "0.1.0"
dependencies = [
"block2",
"bytemuck",
"crossbeam-channel",
"dispatch2",
"ghostty-config",
"ghostty-crash",
"ghostty-datastruct",
"ghostty-font",
"ghostty-input",
"ghostty-os",
"ghostty-terminal",
"ghostty-unicode",
"ghostty-vt",
@@ -1461,6 +1517,14 @@ dependencies = [
"khronos-egl",
"log",
"naga",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-video",
"objc2-foundation",
"objc2-io-surface",
"objc2-metal",
"objc2-quartz-core",
"onig",
"png",
"thiserror 2.0.21",
@@ -1475,8 +1539,12 @@ dependencies = [
"ghostty-cli",
"ghostty-config",
"ghostty-core",
"ghostty-crash",
"ghostty-os",
"log",
"rustix",
"serde_json",
"tempfile",
]
[[package]]
@@ -1489,6 +1557,7 @@ dependencies = [
"ghostty-config",
"ghostty-datastruct",
"ghostty-onig",
"ghostty-os",
"ghostty-unicode",
"ghostty-vt",
"log",
@@ -1505,6 +1574,7 @@ dependencies = [
"crossbeam-channel",
"ghostty-apprt",
"ghostty-config",
"ghostty-crash",
"ghostty-datastruct",
"ghostty-os",
"ghostty-renderer",
@@ -1513,9 +1583,13 @@ dependencies = [
"libc",
"log",
"nix 0.31.3",
"objc2-core-foundation",
"objc2-foundation",
"rustix",
"temp-env",
"thiserror 2.0.21",
"windows-sys",
"zbus",
]
[[package]]
@@ -1532,6 +1606,27 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "ghostty-vt-capi"
version = "0.1.0"
dependencies = [
"ghostty-input",
"ghostty-vt",
"log",
]
[[package]]
name = "ghostty-wasm"
version = "0.1.0"
dependencies = [
"ghostty-config",
"ghostty-font",
"ghostty-os",
"ghostty-terminal",
"log",
"temp-env",
]
[[package]]
name = "gio"
version = "0.22.10"
@@ -2379,6 +2474,58 @@ dependencies = [
"objc_id",
]
[[package]]
name = "objc2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"
dependencies = [
"objc2-encode",
]
[[package]]
name = "objc2-app-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
"objc2-cloud-kit",
"objc2-core-data",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-image",
"objc2-core-text",
"objc2-core-video",
"objc2-foundation",
"objc2-quartz-core",
]
[[package]]
name = "objc2-cloud-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-data"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
@@ -2386,6 +2533,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags 2.13.2",
"block2",
"dispatch2",
"libc",
"objc2",
]
[[package]]
@@ -2394,7 +2545,24 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
dependencies = [
"bitflags 2.13.2",
"block2",
"dispatch2",
"libc",
"objc2",
"objc2-core-foundation",
"objc2-io-surface",
"objc2-metal",
]
[[package]]
name = "objc2-core-image"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"
dependencies = [
"objc2",
"objc2-foundation",
]
[[package]]
@@ -2404,7 +2572,90 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
]
[[package]]
name = "objc2-core-video"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
dependencies = [
"bitflags 2.13.2",
"block2",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-io-surface",
"objc2-metal",
]
[[package]]
name = "objc2-encode"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
[[package]]
name = "objc2-foundation"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-io-surface"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d"
dependencies = [
"bitflags 2.13.2",
"libc",
"objc2",
"objc2-core-foundation",
"objc2-foundation",
]
[[package]]
name = "objc2-metal"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794"
dependencies = [
"bitflags 2.13.2",
"block2",
"dispatch2",
"objc2",
"objc2-core-foundation",
"objc2-foundation",
"objc2-io-surface",
]
[[package]]
name = "objc2-quartz-core"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-video",
"objc2-foundation",
"objc2-metal",
]
[[package]]
@@ -2470,6 +2721,15 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "oslog"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969"
dependencies = [
"cc",
]
[[package]]
name = "palette"
version = "0.7.7"
@@ -3052,6 +3312,8 @@ version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
dependencies = [
"foldhash",
"indexmap",
"itoa",
"memchr",
"serde",
@@ -3813,6 +4075,7 @@ checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be"
dependencies = [
"dlib",
"log",
"once_cell",
"pkg-config",
]