coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

problem building some programs on musl

Open sever2806 opened this issue 5 years ago • 11 comments

cabulertion. i had problem while building uutils on musl namely i am getting errors :

error[E0432]: unresolved import `libc::utmpx`
  --> src/uucore/utmpx.rs:44:5
   |
44 | use libc::utmpx;
   |     ^^^^^^^^^^^ no `utmpx` in the root

error[E0432]: unresolved import `libc::getutxent`
  --> src/uucore/utmpx.rs:48:9
   |
48 | pub use libc::getutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `getgrent`
   |         no `getutxent` in the root

error[E0432]: unresolved import `libc::setutxent`
  --> src/uucore/utmpx.rs:49:9
   |
49 | pub use libc::setutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `setgrent`
   |         no `setutxent` in the root

error[E0432]: unresolved import `libc::endutxent`
  --> src/uucore/utmpx.rs:50:9
   |
50 | pub use libc::endutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `endmntent`
   |         no `endutxent` in the root

error[E0432]: unresolved import `libc::utmpxname`
  --> src/uucore/utmpx.rs:52:9
   |
52 | pub use libc::utmpxname;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `tmpnam`
   |         no `utmpxname` in the root

error[E0432]: unresolved import `libc::__UT_LINESIZE`
  --> src/uucore/utmpx.rs:69:13
   |
69 |     pub use libc::__UT_LINESIZE as UT_LINESIZE;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__UT_LINESIZE` in the root

error[E0432]: unresolved import `libc::__UT_NAMESIZE`

sever2806 avatar Apr 25 '19 00:04 sever2806

This might just be due to an out-of-date libc or something. I'll take a look.

Arcterus avatar Apr 28 '19 03:04 Arcterus

I reported the issue to the libc crate: https://github.com/rust-lang/libc/issues/3190 This can still be reproduced with version 0.0.18, so I think this ticket should be reopened:

$ rustup target add x86_64-unknown-linux-musl
$ cargo build -p uu_users --target=x86_64-unknown-linux-musl
...
13 | use uucore::utmpx::{self, time, Utmpx};
   |             ^^^^^   ^^^^ no utmpx in the root
   |             |
   |             could not find utmpx in uucore``

Ecordonnier avatar Apr 06 '23 19:04 Ecordonnier

Looks like a slightly different issue right? Could you make a new one? On our side, we should probably disable that functionality for the time being.

tertsdiepraam avatar Apr 06 '23 21:04 tertsdiepraam

As far as I understand, the issue is almost the same. This ticket was worked-around with this commit , so now instead of uucore failing and producing the logs in this ticket, the utilities which depend on uucore's utmpx functionality are failing when building for musl. The proper long-term fix is to implement the functionality on libc's side, which I'll try to work on.

Ecordonnier avatar Apr 06 '23 22:04 Ecordonnier

I'd probably call this more of a platform support documentation issue than a coding bug.

I can add some compiler_error!() code based on platform or a proc_macro testing for module functionality that returns a more obvious error message for the utilities that are platform-limited. Maybe something like "Unsupported; platform ('...') is missing required 'utmpx' support" as a compiler error.

rivy avatar Apr 09 '23 13:04 rivy

[...] The proper long-term fix is to implement the functionality on libc's side, which I'll try to work on.

That's a big hill to climb; I wish you luck!

rivy avatar Apr 09 '23 15:04 rivy

I investigated this further, and while the utmpx functions are exported by musl in a header-file, those are only stub implementations doing nothing. I'll try to improve the build errors, but compiling e.g. the utility "users" using musl stubs doesn't really make sense, because while it would compile, it would produce a runtime error (this explains why only stubs are provided).

Ecordonnier avatar May 01 '23 21:05 Ecordonnier

@Ecordonnier Just checking in here. I see that https://github.com/rust-lang/libc/issues/3190 and https://github.com/rust-lang/libc/pull/3213 are still open. Should we poll there to see if we can get them merged?

tertsdiepraam avatar Aug 19 '23 10:08 tertsdiepraam

@tertsdiepraam I'm not very familiar with the rust libc project, but my understanding is that this PR is changing the API and therefore tagged as "breakage-candidate" so that it can be merged when they do a release with non-backwards-compatible API. I asked them for confirmation in the PR.

Ecordonnier avatar Aug 19 '23 13:08 Ecordonnier

Interesting! I'll subscribe to the PR. Thanks!

tertsdiepraam avatar Aug 19 '23 13:08 tertsdiepraam

The required functions were added to libc ( https://github.com/rust-lang/libc/commit/e3caaf6b0ea08ae294e25a861022c256a7535ec4 ), however those changes will be available via cargo only once libc 0.3 is released ( https://github.com/rust-lang/libc/issues/3248 ). The main branch of libc is now used for the development of 0.3, and the version 0.2 is developed on the branch libc-0.2 (and hence the libc release 0.2.152 does NOT contain e3caaf6b0ea08a ). The release of libc 0.3 is tracked at https://github.com/rust-lang/libc/issues/3248 (it will probably take a while).

Edit May 2024: The status is still the same. libc version 1.0 will be needed in order to fix this, and this will probably take at least several months: https://github.com/rust-lang/libc/issues/3248

Ecordonnier avatar Jan 11 '24 14:01 Ecordonnier