ESC
开源 4 分钟阅读

Libghostty 1.0 发布,终端库实现 ABI 稳定性和多语言绑定

Libghostty 1.0 发布,提供稳定的 ABI、丰富的语言绑定,终端使用 libghostty 的人数超过 Ghostty 应用本身,支持多种平台,许可为 MIT。

来源:Hacker News

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

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.

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

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.

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.

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

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

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.

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.

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:

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:

Each of the tested platforms gets the artifacts it expects:

Portability isn’t just about the ability to build and run. It’s also about resource usage and being able to work in a wide variety of resource environments.

For resource usage, the library creates no threads, allocates only through an allocator you can customize, and uses minimal compute and memory. I’ve run 10,000 active terminals, each with a live shell producing output, on a Linux server with 4 cores and 8 GB of RAM. In this test, I had to use dash because bash used far more RAM than libghostty-vt and wouldn’t fit into the 8 GB budget.

You can now create a terminal in ~1,500 lines of C that has more features and better performance than just about any terminal that existed in 2025, and most today in 2026.5 And thanks to the rich ecosystem of language bindings, you can do this in every major programming language. You get this for free. For almost no effort. You can just do it.

libghostty-vt is a generalized library, so we will focus on stability while implementing as many terminal protocols as exist (giving options to enable/disable them, of course) so that embedders have the luxury of choice.