Skip to content

enable utmpx feature for musl #7740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2025

Conversation

Ecordonnier
Copy link
Contributor

@Ecordonnier Ecordonnier commented Apr 12, 2025

musl provides stubs of the utmpx functions, and those stubs are provided in the libc crate version 0.2.172. Thus let's enable the feature so that it can compile with musl. Note that those stubs always return a success exit value, and commands such as "users" will report an empty list of users, when calling those stubs.

This is consistent with the behavior of GNU coreutils which does the same thing.

The coreutils utillities using utmpx are "pinky", "uptime", "users", "who". This is the expected behavior when using those utilities compiled with those musl utmpx stubs:

root@qemuarm64:~# users
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# pinky
Login    Name                 TTY      Idle   When         Where
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# uptime
 12:58:47 up 0 min,  0 users,  load average: 0.07, 0.02, 0.00
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# who
root@qemuarm64:~# echo $?
0

Closes #1361

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from cc6a852 to 179d60f Compare April 12, 2025 18:35
@Ecordonnier Ecordonnier marked this pull request as draft April 12, 2025 18:37
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@cakebaker cakebaker force-pushed the eco/enable-utmpx-for-musl branch from 179d60f to 0060e1c Compare April 15, 2025 07:13
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/misc/sleep is no longer failing!

@Ecordonnier Ecordonnier changed the title enable utmpx feature for musl (MERGEABLE ONLY AFTER LIBC 0.2.172 IS RELEASED) enable utmpx feature for musl Apr 15, 2025
@Ecordonnier
Copy link
Contributor Author

I'll check the test failure. I can reproduce locally with cargo test --features "uptime" --no-default-features --target=x86_64-unknown-linux-musl.

@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from 0060e1c to fa03130 Compare April 15, 2025 09:21
@Ecordonnier
Copy link
Contributor Author

Ecordonnier commented Apr 15, 2025

I'd like to emphasize the trade-off of this PR:

  • pro: this will provide full compatibility with GNU coreutils compiled with musl, and the utilities like uptime etc. will have the same behavior in uutils-coreutils and GNU coreutils when compiled with musl, following the high-level goal of providing a drop-in replacement. I have taken take of adding a note in the usage text of the impacted utilities.

  • con: this will allow utilities like "users" to be shipped with a behavior which may not be expected by end-users, and will have the same behavior than what may be considered a bug in GNU coreutils.

@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from e718696 to d09a756 Compare April 15, 2025 10:03
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@Ecordonnier Ecordonnier marked this pull request as ready for review April 15, 2025 10:47
bump libc to 0.2.172

musl provides stubs of utmpx functions, and those stubs are available in the
libc crate version 0.2.172. Thus let's enable the feature so that it can
compile with musl.  Note that those stubs always return a success exit value,
and commands such as "users" will report an empty list of users, when calling
those stubs.

This is consistent with the behavior of GNU coreutils which does the same thing.

The coreutils utillities using utmpx are "pinky", "uptime", "users", "who".
This is the expected behavior when using those utilities compiled with those musl utmpx stubs:
```
root@qemuarm64:~# users
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# pinky
Login    Name                 TTY      Idle   When         Where
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# uptime
 12:58:47 up 0 min,  0 users,  load average: 0.07, 0.02, 0.00
root@qemuarm64:~# echo $?
0
root@qemuarm64:~# who
root@qemuarm64:~# echo $?
0
```

Closes uutils#1361

Signed-off-by: Etienne Cordonnier <[email protected]>
After the addition of utmpx, feat_os_unix_musl is now identical to feat_os_unix and is thus not needed any more.

Signed-off-by: Etienne Cordonnier <[email protected]>
musl libc only provides stub functions for utmpx, thus this test cannot pass with musl libc.

Signed-off-by: Etienne Cordonnier <[email protected]>
@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from d09a756 to 0692a29 Compare April 15, 2025 10:52
@Ecordonnier
Copy link
Contributor Author

Ecordonnier commented Apr 15, 2025

I think the failure of test_follow_when_files_are_pointing_to_same_relative_file_and_file_stays_same_size is a race-condition unrelated to this PR. It is the same failure than in this unrelated PR: https://github.com/uutils/coreutils/actions/runs/14447059105/job/40510610531?pr=7616

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from 0692a29 to 1ec4478 Compare April 15, 2025 13:05
@Ecordonnier Ecordonnier force-pushed the eco/enable-utmpx-for-musl branch from 1ec4478 to bc8acbb Compare April 15, 2025 13:16
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre requested a review from tertsdiepraam April 17, 2025 15:59
@tertsdiepraam tertsdiepraam merged commit d99b7b3 into uutils:main Apr 17, 2025
70 checks passed
@Ecordonnier Ecordonnier deleted the eco/enable-utmpx-for-musl branch April 17, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

problem building some programs on musl
2 participants