Skip to content
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

problem building some programs on musl #1361

Open
sever2806 opened this issue Apr 25, 2019 · 11 comments · Fixed by #1449
Open

problem building some programs on musl #1361

sever2806 opened this issue Apr 25, 2019 · 11 comments · Fixed by #1449

Comments

@sever2806
Copy link

sever2806 commented Apr 25, 2019

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`
@Arcterus
Copy link
Collaborator

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

@Ecordonnier
Copy link
Contributor

Ecordonnier commented Apr 6, 2023

I reported the issue to the libc crate: rust-lang/libc#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``

@tertsdiepraam
Copy link
Member

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.

@Ecordonnier
Copy link
Contributor

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.

@tertsdiepraam tertsdiepraam reopened this Apr 7, 2023
@rivy
Copy link
Member

rivy commented Apr 9, 2023

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 rivy self-assigned this Apr 9, 2023
@rivy
Copy link
Member

rivy commented Apr 9, 2023

[...] 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!

@Ecordonnier
Copy link
Contributor

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).

@tertsdiepraam
Copy link
Member

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

@Ecordonnier
Copy link
Contributor

@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.

@tertsdiepraam
Copy link
Member

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

@Ecordonnier
Copy link
Contributor

Ecordonnier commented Jan 11, 2024

The required functions were added to libc ( rust-lang/libc@e3caaf6 ), however those changes will be available via cargo only once libc 0.3 is released ( rust-lang/libc#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 rust-lang/libc#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: rust-lang/libc#3248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants