rust - 调用cargo-binutils命令时,是否可以使用xbuild代替build?

标签 rust rust-cargo binutils cross-build

我尝试通过cargo xbuild命令将binutils命令用于自定义构建目标的二进制文件。
但是,我收到类似以下消息的错误。

$ cargo nm --target i586-rust_dos.json --bin rust_dos --verbose
"cargo" "build" "--target" "i586-rust_dos.json" "--bin" "rust_dos" "--message-format=json"
   Compiling rust_dos v0.1.0 (/home/soya/Documents/src/rust/prac/rust_dos)
error[E0463]: can't find crate for `core`                                ] 0/2
  |
  = note: the `i586-rust_dos-8410465322435951119` 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_dos`.

To learn more, run the command again with --verbose.
error: Failed to parse crate metadata


我意识到cargo nm使用cargo build命令,
所以我认为如果我使cargo nm使用cargo xbuild而不是cargo build,则应该解决此错误。

但是,我找不到该怎么做。
如果可以的话,请教我。

最佳答案

要检测使用core构建的cargo xbuild crate ,我需要在sysrootrustflags中添加.cargo/config标志。

示例如下。

rustflags = ["--sysroot", "/full/path/to/sysroot/directory"]

在项目的目标目录中有sysroot目录。

如果添加了这些标志,那么cargo-bintuils命令将被启用以在我的环境中使用。

关于rust - 调用cargo-binutils命令时,是否可以使用xbuild代替build?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61305693/

相关文章:

binutils - x86_64是否有其他版本的binutils?

linux - 找出函数符号在目标文件 (.o) 中的可见性

c - 为什么 STM32 gcc 链接器脚本会自动丢弃这些标准库 : libc. a、libm.a、libgcc.a 中的所有输入节?

rust - From 特征的实现可以是有损的吗?

rust - 在 Rust 中创建关联数组

docker - 编译 azure iot edge 的 edgelet 模块时出现 cargo 错误

testing - 运行 Rust cargo test 并让测试运行器将任何日志输出显示到控制台 stdout 或 stderr 的方法有哪些?

arrays - 结构中的枚举数组打印变体名称和值

rust - 如何仅使用标准库设置主机名?

rust - 在解析包版本时,我可以强制使用依赖项的 Cargo.lock 吗?