【发布时间】:2022-01-04 17:27:13
【问题描述】:
我正在尝试交叉编译示例 rust 代码作为 Linux (KDE-Neon) 上裸机 AArch64 的库。不幸的是,它不起作用。这是我的示例 rust 代码 (lib.rs):
#![no_std]
#[no_mangle]
pub extern "C" fn double_value (a : u32) -> u32
{
a / 2
}
根据 [1],我首先安装了 rustup:
sudo snap install rustup --classic
之后,我跟着[2]跑了:
rustup toolchain list
rustup install stable
rustup default stable
然后我跟着[1]和[3]跑了:
rustup target add aarch64-unknown-none
但是当我之后尝试编译时,我不工作,无论是使用 rustc 还是使用 cargo:
rustc:
rustc --crate-type=lib lib.rs --target=aarch64-unknown-none
error[E0463]: can't find crate for `core`
|
= note: the `aarch64-unknown-none` target may not be installed
error: aborting due to previous error
货物:
Cargo.toml:
[package]
name = "rust_baremetal_lib"
version = "0.1.0"
edition = "2018"
[lib]
name = "rust_baremetal_lib"
path = "src/lib.rs"
crate-type = ["staticlib"]
[dependencies]
cargo build --lib --target=aarch64-unknown-none
Compiling rust_baremetal_lib v0.1.0 (/home/kilian/code/rust_link/rust_baremetal_lib)
error[E0463]: can't find crate for `core`
|
= note: the `aarch64-unknown-none` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `rust_baremetal_lib`
To learn more, run the command again with --verbose.
在我看来 rustc 和 cargo 找不到核心库,尽管应该安装它,正如运行 rustc --print 时看到的那样:
rustc --print target-list|grep arch64-unknown-none
aarch64-unknown-none
aarch64-unknown-none-softfloat
我已经在互联网上查看过,但不幸的是没有找到任何线索。希望有人能帮我找到问题!
[1]https://rust-lang.github.io/rustup/cross-compilation.html
[2]No default toolchain configured after installing rustup
[3]https://doc.rust-lang.org/nightly/rustc/platform-support.html
【问题讨论】:
-
rustup component add rust-std-aarch64-unknown-none? -
rustup component add rust-std-aarch64-unknown-none error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rust-std-aarch64-unknown-none' for target 'x86_64-unknown-linux-gnu' note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html -
但是,当运行
rustup component list | grep aarch时,它会输出:rust-std-aarch64-unknown-none (installed)
标签: rust cross-compiling rust-cargo arm64 bare-metal