简体   繁体   English

调用 cargo-binutils 命令时有没有办法使用 xbuild 而不是 build?

[英]Is there way to use xbuild instead of build when calling cargo-binutils commands?

I try to use binutils commands for binary of custom build target with cargo xbuild command.我尝试将 binutils 命令用于自定义构建目标的二进制文件和cargo xbuild命令。
However, I get an error like below message.但是,我收到类似以下消息的错误。

$ 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

I realized that cargo nm uses cargo build command,我意识到cargo nm使用cargo build命令,
so I think this error should be solved if I make cargo nm to use cargo xbuild instead of cargo build .所以我认为如果我让cargo nm使用cargo xbuild而不是cargo build应该可以解决这个错误。

However, I cannot find how to do that.但是,我找不到如何做到这一点。
Please teach me if there is a way.如果有办法请教我。

To detect core crate built with cargo xbuild , I need to add sysroot flag in rustflags in .cargo/config .要检测使用cargo xbuild构建的core板条箱,我需要在.cargo/configrustflags中添加sysroot标志。

example is below.示例如下。

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

There is sysroot directory in project's target directory.项目的目标目录中有 sysroot 目录。

If adding these flags, cargo-bintuils commands are enabled to use as far as in my environment.如果添加这些标志,则可以在我的环境中使用 cargo-bintuils 命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法安装 cargo-binutils 库:找不到工具。 是否安装了`gcc.exe`? - Can't install cargo-binutils library: Failed to find tool. Is `gcc.exe` installed? 是否可以在调用 cargo build 时从命令行覆盖 Cargo.toml 中指定的 crate-type? - Is it possible to override the crate-type specified in Cargo.toml from the command line when calling cargo build? 使用 Cargo 为使用相同源目录的多个平台构建的最佳方法是什么? - What's the best way to use Cargo to build for multiple platforms using the same source directory? 如何在 Cargo 构建脚本中使用外部板条箱? - How to use external crates in a Cargo build script? Cargo 的 build 和 rustc 命令有什么区别? - What's the difference between Cargo's build and rustc commands? 尝试将货物与 docker 一起使用时权限被拒绝 - Permission denied when trying to use cargo with docker 如果我使用cargo build --release命令,默认的优化级别是多少? - What is the default optimization level, if I use the cargo build --release command? 离线时如何使用Cargo建立项目? - How do I use Cargo to build a project while offline? 如何使用 raft-rs 板条箱并使用货物进行构建? - How to use the raft-rs crate and build with cargo? 运行“货物构建”时无法执行链接器“cc”错误 - Could not exec the linker `cc` error when running “cargo build”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM