12 unstable releases (3 breaking)
|0.8.0||Nov 25, 2020|
|0.6.2||Oct 15, 2019|
|0.5.3||Dec 25, 2018|
#86 in Cargo plugins
128 downloads per month
A simple tool to compile the sysroot crates for your no_std application, while using the standard cargo tools.
This is not a wrapper like
cargo xbuild or
xargo, this is a standalone tool you call once beforehand.
This has the nice benefit of actually working with standard tools like Rust Analyzer, clippy,
or even the simple
cargo check. It accomplishes this by generating a
.cargo/config for you.
- The latest nightly compiler.
rust-srccomponent must be installed for the active toolchain.
Cargo.tomlfile MUST contain
targetis a target specification json file.
- A built-in target also works!
- OR Pass
--targeton the command line, ex
cargo sysroot --target path/to/target.json
[package] name = "My Project" version = "0.1.0" authors = ["Me <Me@Me.com>"] [package.metadata.cargo-sysroot] target = "my_custom_target.json" # This is relative to Cargo.toml
cargo install cargo-sysroot.
cargo sysrootin the working directory of your project.
This tool will generate a
.cargo/config.toml for you that looks something like this.
This can be disabled via the
--no-config command-line option.
[build] target = <package.metadata.cargo-sysroot.target> rustflags = [ "--sysroot", "<project root>/target/sysroot", ]
The sysroot will be located at
target/sysroot and the target directory for building it at
Due to how the rust sysroot works, you can use multiple different target specifications at a time without rebuilding, by simply passing a different
--target to cargo.
Note that this tool is currently quite simple, so it won't attempt to do anything if that file already exists. In this case you will have to edit it manually.
This will allow Cargo to properly build your project with the normal commands, such as
You may wish to modify this file to make use of the
target.$triple.runner key. See the Cargo Documentation for details.
Note that the author experienced problems with the
$triple variant not working, and you may experience better success with the
If you update your Rust nightly version you will need to run
causing cargo to detect the update and rebuild the sysroot and your project.
If you have more complicated needs than can be satisfied by
which doesn't support complex-ish modifications of the command line.
The author recommends their own,
to solve this, it allows specifying the command-line in
Cargo.toml and applying a suffix
to the path from Cargo.
Alternatives include cargo-make,
which you can setup to run whatever you like, instead of using
Use my other crate,
cargo-image to build an image suitable for running in QEMU.
The sysroot crates are compiled with the
compiler_builtins is built with the
rustc-dep-of-std features, which provides
memcpy and related.
The sysroot crates will share any profile information your crate specifies. Eg if you enable debug for
release, the sysroot crates will have that too. This matches
cargo-xbuild behavior and some crates,
bootloader, require this to function.
You can pass custom rust sources through the
- Allow disabling the
- Q: Why did you write this over just using
- A: It was easier and simpler than getting
cargo-xbuildto work reliably or with any other standard tools.
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.
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.