Improve FreeBSD support (#33162)

This PR contains a set of changes for improving FreeBSD support (#15309,
#29550) and is a kind of follow up to the PR #20480 which added an
initial support for FreeBSD.

A summary of changes is as follows:
- Add some more freebsd conditionals which seem missing in the previous
PR.
- Implement `anonymous_fd()` and `current_path()` functions for FreeBSD.
- Improve detection of FreeBSD in telemetry and GPU detection.
- Temporarily disable LiveKit/WebRTC support to make build succeed.
- Remove support for flatpak since it is Linux-only packaging format.

Adding `RUSTFLAGS="-C link-dead-code"` does not seem necessary anymore.
It builds fine without the flag.

Known issues:
- Integrated terminal is painfully laggy and virtually unusable in my
environment. This might be specific to my setup.
- I cannot input Japanese using IME. When I type characters, they appear
on the screen. But when I hit return key, they disappears. Seems the
same issue as #15409.

My environment is MATE desktop on X11 on FreeBSD 14.2 on Intel Core
i5-7260U integrated graphics.

P.S. For those who might be interested, a work-in-progress FreeBSD port
and binary packages are available at
https://github.com/tagattie/FreeBSD-Zed

Release Notes:

- N/A

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
Hiroki Tagato 2025-06-23 05:23:17 +09:00 committed by GitHub
parent 6b4c607331
commit ac30a8b0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 50 additions and 18 deletions

View file

@ -134,7 +134,7 @@ fn main() -> Result<()> {
util::prevent_root_execution();
// Exit flatpak sandbox if needed
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "linux")]
{
flatpak::try_restart_to_host();
flatpak::ld_extra_libs();
@ -158,7 +158,7 @@ fn main() -> Result<()> {
paths::set_custom_data_dir(dir);
}
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "linux")]
let args = flatpak::set_bin_if_no_escape(args);
let app = Detect::detect(args.zed.as_deref()).context("Bundle detection")?;
@ -374,7 +374,7 @@ fn anonymous_fd(path: &str) -> Option<fs::File> {
let file = unsafe { fs::File::from_raw_fd(fd) };
return Some(file);
}
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
{
use std::os::{
fd::{self, FromRawFd},
@ -392,7 +392,7 @@ fn anonymous_fd(path: &str) -> Option<fs::File> {
let file = unsafe { fs::File::from_raw_fd(fd) };
return Some(file);
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))]
{
_ = path;
// not implemented for bsd, windows. Could be, but isn't yet
@ -537,7 +537,7 @@ mod linux {
}
}
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_os = "linux")]
mod flatpak {
use std::ffi::OsString;
use std::path::PathBuf;