bytecodealliance / bytecodealliance/rustix

Next libc version will break musl targets

Open
#1,675 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.1k
Forks
294
Avg merge
4h 7m
Merged PRs (30d)
2

Description

We currently import `STATX_TYPE` and related constants from `linux_raw_sys` because the `libc` crate does not expose `statx` constants for non-glibc targets:

https://github.com/bytecodealliance/rustix/blob/9640071aef0dfd65d21bf01c1dd1baa0a1b13310/src/backend/libc/c.rs#L477

However, the next version of the `libc` crate will expose these constants as well (see https://github.com/rust-lang/libc/pull/5448). This will result in ambiguous imports and build failures on musl targets:

```console
$ cargo check -q --workspace --features=use-libc,all-apis --all-targets --target=x86_64-unknown-linux-musl
error[E0659]: `STATX_TYPE` is ambiguous
--> src/fs/statx.rs:75:25
|
75 | const TYPE = c::STATX_TYPE;
| ^^^^^^^^^^ ambiguous name
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `STATX_TYPE` could refer to the constant imported here
--> src/backend/libc/c.rs:7:16
|
7 | pub(crate) use libc::*;
| ^^^^^^^
= help: consider adding an explicit import of `STATX_TYPE` to disambiguate
note: `STATX_TYPE` could also refer to the constant imported here
--> src/backend/libc/c.rs:512:16
|
512 | pub(crate) use statx_flags::*;
| ^^^^^^^^^^^^^^
= help: consider adding an explicit import of `STATX_TYPE` to disambiguate
```

We should update the imports before the next `libc` release to avoid breaking musl builds.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.