[英]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.