feat(hints): support minimum optimization levels - #17368
Conversation
b532a3f to
2b19c48
Compare
There was a problem hiding this comment.
🔢 Self-check (PR reviewed by myself and ready for feedback)
-
Code compiles successfully
-
Unit tests added
-
No AI-generated elegant nonsense in PR.
-
Comments added where necessary
-
PR title and description updated
-
Documentation updated
-
PR size is reasonable
| via `profile`, which takes precedence, and which can only be specified in the | ||
| top-level crate being built. | ||
|
|
||
| ## Package `min-opt-level` hint |
There was a problem hiding this comment.
Can you have a subsection that is written as-if it was the end-user documentation?
There was a problem hiding this comment.
Could you give an example of the kind of end-user documentation you expect? What should it include? I thought the current document already covered the basic usage and examples.
There was a problem hiding this comment.
I'm not just looking for how well it is explain but find it helpful to literally have the docs that will go into any guide or reference section written out in the Unstable chapter with asides saying where they will go. I generally ask for this to be written in the RFC but seemed to have overlooked it in this case.
For example, will the docs live under https://doc.rust-lang.org/cargo/reference/manifest.html?highlight=hint#the-hints-section ? What will the heading be? How do we want to organize these?
This comment has been minimized.
This comment has been minimized.
14ab0ce to
415812c
Compare
This comment has been minimized.
This comment has been minimized.
415812c to
aaf6533
Compare
18f313e to
ff1b273
Compare
This comment has been minimized.
This comment has been minimized.
Record the current ignored-hint behavior across the RFC precedence, scope, validation, and boundary cases. Signed-off-by: 0xPoe <poe.liu@pm.me>
RFC 3924 lets a package request a numeric optimization floor without overriding an application's profile choices. Apply the hint after profile and built-in host defaults but before explicit package and build overrides, while leaving the unordered size levels unchanged. Signed-off-by: 0xPoe <poe.liu@pm.me>
Document the unstable gate, accepted range, profile precedence, non-recursive scope, and the narrow cases where packages should request optimization. Include an explicit debugging override so top-level users retain control. Signed-off-by: 0xPoe <poe.liu@pm.me>
ff1b273 to
b9ea4de
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (possibly #17424) made this pull request unmergeable. Please resolve the merge conflicts. |
| let warn = |message: &str| { | ||
| gctx.shell() | ||
| .warn(format!("{}@{}: {message}", pkg.name(), pkg.version())) | ||
| }; | ||
| let min_opt_level = match parse_min_opt_level_hint( | ||
| pkg.hints().and_then(|hints| hints.min_opt_level.as_ref()), | ||
| ) { | ||
| Ok(level) => level, | ||
| Err(MinOptLevelHintError::OutOfRange(level)) => { | ||
| warn(&format!( | ||
| "ignoring unsupported value ({level}) for 'hints.min-opt-level', which only supports integers from 0 to 3" | ||
| ))?; | ||
| None | ||
| } | ||
| Err(MinOptLevelHintError::WrongType(value_type)) => { | ||
| warn(&format!( | ||
| "ignoring unsupported value type ({value_type}) for 'hints.min-opt-level', which expects an integer" | ||
| ))?; | ||
| None | ||
| } | ||
| }; |
There was a problem hiding this comment.
If we're keeping these long term, let's render them "correctly" using annotate-snippets
View all comments
What does this PR try to resolve?
ref #17334
This PR would allow Rust library to provide a simple hint about the minimum opt-level to build them with via the
hint.min-opt-levelsetting in the manifest.How to test and review this PR?
Check the unit tests and review it commit by commit.
r?@ghost