Libghostty 1.0
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Libghostty 1.0
Mitchell Hashimoto Libghostty 1.0 November 6, 2026
libghostty-vt 1.0 is here. libghostty is a portable, high-performance C library for terminal emulation, extracted directly from the core of Ghostty. The 1.0 release means both the library itself and the C ABI are now stable.
libghostty-vt 1.0 现已发布。libghostty 是一个可移植、高性能的 C 语言终端仿真库,直接从 Ghostty 的核心中提取而来。1.0 版本的发布意味着该库本身及其 C ABI(应用程序二进制接口)现已稳定。
A little over a year ago, I wrote that libghostty is coming. At the time, the Zig module had just been merged, the C API didn’t exist, and nobody but Ghostty was a consumer. Today, the C API is a complete terminal emulator, it runs in production for millions of people across hundreds of products, both free and commercial, and it has a real, enforced ABI stability policy. This post is about how we got here and what 1.0 actually means.
一年多前,我写道 libghostty 即将到来。当时,Zig 模块才刚刚合并,C API 尚不存在,除了 Ghostty 之外没有其他使用者。今天,这个 C API 已经是一个完整的终端仿真器,它在数以百计的免费和商业产品中为数百万用户提供生产环境支持,并且拥有真正且强制执行的 ABI 稳定性策略。本文将介绍我们是如何走到这一步的,以及 1.0 版本的真正含义。
1 Who Is Already Using It
Since starting the Ghostty project in 2022, the most common question I’ve been asked is “why?”. I already answered this in the libghostty is coming post, so feel free to read that if you wish. Today, I’d rather answer this by showing the broad industry impact libghostty has already had. I believe this strongly validates its existence.
1 谁在使用它?
自 2022 年启动 Ghostty 项目以来,我被问到最多的问题是“为什么?”。我已经在《libghostty 即将到来》一文中回答过这个问题,如果你愿意,可以去阅读。今天,我更倾向于通过展示 libghostty 已经产生的广泛行业影响来回答这个问题。我相信这有力地证明了它存在的价值。
A year ago, I used a bug in JediTerm, the terminal emulator in JetBrains IDEs, as an example of why terminal emulation is hard to get right. A year later, the terminal in JetBrains IDEs now runs on libghostty. Every IntelliJ, PyCharm, GoLand, etc. user now has a libghostty-powered terminal. Based on a report by JetBrains, that’s over 12.5 million active users.
一年前,我曾以 JetBrains IDE 中的终端仿真器 JediTerm 的一个 Bug 为例,说明为什么终端仿真很难做到完美。一年后,JetBrains IDE 中的终端现在运行在 libghostty 之上。每一位 IntelliJ、PyCharm、GoLand 等用户现在都拥有了一个由 libghostty 驱动的终端。根据 JetBrains 的报告,这涉及超过 1250 万活跃用户。
Neovim has an approved pull request replacing libvterm with libghostty-vt. Among other things, it closes a 10-year-old issue about reflowing scrollback on resize. The maintainers are waiting on a tagged release before merging so that distributions can package the dependency separately, and the release today should enable that.
Neovim 有一个已获批准的拉取请求,旨在用 libghostty-vt 替换 libvterm。除其他事项外,它还解决了一个关于调整窗口大小时回滚缓冲区重排的 10 年老问题。维护者们正在等待一个带标签的发布版本后再进行合并,以便各发行版可以单独打包该依赖项,而今天的发布将实现这一目标。
KDE developers are experimenting with a Konsole replacement built on it. Vercel’s Turborepo uses it to render task output in its TUI. devenv uses it to drive shells. Antithesis used it to fuzz TUI programs and found real bugs in btop and others. Ghostel brings it to Emacs. ghostty-web is the WASM build with an Xterm.js-compatible API. Commercial products like OrbStack embed it. And a whole wave of new terminals and “agentic” coding tools, such as herdr and cmux, have been built on it rather than writing yet another emulator.
KDE 开发人员正在尝试用它构建 Konsole 的替代品。Vercel 的 Turborepo 使用它在 TUI 中渲染任务输出。devenv 使用它来驱动 Shell。Antithesis 使用它对 TUI 程序进行模糊测试,并在 btop 等程序中发现了真实的 Bug。Ghostel 将其引入了 Emacs。ghostty-web 是一个具有 Xterm.js 兼容 API 的 WASM 构建版本。OrbStack 等商业产品也嵌入了它。此外,一大批新的终端和“代理式”编码工具(如 herdr 和 cmux)都建立在它之上,而不是去编写另一个新的仿真器。
There are community bindings for Rust, Go, JavaScript, Swift, Python, .NET, Elixir, Dart, Java, and more, and the awesome-libghostty list tracks well over a hundred projects. More people today use a terminal powered by libghostty than use Ghostty the application, by a very large multiple. And libghostty is having a much larger impact than being “just” a terminal emulator.
目前已有针对 Rust、Go、JavaScript、Swift、Python、.NET、Elixir、Dart、Java 等语言的社区绑定,awesome-libghostty 列表追踪的项目已超过一百个。今天使用由 libghostty 驱动的终端的人数,远超使用 Ghostty 应用程序的人数。libghostty 产生的影响远不止于“仅仅”是一个终端仿真器。
2 ABI Stability
1.0 means libghostty-vt follows semantic versioning and has strict ABI compatibility promises so that packagers across distributions and operating systems can be confident packaging libghostty-vt and program developers can be confident dynamically linking against it.
2 ABI 稳定性
1.0 意味着 libghostty-vt 遵循语义化版本控制,并具有严格的 ABI 兼容性承诺,以便各发行版和操作系统的打包者可以放心地打包 libghostty-vt,程序开发人员也可以放心地对其进行动态链接。
Beyond providing useful features, I believe the hallmark of a high-quality and enduring C library is ABI stability. So from the start, I took inspiration from C libraries I enjoyed working with and designed the API to have a strong, stable ABI that allows for future additions. Every object is an opaque handle. The hundreds of values you might read or write go through a small set of enum-keyed getters and setters, so we can add new values easily without introducing a new symbol.
除了提供有用的功能外,我认为高质量且持久的 C 库的标志是 ABI 稳定性。因此,从一开始,我就从我喜欢使用的 C 库中汲取灵感,设计了具有强大、稳定 ABI 的 API,从而允许未来的扩展。每个对象都是一个不透明句柄。你可能读取或写入的数百个值都通过一组少量的枚举键控 Getter 和 Setter 进行处理,因此我们可以轻松添加新值而无需引入新符号。
Programs with newer headers linked against an older libghostty get GHOSTTY_UNSUPPORTED results instead of crashes or undefined behavior. The few non-opaque structs we have carry their size so that fields can be appended later, or contain reserved padding. Enums are pinned to int on every compiler, as much as the C standard allows.
使用较新头文件链接到旧版 libghostty 的程序会得到 GHOSTTY_UNSUPPORTED 结果,而不是崩溃或未定义的行为。我们仅有的几个非不透明结构体都带有大小信息,以便后续可以追加字段,或者包含预留的填充空间。在 C 标准允许的范围内,枚举在每个编译器上都被固定为 int 类型。
Our CI enforces our ABI policy. Every change is checked with libabigail against a committed baseline on Linux, and against golden type manifests on macOS and WebAssembly. On ELF platforms, every exported symbol is also versioned, so the dynamic loader refuses to load a mismatched library by name rather than failing in some mysterious way later.
我们的 CI(持续集成)强制执行 ABI 策略。每一次更改都会在 Linux 上通过 libabigail 与已提交的基准进行比对,并在 macOS 和 WebAssembly 上与黄金类型清单进行比对。在 ELF 平台上,每个导出的符号也都进行了版本控制,因此动态加载器会按名称拒绝加载不匹配的库,而不是在稍后以某种神秘的方式失败。
Packaging
In addition to ABI stability, the 1.0 release brings along the proper build tooling, tarballs, dependency licensing manifests, documentation, and more to enable every major operating system and distribution to package libghostty-vt through standard official tooling.
打包
除了 ABI 稳定性外,1.0 版本还带来了适当的构建工具、压缩包、依赖项许可清单、文档等,使每个主流操作系统和发行版都能通过标准的官方工具打包 libghostty-vt。
Libghostty has its own release cycle, separate from Ghostty the application. And it has its own tarballs with only the files and dependencies libghostty needs, resulting in smaller sizes and simpler licensing verification and compatibility. Each release publishes a signed source tarball along with a companion dependencies tarball containing every Zig package in Zig’s own cache layout, so a distribution can build the library completely offline.
Libghostty 拥有独立的发布周期,与 Ghostty 应用程序分开。它拥有自己的压缩包,仅包含 libghostty 所需的文件和依赖项,从而减小了体积,并简化了许可验证和兼容性工作。每次发布都会发布一个已签名的源代码压缩包,以及一个包含 Zig 缓存布局中所有 Zig 包的配套依赖项压缩包,因此发行版可以在完全离线的情况下构建该库。
The build installs the shared and static libraries with a proper SONAME, headers, pkg-config files, and a CMake package config, and it honors —prefix, DESTDIR, and lib64. Debug info is kept by default so distros can split it out. All of this is documented in PACKAGING-LIBGHOSTTY.md, which ships with the tarball.
构建过程会安装带有正确 SONAME 的共享库和静态库、头文件、pkg-config 文件以及 CMake 包配置,并支持 —prefix、DESTDIR 和 lib64。默认保留调试信息,以便发行版可以将其分离。所有这些内容都在随压缩包提供的 PACKAGING-LIBGHOSTTY.md 中有详细记录。
Dependencies and Licensing
libghostty-vt is MIT licensed. At runtime it needs nothing beyond libc, and it can be built fully freestanding if you don’t want that either. The library compiles in a small number of permissively licensed dependencies: simdutf and Google Highway for SIMD, a compact Unicode table for grapheme data, and Wuffs for image decoding in the Kitty graphics protocol.
依赖项与许可
libghostty-vt 采用 MIT 许可。在运行时,它除了 libc 之外不需要任何其他东西,如果你不需要 libc,它甚至可以完全独立构建。该库编译时包含少量采用宽松许可的依赖项:用于 SIMD 的 simdutf 和 Google Highway,用于字形数据的紧凑 Unicode 表,以及用于 Kitty 图形协议中图像解码的 Wuffs。
Both simdutf and Highway are built without libc++, so there is no C++ standard library dependency. There is no copyleft code anywhere in the dependency tree. Every dependency is listed in a machine-readable manifest with its version, SPDX license, and hash, specifically so distros can fill in their bundled-library metadata more easily. If a distro would rather dynamically link the system simdutf or Highway, there’s a build flag for that.
simdutf 和 Highway 在构建时均不使用 libc++,因此不存在 C++ 标准库依赖。依赖树中没有任何 Copyleft 代码。每个依赖项都在机器可读的清单中列出,包含其版本、SPDX 许可和哈希值,专门用于方便发行版填写其捆绑库的元数据。如果发行版更倾向于动态链接系统级的 simdutf 或 Highway,我们为此提供了构建标志。