From 3849ee5d4c1f2ce01cb6873a19d9479911e66671 Mon Sep 17 00:00:00 2001 From: sorathpanzer Date: Sat, 13 Dec 2025 21:38:01 +0000 Subject: [PATCH 1/2] openbsd: fix build --- Cargo.toml | 2 +- yazi-fm/Cargo.toml | 2 +- yazi-fm/src/main.rs | 2 +- yazi-fs/src/provider/local/casefold.rs | 6 +++++- yazi-plugin/src/process/command.rs | 22 +++++++++++++++++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1988d1c92..b34bc6809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ default-members = [ "yazi-fm", "yazi-cli" ] [profile.release] codegen-units = 1 -lto = true +lto = false panic = "abort" strip = true diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 3968ab5ad..f4c9aceff 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -69,7 +69,7 @@ signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ] } [target.'cfg(target_os = "macos")'.dependencies] crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } -[target.'cfg(all(not(target_os = "macos"), not(target_os = "windows")))'.dependencies] +[target.'cfg(all(not(target_os = "macos"), not(target_os = "windows"), not(target_os = "openbsd")))'.dependencies] tikv-jemallocator = "0.6.1" [[bin]] diff --git a/yazi-fm/src/main.rs b/yazi-fm/src/main.rs index 6f7f0153f..9d65d0cba 100644 --- a/yazi-fm/src/main.rs +++ b/yazi-fm/src/main.rs @@ -1,4 +1,4 @@ -#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))] +#[cfg(all(not(target_os = "macos"), not(target_os = "windows"), not(target_os = "openbsd")))] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; diff --git a/yazi-fs/src/provider/local/casefold.rs b/yazi-fs/src/provider/local/casefold.rs index dc576e341..d5ba6dbd9 100644 --- a/yazi-fs/src/provider/local/casefold.rs +++ b/yazi-fs/src/provider/local/casefold.rs @@ -100,7 +100,6 @@ fn casefold_impl(path: PathBuf) -> io::Result { #[cfg(any( target_os = "macos", target_os = "netbsd", - target_os = "openbsd", target_os = "freebsd" ))] fn final_path(path: &Path) -> io::Result { @@ -123,6 +122,11 @@ fn final_path(path: &Path) -> io::Result { Ok(OsString::from_vec(cstr.to_bytes().to_vec()).into()) } +#[cfg(target_os = "openbsd")] +fn final_path(path: &Path) -> io::Result { + std::fs::canonicalize(path) +} + #[cfg(target_os = "windows")] fn final_path(path: &Path) -> io::Result { use std::{ffi::OsString, fs::File, os::windows::{ffi::OsStringExt, fs::OpenOptionsExt, io::AsRawHandle}}; diff --git a/yazi-plugin/src/process/command.rs b/yazi-plugin/src/process/command.rs index 67d4b3d4c..63ce2a23f 100644 --- a/yazi-plugin/src/process/command.rs +++ b/yazi-plugin/src/process/command.rs @@ -38,7 +38,12 @@ impl Command { lua.globals().raw_set("Command", command) } - #[cfg(unix)] + #[cfg(any( + target_os = "macos", + target_os = "netbsd", + target_os = "linux", + target_os = "freebsd" + ))] fn spawn(&mut self) -> io::Result { if let Some(max) = self.memory { unsafe { @@ -51,6 +56,21 @@ impl Command { } self.inner.spawn().map(Child::new) } + + #[cfg(target_os = "openbsd")] + fn spawn(&mut self) -> io::Result { + if let Some(max) = self.memory { + unsafe { + self.inner.pre_exec(move || { + let rlp = libc::rlimit { rlim_cur: max as _, rlim_max: max as _ }; + #[cfg(target_os = "openbsd")] + libc::setrlimit(libc::RLIMIT_DATA, &rlp); + Ok(()) + }); + } + } + self.inner.spawn().map(Child::new) + } #[cfg(windows)] fn spawn(&mut self) -> io::Result { From 4e6b05f71c542fe09731b7af308d3ad9a723d0c4 Mon Sep 17 00:00:00 2001 From: sorathpanzer Date: Sun, 14 Dec 2025 15:21:16 +0000 Subject: [PATCH 2/2] Revert OpenBSD LTO change as requested --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b34bc6809..1988d1c92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ default-members = [ "yazi-fm", "yazi-cli" ] [profile.release] codegen-units = 1 -lto = false +lto = true panic = "abort" strip = true