[WIP] per profile sysroot via Cargo.toml #2436
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch lets you use the 'profile.$profile.sysroot' key in Cargo.toml to pass
--sysroot $path
to
rustc
during the compilation of the current crate and its dependencies.Main use cases are kernel development and bare metal programming (e.g. microcontrollers) where the
application depends on a minimal set of "core" crates like
core
,alloc
,collections
, etc.These dependencies need to be cross compiled for the target platform/architecture and a "sysroot"
(*) provides, IMO ,the cleanest way to make these core dependencies available to the many crates
that conform the application.
(*) A sysroot is basically a directory that holds the already (cross) compiled "standard" crates
(i.e.
core
,std
, etc) that are linked to your Rust programs when you callrustc
. The importantbit is that you don't explicitly spell out these dependencies in e.g. a Cargo.toml; they are
implicitly available. The fastest way to familiarize with sysroots is to explore the default sysroot
with something like
tree $(rustc --print sysroot)
.cc #2312
This is minimal PoC to start the discussion. There are a few unresolved questions.
--sysroot
torustc
. Should we just use thatfeature and not implement this one?
the call site or relative the root of the cargo project? Example, if the user sets 'sysroot =
foo' in their Cargo project and then calls
cargo build --manifest-path some/path/Cargo.toml
should
$(pwd)/foo
orsome/path/foo
be used as the sysroot?cc @alexcrichton @Zoxc