cargo-xbuild
Cargo-xbuild is a wrapper for cargo build, which cross compiles the sysroot crates core, compiler_builtins, and alloc for custom targets. It is a simplified fork of xargo, which is in maintaince mode.
Dependencies
-
The
rust-srccomponent, which you can install withrustup component add rust-src. -
Rust and Cargo.
Installation
$ cargo install cargo-xbuild
Usage
Just use cargo xbuild instead of cargo build when cross-compiling for a custom target.
cargo xbuild --target your-target-name.json
Instead of the "can't find crate for core" error you would get with a plain cargo build, this crate cross-compiles the core, compiler_builtins, and alloc crates and then invokes cargo build with a modified sysroot. The sysroot is compiled in the target directory of your crate.
All additional arguments (e.g. --release or --verbose) are forwarded to cargo build.
Dev channel
If you want to use a local Rust source instead of rust-src rustup component, you can set the XARGO_RUST_SRC environment variable.
# The source of the `core` crate must be in `$XARGO_RUST_SRC/libcore`
$ export XARGO_RUST_SRC=/path/to/rust/src
$ cargo xbuild --target msp430-none-elf.json
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.