使用 Yocto 的强制货运版本

问题描述 投票:0回答:2

我正在尝试使用 meta-rust 层将 rust

bitbake/yocto
一起使用。

在图层本身中,我可以看到最近添加了 cargo 版本 1.58.0 的配方。不幸的是,当我尝试使用 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.
rust yocto bitbake
2个回答
0
投票

这通常是通过 PREFERRED_VERSION_foo 在 bitbake 中完成的,它看起来像 meta-rust 包含一个可以为您进行此更改的文件:

https://github.com/meta-rust/meta-rust/blob/c654f5cb928bd4f4c7da7d74a8356fd2a94283f6/conf/distro/include/rust_versions.inc#L4

RUST_VERSION ?= "1.58"

如果您将此文件包含在您的distro.conf(或local.conf)中并更改第4行以匹配版本1.58,您应该能够使用/构建货物版本1.58

您仍然可以在 local.conf 上手动更改

PREFERRED_VERSION_cargo/rust*
,但您必须对所有 Rust 组件执行此操作,就像 rust_versions.inc 文件所做的那样。


0
投票

ah008a 在评论中正确指出,除了设置 RUST_VERSION 之外,还必须包含

rust_versions.inc
。该文件设置默认值,然后将 Rust 版本传播到其他 Rust 工具,例如 Cargo:

# include this in your distribution to easily switch between versions
# just by changing RUST_VERSION variable

RUST_VERSION ?= "1.78.0"

PREFERRED_VERSION_cargo ?= "${RUST_VERSION}"
PREFERRED_VERSION_cargo-cross-canadian-${TARGET_ARCH} ?= "${RUST_VERSION}"
PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}"
PREFERRED_VERSION_nativesdk-cargo ?= "${RUST_VERSION}"
PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}"
PREFERRED_VERSION_nativesdk-libstd-rs ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-cross-canadian-${TARGET_ARCH} ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-tools-cross-canadian-${TARGET_ARCH} ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-cross-${DEFAULTTUNE}-${TCLIBC} ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-crosssdk-${SDK_ARCH}-${TCLIBC} ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-llvm ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}"
PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}"

覆盖

RUST_VERSION
distro.conf
中的
local.conf
,然后包含或要求它:

RUST_VERSION = 1.82.0
require ${SRC_DIR}/meta-rust/conf/distro/include/rust_versions.inc

当然可以根据需要更改路径。

这是ah008a说的,我只是想整合一下他们提供的信息。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.