Support profile overrides for -Z build-std
#15811
Open
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.
Pass both the main package graph and the build-std package graph to the verifier so that e.g.
[profile.dev.package.core]is not rejected and ignored ifcoreis being built.What does this PR try to resolve?
Currently,
[profile.dev.package.my_std_crate_here]will not be respected when-Z build-std=my_std_crate_hereis passed, because profile overrides are verified on a package graph that does not include the build-std package graph.This is important to support because many users of
-Z build-stdare targeting embedded environments where image space may be at a premium. This means that while they may be able to support a more relaxed dev build for their own code, they'd like to build standard libraries with optimizations and fewer assertions to shrink things down.The default behavior without
-Z build-stdis to use prebuilt stdlibs, so you will get an optimized stdlib and a dev-profile version of your project. This configurability allows developers to opt back in to a similar configuration with-Z build-stdby setting profile flags forcore/compiler_builtins/alloc/stdas appropriate.How to test and review this PR?
cargo testshould test it - I've added a new test which ensures both that:-Z build-stdis used