rust-lang / jobserver-rs

Apache License 2.0
69 stars 39 forks source link

0.1.29 doesn't build against musl libc. #79

Closed sfackler closed 4 months ago

sfackler commented 4 months ago

For example, building in an alpine container:

6.767 error[E0425]: cannot find function `preadv2` in crate `libc`
6.767     --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/jobserver-0.1.29/src/unix.rs:598:15
6.767      |
6.767 598  |           libc::preadv2(
6.767      |                 ^^^^^^^ help: a function with a similar name exists: `preadv`
6.767      |
6.767     ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.153/src/unix/linux_like/linux/mod.rs:4868:13
6.767      |
6.767 4868 | /             pub fn preadv(
6.767 4869 | |                 fd: ::c_int,
6.767 4870 | |                 iov: *const ::iovec,
6.767 4871 | |                 iovcnt: ::c_int,
6.767 4872 | |                 offset: ::off_t,
6.767 4873 | |             ) -> ::ssize_t;
6.767      | |__________________________- similarly named function `preadv` defined here
6.767
6.768 error[E0425]: cannot find value `RWF_NOWAIT` in crate `libc`
6.768     --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/jobserver-0.1.29/src/unix.rs:606:19
6.768      |
6.768 606  |             libc::RWF_NOWAIT,
6.768      |                   ^^^^^^^^^^ help: a constant with a similar name exists: `IPC_NOWAIT`
6.768      |
6.768     ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.153/src/unix/linux_like/linux/mod.rs:2102:1
6.768      |
6.768 2102 | pub const IPC_NOWAIT: ::c_int = 0o4000;
6.768      | ----------------------------- similarly named constant `IPC_NOWAIT` defined here
6.768
6.821 For more information about this error, try `rustc --explain E0425`.

https://docs.rs/libc/latest/x86_64-unknown-linux-musl/libc/index.html?search=preadv2

eeeebbbbrrrr commented 4 months ago

Dunno if this is helpful but I see the same using Docker images based on Alpline-3.12 and Alpine 3.19.

weihanglo commented 4 months ago

We should probably add more cfg on these usages and yank 0.1.29 after releasing a new one. I'll find a time sending a fix.

rdbo commented 4 months ago

Yep, having the same issue here as well, on x86_64 Alpine edge.

I added a temporary fix in my Cargo.toml for this:

jobserver = { version = "=0.1.20", default-features = false }

It's enough to compile the cc crate for now, which is what I needed it for

Asempere123123 commented 4 months ago

Same issue on rust:alpine3.19 docker image

weihanglo commented 4 months ago

Looks like musl libc has gained support of preadv2 since 1.2.5: https://www.openwall.com/lists/musl/2024/03/01/2, though that might be too new and the latest libc doesn't have that at this moment.

randomairborne commented 4 months ago

Also having this issue. Perhaps MUSL compatibility should also be tested in CI?

weihanglo commented 4 months ago

Also having this issue. Perhaps MUSL compatibility should also be tested in CI?

Feel free to open a PR for that if it is not too complicated to set up in CI.

weihanglo commented 4 months ago

https://github.com/rust-lang/jobserver-rs/pull/80#issuecomment-2052112449

Published 0.1.30 and yanked 0.1.29.