跳到主内容
@wquguru
精选88Hacker News Best(web_list)产品发布/更新

libghostty 1.0发布:稳定C ABI与跨平台终端仿真库

Libghostty 1.0

原文
发到 X
推荐理由

AI Agent开发常需嵌入终端交互界面,libghostty作为底层高性能且ABI稳定的组件,能显著降低集成复杂度,值得Agent框架开发者关注。

Mitchell Hashimoto

Libghostty 1.0

November 6, 2026

2026年11月6日

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.

一年多前,我曾写道 libghostty 即将到来。当时,Zig 模块刚刚合并,C API 尚不存在,除了 Ghostty 之外没有其他消费者。如今,C API 已成为一个完整的终端模拟器,在数百款免费和商业产品中为数百万人提供生产环境支持,并且拥有真正强制执行的 ABI 稳定性策略。

This post is about how we got here and what 1.0 actually means.1

这篇文章讲述了我们如何走到这一步,以及 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.

自 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 IDEs 中的终端模拟器 JediTerm 的一个漏洞为例,说明终端仿真很难做到完美。一年后,JetBrains IDEs 中的终端现在运行在 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 已批准一项将 libvterm 替换为 libghostty-vt 的拉取请求。除此之外,它还解决了一个关于调整大小时重排滚动历史记录的十年旧问题。维护者正在等待打标签的版本发布后再合并,以便发行版可以单独打包该依赖项,而今天的发布应该能实现这一点。

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 等其他程序中发现了真实漏洞。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.

社区提供了 Rust、Go、JavaScript、Swift、Python、.NET、Elixir、Dart、Java 等的绑定,awesome-libghostty 列表追踪的项目已超过一百个。

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.2

如今,使用由 libghostty 驱动的终端的用户数量远超使用 Ghostty 应用程序的用户,且差距巨大。libghostty 的影响也远不止于“仅仅”是一个终端模拟器。

ABI Stability

ABI 稳定性

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.

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.

除了提供有用的功能外,我认为高质量且持久的 C 库的标志是 ABI 稳定性。因此,从一开始,我就从我喜欢使用的 C 库中汲取灵感,设计了具有强大、稳定 ABI 的 API,以允许未来的扩展。

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. 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.

每个对象都是一个不透明句柄。你可能读取或写入的数百个值都通过一组少量的枚举键控 getter 和 setter 进行传递,这样我们就可以轻松添加新值而无需引入新的符号。链接较旧 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.

我们的 CI(持续集成)强制执行我们的 ABI 策略。每次更改都会使用 libabigail 在 Linux 上与提交的基线进行检查,并在 macOS 和 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.

在 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 版本还带来了适当的构建工具、tarball 包、依赖项许可清单、文档等,使每个主要操作系统和发行版都能通过标准的官方工具对 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.

Libghostty 拥有独立于 Ghostty 应用程序自身的发布周期。它拥有自己的 tarball 包,仅包含 libghostty 所需的文件和依赖项,从而实现了更小的体积以及更简单的许可验证和兼容性检查。

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. 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.

每次发布都会附带一个签名的源码 tarball,以及一个包含 Zig 自身缓存布局中所有 Zig 包的依赖项 tarball,因此发行版可以完全离线构建该库。构建过程会安装带有正确 SONAME 的共享和静态库、头文件、pkg-config 文件和 CMake 包配置,并支持 --prefix、DESTDIR 和 lib64。默认保留调试信息,以便发行版可以将其分离出来。所有这些都在 PACKAGING-LIBGHOSTTY.md 中有文档说明,该文件随 tarball 一起分发。

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.3

libghostty-vt 采用 MIT 许可证。在运行时,它除了 libc 之外不需要任何其他依赖;如果你也不想要 libc,它可以完全独立构建。3

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. Both simdutf and Highway are built without libc++, so there is no C++ standard library dependency.

该库编译了少量采用宽松许可证的依赖项:用于 SIMD 的 simdutf 和 Google Highway、用于字形数据的紧凑 Unicode 表,以及用于 Kitty 图形协议图像解码的 Wuffs。simdutf 和 Highway 均在无 libc++ 的情况下构建,因此没有 C++ 标准库依赖。

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.

依赖树中没有任何 Copyleft 代码。每个依赖项都列在一个机器可读的清单中,包含其版本、SPDX 许可证和哈希值,专门方便发行版更轻松地填写捆绑库元数据。

If a distro would rather dynamically link the system simdutf or Highway, there's a build flag for that.

如果发行版更倾向于动态链接系统的 simdutf 或 Highway,有一个构建标志可以实现这一点。

Portability

可移植性

libghostty-vt is highly portable. The table below lists all the platforms and architectures that we build and test (full unit tests plus running all examples) in CI:

libghostty-vt 具有高度的可移植性。下表列出了我们在 CI 中构建和测试的所有平台和架构(完整的单元测试加上运行所有示例):

PlatformArchitectures
Linux (glibc, musl)x86_64, aarch64
macOS 13+x86_64, aarch64
iOS 13+aarch64
FreeBSDx86_64, aarch64
Windowsx86_64
Androidaarch64, x86_64, arm
WebAssemblywasm32 (freestanding)
平台架构
Linux (glibc, musl)x86_64, aarch64
macOS 13+x86_64, aarch64
iOS 13+aarch64
FreeBSDx86_64, aarch64
Windowsx86_64
Androidaarch64, x86_64, arm
WebAssemblywasm32 (freestanding)

There is a second set of platforms we build in CI but do not run tests for. These systems all have known users; we just haven't set up the machinery for automated testing:

还有另一组我们在 CI 中构建但不运行测试的平台。这些系统都有已知用户;我们只是尚未设置自动化测试的基础设施:

PlatformArchitectures
Bare metalriscv32, thumb
WebAssembly (WASI)wasm32
Windowsarm64
illumosx86_64
32-bit x86x86
平台架构
裸机riscv32, thumb
WebAssembly (WASI)wasm32
Windowsarm64
illumosx86_64
32位 x86x86

Each of the tested platforms gets the artifacts it expects:

每个经过测试的平台都会获得其预期的工件:

  • Linux and FreeBSD get a shared library with a proper SONAME and versioned symbols, a static library, headers, pkg-config files, and a CMake package config.
  • macOS and iOS get a dylib with an @rpath install name and compatibility version, plus an XCFramework covering macOS, iOS, and the iOS simulator that drops straight into Xcode or Swift Package Manager.
  • Windows gets a DLL with a .pdb, an import library, and a static library. The library is built with the GNU ABI, but MSVC programs link against it through the import library and CI verifies this.
  • Android gets a shared library built against the NDK with 16 KB page size support, as required by Android 15+.
  • WebAssembly ships in two flavors, one optimized for speed and one for size, and the small one is under a megabyte with every feature enabled. If you only need a read-only viewer, subsystems like input encoding, search, selection, and Kitty graphics can be compiled out with a build flag, which roughly halves the module. Every function stays exported and simply returns GHOSTTY_UNSUPPORTED so your code doesn't have to change.4
  • Linux 和 FreeBSD 获得带有正确 SONAME 和版本化符号的共享库、静态库、头文件、pkg-config 文件和 CMake 包配置。
  • macOS 和 iOS 获得带有 @rpath 安装名称和兼容版本的 dylib,以及一个涵盖 macOS、iOS 和 iOS 模拟器的 XCFramework,可直接导入 Xcode 或 Swift Package Manager。
  • Windows 获得一个带有 .pdb、导入库和静态库的 DLL。该库使用 GNU ABI 构建,但 MSVC 程序通过导入库与其链接,CI 对此进行了验证。
  • Android 获得一个针对 NDK 构建的支持 16 KB 页面大小的共享库,这是 Android 15+ 的要求。
  • WebAssembly 提供两种版本,一种优化速度,一种优化体积,启用所有功能后小版本仍不足 1 MB。如果你只需要只读查看器,可以通过构建标志编译掉输入编码、搜索、选择和 Kitty 图形等子系统,这大致可将模块大小减半。每个函数仍保持导出状态,仅返回 GHOSTTY_UNSUPPORTED,因此你的代码无需更改。4

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件