rCore-Tutorial
rCore-Tutorial copied to clipboard
cargo install cargo-binutils failed
欢迎提出任何问题
环境
rustc 1.62.0-nightlywsl2 Ubuntu 20.04
遇到问题
安装环境时,cargo install cargo-binutils 失败。
安装依赖clap v2.34.0时,提示:
error[E0658]: `if` is not allowed in a `const fn`
--> /home/ruiqurm/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/clap-2.34.0/src/app/settings.rs:7:1
|
7 | / bitflags! {
8 | | struct Flags: u64 {
9 | | const SC_NEGATE_REQS = 1;
10 | | const SC_REQUIRED = 1 << 1;
... |
51 | | }
52 | | }
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `if` is not allowed in a `const fn`
--> /home/ruiqurm/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/clap-2.34.0/src/args/settings.rs:6:1
|
6 | / bitflags! {
7 | | struct Flags: u32 {
8 | | const REQUIRED = 1;
9 | | const MULTIPLE = 1 << 1;
... |
28 | | }
29 | | }
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Compiling addr2line v0.17.0
Compiling regex v1.5.5
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.
error: could not compile `clap`.
尝试添加标志-Z minimal-versions : cargo install cargo-binutils -Z minimal-versions
在编译backtrace v0.3.5处失败:
Compiling backtrace v0.3.5
error[E0425]: cannot find value `RTLD_LAZY` in crate `libc`
--> /home/ruiqurm/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/backtrace-0.3.5/src/dylib.rs:30:70
|
30 | let ptr = libc::dlopen(name.as_ptr() as *const c_char, libc::RTLD_LAZY);
| ^^^^^^^^^ not found in `libc`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
error: could not compile `backtrace`.
(可能的)解决方案
切换nightly到stable:
rustup override set stable
It seems to be caused by the clap issue#2734 and some similar api-outdated cases.
So we only need to use the rust-toolchain version greater than 1.51.0 (such as nightly-2022-06-09) in the file rust-toolchain .