From cd0a52cf00a508476574d94f66b0841387df1631 Mon Sep 17 00:00:00 2001 From: nibon7 Date: Tue, 19 Dec 2023 22:58:45 +0800 Subject: [PATCH] Fix build for BSDs (#11372) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR fixes build for BSD variants (including FreeBSD and NetBSD). Currently, `procfs` only support linux, android and l4re, and 0cba269d80953bc391070bdc8e878d276ecd1180 only adds support for NetBSD, this PR should work on all BSD variants. https://github.com/eminence/procfs/blob/b153b782a5957aa619ed744d0ac8bbe4734601ed/procfs/build.rs#L4-L8 Fixes #11373 # User-Facing Changes * before ```console nibon7@fbsd /d/s/nushell ((70f7db14))> cargo build Compiling tempfile v3.8.1 Compiling procfs v0.16.0 Compiling toml_edit v0.21.0 Compiling native-tls v0.2.11 error: failed to run custom build command for `procfs v0.16.0` Caused by: process didn't exit successfully: `/data/source/nushell/target/debug/build/procfs-d59599f40f32f0d5/build-script-build` (exit status: 1) --- stderr Building procfs on an for a unsupported platform. Currently only linux and android are supported (Your current target_os is freebsd) warning: build failed, waiting for other jobs to finish... ``` * after ```console nushell on  bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1 ❯ version ╭────────────────────┬───────────────────────────────────────────╮ │ version │ 0.88.2 │ │ branch │ bsd │ │ commit_hash │ 151edef186470e454367ac6e4b2178188062c1f9 │ │ build_os │ freebsd-x86_64 │ │ build_target │ x86_64-unknown-freebsd │ │ rust_version │ rustc 1.74.1 (a28077b28 2023-12-04) │ │ rust_channel │ stable-x86_64-unknown-freebsd │ │ cargo_version │ cargo 1.74.1 (ecb9851af 2023-10-18) │ │ build_time │ 2023-12-19 10:12:15 +00:00 │ │ build_rust_channel │ debug │ │ allocator │ mimalloc │ │ features │ default, extra, sqlite, trash, which, zip │ │ installed_plugins │ │ ╰────────────────────┴───────────────────────────────────────────╯ nushell on  bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1 ❯ cargo test --workspace commands::ulimit e>> /dev/null | rg ulimit test commands::ulimit::limit_set_filesize2 ... ok test commands::ulimit::limit_set_filesize1 ... ok test commands::ulimit::limit_set_hard1 ... ok test commands::ulimit::limit_set_hard2 ... ok test commands::ulimit::limit_set_invalid1 ... ok test commands::ulimit::limit_set_invalid3 ... ok test commands::ulimit::limit_set_invalid4 ... ok test commands::ulimit::limit_set_invalid5 ... ok test commands::ulimit::limit_set_soft2 ... ok test commands::ulimit::limit_set_soft1 ... ok nushell on  bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1 ``` # Tests + Formatting # After Submitting --- crates/nu-command/Cargo.toml | 2 +- crates/nu-command/src/platform/ulimit.rs | 2 +- crates/nu-command/src/system/ps.rs | 6 ------ crates/nu-command/tests/commands/ulimit.rs | 1 + 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 5be2783d30..bd6b1d3932 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -106,7 +106,7 @@ libc = "0.2" umask = "2.1" nix = { version = "0.27", default-features = false, features = ["user", "resource"] } -[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android"), not(target_os = "ios"), not(target_os = "netbsd")))'.dependencies] +[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] procfs = "0.16.0" [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies.trash] diff --git a/crates/nu-command/src/platform/ulimit.rs b/crates/nu-command/src/platform/ulimit.rs index e3ec3f3130..41ab374523 100644 --- a/crates/nu-command/src/platform/ulimit.rs +++ b/crates/nu-command/src/platform/ulimit.rs @@ -233,7 +233,7 @@ static RESOURCE_ARRAY: Lazy> = Lazy::new(|| { "Maximum number of pseudo-terminals", 'P', 1, - Resource::RLIMIT_NPTY, + Resource::RLIMIT_NPTS, ), ]; diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index 730f6779cb..ab358b4078 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -5,8 +5,6 @@ use itertools::Itertools; not(target_os = "macos"), not(target_os = "windows"), not(target_os = "android"), - not(target_os = "ios"), - not(target_os = "netbsd") ))] use nu_protocol::Span; use nu_protocol::{ @@ -20,8 +18,6 @@ use nu_protocol::{ not(target_os = "macos"), not(target_os = "windows"), not(target_os = "android"), - not(target_os = "ios"), - not(target_os = "netbsd") ))] use procfs::WithCurrentSystemInfo; @@ -125,8 +121,6 @@ fn run_ps(engine_state: &EngineState, call: &Call) -> Result