diff --git a/Cargo.toml b/Cargo.toml index 6b646b58359..f019bb66421 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -390,9 +390,11 @@ runcon = { optional = true, version = "0.13.0", package = "uu_runcon", path = "s # Not needed for now. Keep as examples: #pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`) +[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dev-dependencies] +rlimit = { workspace = true } + [target.'cfg(unix)'.dev-dependencies] nix = { workspace = true, features = ["fs", "signal"] } -rlimit = { workspace = true } rustix = { workspace = true, features = ["net", "process"] } [build-dependencies] diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 42005948226..16f3882d5c4 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -39,13 +39,15 @@ uucore = { workspace = true, features = [ [target.'cfg(all(unix, not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku", target_os = "solaris", target_os = "illumos"))))'.dependencies] rustix = { workspace = true, features = ["fs", "system", "process"] } +[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] +rlimit = { workspace = true } + [target.'cfg(not(any(target_os = "redox", target_os = "wasi")))'.dependencies] ctrlc = { workspace = true } [target.'cfg(unix)'.dependencies] libc = { workspace = true } rustix = { workspace = true, features = ["fs"] } -rlimit = { workspace = true } [dev-dependencies] divan = { workspace = true } diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 8a80d585946..2eac8f51bd8 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1529,7 +1529,7 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: String) -> Arg { .action(ArgAction::SetTrue) } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] fn get_rlimit() -> UResult { use rlimit::{Resource, getrlimit}; @@ -1540,12 +1540,12 @@ fn get_rlimit() -> UResult { .map_err(|_| UUsageError::new(2, translate!("sort-failed-fetch-rlimit"))) } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] pub(crate) fn fd_soft_limit() -> Option { get_rlimit().ok() } -#[cfg(not(unix))] +#[cfg(not(all(unix, not(target_os = "fuchsia"))))] pub(crate) fn fd_soft_limit() -> Option { None } diff --git a/tests/uutests/Cargo.toml b/tests/uutests/Cargo.toml index 36ba7a39bc7..b027db5cbaf 100644 --- a/tests/uutests/Cargo.toml +++ b/tests/uutests/Cargo.toml @@ -33,11 +33,13 @@ uucore = { workspace = true, features = [ "utmpx", ] } +[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] +rlimit = { workspace = true } + [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] [target.'cfg(unix)'.dependencies] nix = { workspace = true, features = ["fs", "term"] } -rlimit = { workspace = true } rustix = { workspace = true, features = ["pty", "termios"] } [target.'cfg(any(target_os = "freebsd", target_os = "hurd", target_os = "linux", target_os = "android", target_os = "netbsd"))'.dependencies] diff --git a/tests/uutests/src/lib/util.rs b/tests/uutests/src/lib/util.rs index 25db32151de..598614874fb 100644 --- a/tests/uutests/src/lib/util.rs +++ b/tests/uutests/src/lib/util.rs @@ -24,7 +24,7 @@ use nix::sys; #[cfg(not(windows))] use nix::sys::stat::{self, SFlag}; use pretty_assertions::assert_eq; -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "fuchsia")))] use rlimit::{Resource, setrlimit}; use std::borrow::Cow; use std::collections::{BTreeMap, VecDeque}; @@ -1562,7 +1562,7 @@ pub struct UCommand { stdout: Option, stderr: Option, bytes_into_stdin: Option>, - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "fuchsia")))] limits: Vec<(Resource, u64, u64)>, #[cfg(unix)] ignore_sigxfsz: bool, @@ -1727,7 +1727,7 @@ impl UCommand { self } - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "fuchsia")))] pub fn limit(&mut self, resource: Resource, soft_limit: u64, hard_limit: u64) -> &mut Self { self.limits.push((resource, soft_limit, hard_limit)); self @@ -2086,7 +2086,7 @@ impl UCommand { } } - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "fuchsia")))] if !self.limits.is_empty() { // just to be safe: move a copy of the limits list into the closure. // this way the closure is fully self-contained. @@ -3768,7 +3768,7 @@ mod tests { .stdout_is("unlimited\nunlimited\n"); } - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "fuchsia")))] #[test] fn test_application_of_process_resource_limits_limited_file_size() { let unit_size_bytes = if cfg!(target_vendor = "apple") {