Skip to content

Commit d99b7b3

Browse files
Merge pull request #7740 from Ecordonnier/eco/enable-utmpx-for-musl
enable utmpx feature for musl
2 parents da351d2 + bc8acbb commit d99b7b3

File tree

9 files changed

+47
-15
lines changed

9 files changed

+47
-15
lines changed

.github/workflows/CICD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,13 @@ jobs:
516516
# - { os , target , cargo-options , features , use-cross , toolchain, skip-tests, workspace-tests }
517517
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross , skip-tests: true }
518518
- { os: ubuntu-24.04-arm , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf }
519-
- { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
519+
- { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross , skip-tests: true }
520520
# - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_selinux , use-cross: use-cross }
521521
- { os: ubuntu-latest , target: i686-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
522-
- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
522+
- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross }
523523
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
524524
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,uudoc" , use-cross: no, workspace-tests: true }
525-
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
525+
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross }
526526
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true }
527527
- { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos, workspace-tests: true } # M1 CPU
528528
- { os: macos-13 , target: x86_64-apple-darwin , features: feat_os_macos, workspace-tests: true }

Cargo.toml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ feat_os_macos = [
150150
#
151151
"feat_require_unix_hostid",
152152
]
153-
# "feat_os_unix" == set of utilities which can be built/run on modern/usual *nix platforms
153+
# "feat_os_unix" == set of utilities which can be built/run on modern/usual *nix platforms.
154+
# Also used for targets binding to the "musl" library (ref: <https://musl.libc.org/about.html>)
154155
feat_os_unix = [
155156
"feat_Tier1",
156157
#
@@ -172,14 +173,6 @@ feat_os_unix_gnueabihf = [
172173
"feat_require_unix_hostid",
173174
"feat_require_unix_utmpx",
174175
]
175-
# "feat_os_unix_musl" == set of utilities which can be built/run on targets binding to the "musl" library (ref: <https://musl.libc.org/about.html>)
176-
feat_os_unix_musl = [
177-
"feat_Tier1",
178-
#
179-
"feat_require_crate_cpp",
180-
"feat_require_unix",
181-
"feat_require_unix_hostid",
182-
]
183176
feat_os_unix_android = [
184177
"feat_Tier1",
185178
#
@@ -309,7 +302,7 @@ hostname = "0.4"
309302
iana-time-zone = "0.1.57"
310303
indicatif = "0.17.8"
311304
itertools = "0.14.0"
312-
libc = "0.2.153"
305+
libc = "0.2.172"
313306
linux-raw-sys = "0.9"
314307
lscolors = { version = "0.20.0", default-features = false, features = [
315308
"gnu_legacy",

src/uu/pinky/src/pinky.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ use uucore::{format_usage, help_about, help_usage};
1010

1111
mod platform;
1212

13+
#[cfg(target_env = "musl")]
14+
const ABOUT: &str = concat!(
15+
help_about!("pinky.md"),
16+
"\n\nWarning: When built with musl libc, the `pinky` utility may show incomplete \n",
17+
"or missing user information due to musl's stub implementation of `utmpx` \n",
18+
"functions. This limitation affects the ability to retrieve accurate details \n",
19+
"about logged-in users."
20+
);
21+
22+
#[cfg(not(target_env = "musl"))]
1323
const ABOUT: &str = help_about!("pinky.md");
24+
1425
const USAGE: &str = help_usage!("pinky.md");
1526

1627
mod options {

src/uu/uptime/src/uptime.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ use uucore::{format_usage, help_about, help_usage};
2323
#[cfg(not(target_os = "openbsd"))]
2424
use uucore::utmpx::*;
2525

26+
#[cfg(target_env = "musl")]
27+
const ABOUT: &str = concat!(
28+
help_about!("uptime.md"),
29+
"\n\nWarning: When built with musl libc, the `uptime` utility may show '0 users' \n",
30+
"due to musl's stub implementation of utmpx functions. Boot time and load averages \n",
31+
"are still calculated using alternative mechanisms."
32+
);
33+
34+
#[cfg(not(target_env = "musl"))]
2635
const ABOUT: &str = help_about!("uptime.md");
36+
2737
const USAGE: &str = help_usage!("uptime.md");
2838
pub mod options {
2939
pub static SINCE: &str = "since";

src/uu/users/src/users.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ use utmp_classic::{UtmpEntry, parse_from_path};
1818
#[cfg(not(target_os = "openbsd"))]
1919
use uucore::utmpx::{self, Utmpx};
2020

21+
#[cfg(target_env = "musl")]
22+
const ABOUT: &str = concat!(
23+
help_about!("users.md"),
24+
"\n\nWarning: When built with musl libc, the `users` utility may show '0 users' \n",
25+
"due to musl's stub implementation of utmpx functions."
26+
);
27+
28+
#[cfg(not(target_env = "musl"))]
2129
const ABOUT: &str = help_about!("users.md");
30+
2231
const USAGE: &str = help_usage!("users.md");
2332

2433
#[cfg(target_os = "openbsd")]

src/uu/who/src/who.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ mod options {
2828
pub const FILE: &str = "FILE"; // if length=1: FILE, if length=2: ARG1 ARG2
2929
}
3030

31+
#[cfg(target_env = "musl")]
32+
const ABOUT: &str = concat!(
33+
help_about!("who.md"),
34+
"\n\nNote: When built with musl libc, the `who` utility will not display any \n",
35+
"information about logged-in users. This is due to musl's stub implementation \n",
36+
"of `utmpx` functions, which prevents access to the necessary data."
37+
);
38+
39+
#[cfg(not(target_env = "musl"))]
3140
const ABOUT: &str = help_about!("who.md");
41+
3242
const USAGE: &str = help_usage!("who.md");
3343

3444
#[cfg(target_os = "linux")]

src/uucore/src/lib/features.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pub mod signals;
7676
not(target_os = "fuchsia"),
7777
not(target_os = "openbsd"),
7878
not(target_os = "redox"),
79-
not(target_env = "musl"),
8079
feature = "utmpx"
8180
))]
8281
pub mod utmpx;

src/uucore/src/lib/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub use crate::features::signals;
8989
not(target_os = "fuchsia"),
9090
not(target_os = "openbsd"),
9191
not(target_os = "redox"),
92-
not(target_env = "musl"),
9392
feature = "utmpx"
9493
))]
9594
pub use crate::features::utmpx;

tests/by-util/test_uptime.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ fn test_uptime_with_non_existent_file() {
103103
// This will pass
104104
#[test]
105105
#[cfg(not(any(target_os = "openbsd", target_os = "macos")))]
106+
#[cfg(not(target_env = "musl"))]
106107
#[cfg_attr(
107108
all(target_arch = "aarch64", target_os = "linux"),
108109
ignore = "Issue #7159 - Test not supported on ARM64 Linux"

0 commit comments

Comments
 (0)