我正在尝试使用meta-rust
层,使用bitbake/yocto来使用rust。
在该层中,我可以看到最近添加了一个版本为1.58.0的cargo配方。不幸的是,当我尝试使用BitBake构建任何rust代码时,会出现以下错误:
NOTE: Executing Tasks
ERROR: echo-server-0.1.0.AUTOINC+c37d3bb2f3-r0 do_compile: ExecutionError('./tmp/work/corei7-64-poky-linux/echo-server/0.1.0.AUTOINC+c37d3bb2f3-r0/temp/run.do_compile.391773', 101, None, None)
ERROR: Logfile of failure stored in: ./tmp/work/corei7-64-poky-linux/echo-server/0.1.0.AUTOINC+c37d3bb2f3-r0/temp/log.do_compile.391773
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: cargo = build/tmp/work/corei7-64-poky-linux/echo-server/0.1.0.AUTOINC+c37d3bb2f3-r0/recipe-sysroot-native/usr/bin/cargo
| NOTE: rustc =
| NOTE: cargo build -v --target x86_64-poky-linux --release --manifest-path=./build/tmp/work/corei7-64-poky-linux/echo-server/0.1.0.AUTOINC+c37d3bb2f3-r0/git//Cargo.toml
| error: failed to parse manifest at ./build/tmp/work/corei7-64-poky-linux/echo-server/0.1.0.AUTOINC+c37d3bb2f3-r0/git/Cargo.toml
|
| Caused by:
| feature `edition2021` is required
|
| consider adding `cargo-features = ["edition2021"]` to the manifest
| WARNING: exit code 101 from a shell command.
这段 Rust 代码在本地系统上可以正常构建,我认为错误是因为 Yocto 使用的 Cargo 版本是1.54。
tmp/work/corei7-64-poky-linux/libstd-rs/1.54.0-r0/recipe-sysroot-native/usr/bin/cargo --version
cargo 1.54.0
我该如何让 yocto 使用更高版本的 cargo?在
meta-rust
中有相关的配方,我可以看到 yocto 已知道这一点。bitbake -s | grep cargo
cargo :1.58.1-r0
cargo-cross-canadian-x86-64 :1.58.1-r0
cargo-native :1.58.1-r0 :1.54.0-r0
nativesdk-cargo :1.58.1-r0
请注意,如果设置了RUSTVERSION ?= "1.58"
,将会出现以下警告:
WARNING: preferred version 1.58 of cargo-native not available (for item cargo-native)
WARNING: versions of cargo-native available: 1.54.0
WARNING: preferred version 1.58 of libstd-rs not available (for item libstd-rs)
WARNING: versions of libstd-rs available: 1.54.0
WARNING: preferred version 1.58 of libstd-rs not available (for item libstd-rs)
WARNING: versions of libstd-rs available: 1.54.0
WARNING: preferred version 1.58 of libstd-rs not available (for item libstd-rs-dev)
WARNING: versions of libstd-rs available: 1.54.0
WARNING: preferred version 1.58 of rust-native not available (for item rust-native)
WARNING: versions of rust-native available: 1.54.0
WARNING: preferred version 1.58 of rust-llvm-native not available (for item rust-llvm-native)
WARNING: versions of rust-llvm-native available: 1.54.0
这表明它正在使用默认版本1.54.0
注意:bitbake -c cleanall rust cargo
会产生以下错误:
ERROR: Nothing PROVIDES 'rust'
rust was skipped: Rust recipe doesn't work for target builds at this time. Fixes welcome.
meta-rust
层的显式锥体。不幸的是,如果我将RUSTVERSION
设置为1.58
,在检查依赖项时会产生很多警告,并且最终在获取cargo-native
时失败。目前我的解决方法是在我的Cargo.toml
文件中将版本设置为2018年版。 - markbitbake -c cleanall rust cargo
命令和本地包也许会有帮助。我从不建议混合配方和源码。它们之间没有任何关联!但如果你还不知道的话,有一个名为 cargo-bitbake 的工具可以使用。 - hellow