fix(os,termio): FreeBSD support, dev-profile resource precedence, docs

Final fix pass per the stopping criterion (docs/rewrite/PLAN.md),
resolving the remaining RV18 build/behaviour items (final-Z21.md):
- termio errno access uses the per-target libc accessor (__error on
  FreeBSD/DragonFly/Apple, __errno on OpenBSD/NetBSD/Android) instead of
  __errno_location everywhere, unblocking non-Linux BSD builds.
- FreeBSD resource discovery follows Zig (site-terminfo, local/share).
- Zig's Debug-only resource precedence (and the dev workspace-resources
  fallback) key off a ghostty_debug_build cfg set from PROFILE=="debug"
  instead of debug_assertions, so release builds with assertions honor
  GHOSTTY_RESOURCES_DIR first like Zig ReleaseSafe.
- KNOWN_DIFFERENCES.md lists the remaining P3 differences deliberately
  left unfixed (theme-preview editing details, a cleanup timeout edge
  case) and what cannot be verified on this machine.
- DEVIANT_FIXES.md registers the PTY-hangup output drain (35), the
  canvas BGRA conversion (36) and the dev resources fallback.

Test Plan:
- cargo test --workspace --no-fail-fast (exit 0)
- cargo check --target x86_64-unknown-freebsd -p ghostty-os
This commit is contained in:
ddidderr committed 2026-10-12 16:53:27 +02:00
1 parent c126ae873d
commit 4fa55855e8
6 files changed
+83 -7

No files matched your search

+16 -5
View File
@@ -48,9 +48,13 @@ impl ResourcesDir {
/// Sentinels we look for in the path to know we've found the resources
/// directory (Linux).
#[cfg(not(any(windows, target_os = "macos")))]
#[cfg(not(any(windows, target_os = "macos", target_os = "freebsd")))]
const SENTINELS: [&str; 2] = ["terminfo/g/ghostty", "terminfo/x/xterm-ghostty"];
/// Sentinels on FreeBSD (`site-terminfo`, like Zig).
#[cfg(target_os = "freebsd")]
const SENTINELS: [&str; 2] = ["site-terminfo/g/ghostty", "site-terminfo/x/xterm-ghostty"];
/// Sentinel on macOS (terminfo directories are named by hex there).
#[cfg(target_os = "macos")]
const SENTINELS: [&str; 1] = ["terminfo/78/xterm-ghostty"];
@@ -66,12 +70,14 @@ const DEV_SENTINELS: [&str; 1] = ["terminfo/x/xterm-ghostty"];
/// Gets the directory to the bundled resources directory, if it
/// exists (not all platforms or packages have it).
///
/// Zig's `builtin.mode == .Debug` is mapped to `cfg!(debug_assertions)`.
/// Zig's `builtin.mode == .Debug` is mapped to the Cargo `dev` profile
/// (`cfg(ghostty_debug_build)`, set by `build.rs`), not to `debug_assertions`:
/// the repository's `release` profile enables assertions like ReleaseSafe.
pub fn resources_dir() -> io::Result<ResourcesDir> {
let exe = std::env::current_exe().ok();
let env = std::env::var_os("GHOSTTY_RESOURCES_DIR");
Ok(resources_dir_impl(
cfg!(debug_assertions),
cfg!(ghostty_debug_build),
exe.as_deref(),
env,
))
@@ -112,9 +118,14 @@ fn resources_dir_impl(debug: bool, exe: Option<&Path>, env: Option<OsString>) ->
}
}
// We look for a /usr/share style path.
// We look for a /usr/share style path (/usr/local/share on FreeBSD).
let share = if cfg!(target_os = "freebsd") {
"local/share"
} else {
"share"
};
for sentinel in SENTINELS {
if let Some(v) = maybe_dir_os(dir, "share", sentinel) {
if let Some(v) = maybe_dir_os(dir, share, sentinel) {
return ResourcesDir {
app_path: Some(enc(&v.join("ghostty"))),
host_path: None,