简体   繁体   English

如何仅使用 cargo 或 rustc 为自定义目标编译 Rust 核心板条箱?

[英]How can I compile the Rust core crate for a custom target using only cargo or rustc?

I'm writing code for a bare-metal x86 target and I need to cross-compile the core crate.我正在为裸机 x86 目标编写代码,我需要交叉编译核心板条箱。 I want a solution that only uses cargo or rustc.我想要一个只使用 cargo 或 rustc 的解决方案。

I currently use xcargo to compile a dummy no_std crate and copy the sysroot folder to my project.我目前使用xcargo编译一个虚拟的 no_std crate 并将 sysroot 文件夹复制到我的项目中。

You can use the unstable build-std feature of Cargo:您可以使用 Cargo 的不稳定的build-std功能:

cargo build -Z build-std=core --target my-custom-target.json

The argument can be:参数可以是:

  • core
  • std
  • alloc
  • proc_macro

Pass no argument for all of them.不为所有这些争论。

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

相关问题 如何仅使用rustc而不使用商品链接动态Rust库? - How to link a dynamic Rust library using only rustc and not cargo? 为什么此Rust 2018代码使用`cargo build`编译但不使用rustc编译? - Why does this Rust 2018 code compile with `cargo build` but not using rustc? 当我使用 rustc 编译时,为什么会出现在 Cargo.toml 中列为依赖项的“找不到板条箱”? - Why do I get "can't find crate" that is listed as a dependency in Cargo.toml when I compile with rustc? 使用 rustc 但不使用货物时缺少板条箱 - Missing crate when using rustc but not using cargo 如何使用 cargo 找到最新的稳定版本的 crate? - How can I find the latest stable version of a crate using cargo? 如何在现有项目中对Cargo进行类似的依赖解析,并且只使用rustc进行代码分析? - How can I get similar dependency resolution to Cargo in an existing project with only rustc for code analysis? 是否有可以格式化导入的 Rust 板条箱或货物升级? - Is there a Rust crate or Cargo upgrade that can format imports? 如何使用 Chrono crate 在 Rust 中获取当前工作日? - How can I get the current weekday in Rust using the Chrono crate? 如何让 cargo/rustc 为 Rust 代码生成简洁的汇编语言? - How to have cargo/rustc generate concise assembly language for Rust code? 如何使用 `rustc` 板条箱? - How to use `rustc` crate?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM