bytecodealliance / bytecodealliance/rustix

rustix fails to build with features mm, use-libc against riscv64gc-linux-unknown-musl target

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

Description

To reproduce:

```
$ cargo new riscv_musl_madv_softoffline
Creating binary (application) `riscv_musl_madv_softoffline` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cd riscv_musl_madv_softoffline/
$ cargo add -F mm,use-libc rustix
Updating crates.io index
Adding rustix v1.0.7 to dependencies
Features:
+ alloc
+ libc
+ libc_errno
+ mm
+ std
+ use-libc
29 deactivated features
Updating crates.io index
Locking 15 packages to latest Rust 1.86.0 compatible versions
$ cargo build --target riscv64gc-unknown-linux-musl
Compiling libc v0.2.172
Compiling bitflags v2.9.0
Compiling linux-raw-sys v0.9.4
Compiling rustix v1.0.7
Compiling errno v0.3.11
error[E0425]: cannot find value `MADV_SOFT_OFFLINE` in module `c`
--> /home/mnissler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.0.7/src/backend/libc/mm/types.rs:408:36
|
408 | LinuxSoftOffline = bitcast!(c::MADV_SOFT_OFFLINE),
| ^^^^^^^^^^^^^^^^^ not found in `c`
|
help: consider importing this constant
|
1 + use linux_raw_sys::general::MADV_SOFT_OFFLINE;
|
help: if you import `MADV_SOFT_OFFLINE`, refer to it directly
|
408 - LinuxSoftOffline = bitcast!(c::MADV_SOFT_OFFLINE),
408 + LinuxSoftOffline = bitcast!(MADV_SOFT_OFFLINE),
|

For more information about this error, try `rustc --explain E0425`.
```

The reason is that the libc crate is missing a `MADV_SOFT_OFFLINE` definition for the RISC-V / musl targets. I intend to send a libc pull request to fix that. rustix may or may not want to add a temporary local workaround, i.e. extending the existing cfg guard to omit `LinuxSoftOffline` in RISC-V / 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.