Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
c87f767 to
9901111
Compare
This comment has been minimized.
This comment has been minimized.
9901111 to
770a07e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
770a07e to
925f1b3
Compare
This comment was marked as resolved.
This comment was marked as resolved.
925f1b3 to
169b9b6
Compare
This comment has been minimized.
This comment has been minimized.
169b9b6 to
d392fb9
Compare
This comment has been minimized.
This comment has been minimized.
d392fb9 to
d96f1d1
Compare
This comment has been minimized.
This comment has been minimized.
d96f1d1 to
f46ded7
Compare
This comment has been minimized.
This comment has been minimized.
f46ded7 to
ce77e39
Compare
This comment was marked as resolved.
This comment was marked as resolved.
The existing implementation of target modifiers is quite complicated and hard to work with because it relies so heavily on macros. To some extent, this is unavoidable because only a subset of the `UnstableOptions` or `CodegenOptions` flags are target modifiers and so it needs to filter for those. A simpler implementation will be possible given the additional constraint that all target modifier options are in the same group.
A small refactoring just to give each of these meta-variables better names.
Reporting good target modifier mismatch errors will require at least knowing whether a option was set by the user explicitly rather than just having its default value. This small addition to the infrastructure enables that to be tracked. It is not persisted into the cross-crate metadata, it will only be required in the local crate.
Introduces a new implementation of target modifiers under the `-T` prefix, leveraging that all of the options are in the one struct so that the whole type can just be encoded or decoded to keep track of the values set in downstream crates. The term "target modifiers" is leaked, not just "target flags" because `--target` is already used (unsurprisingly!). Also introduces a new trait to control printing of the values of target modifier options in the target modifier diagnostics.
Introduce a generic mechanism for requiring `-Zunstable-options` on flags so this doesn't need to be checked per-flag manually.
|
r? @adwinwhite rustbot has assigned @adwinwhite. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rustbot reroll |
|
@rustbot reroll |
|
☔ The latest upstream changes (presumably #161347) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
What is the behavior if one crate has
I think it makes sense to treat it like
In the interest of having this PR change as few things at the same time as possible, that makes sense to me. We can always relax it later.
I would expect this to behave like |
|
I did a high level review today.
I'd also suggest to merge the strictest version first - options can't be used with -C and -T most of the time, etc. |
|
There is one design question that has major impact on the code, I think -- is there one pool of options that |
To me |
|
I've recently been helping to make progress on this PR, rebasing it (here is the branch, as of last week), discussing with Vadim about their questions and review comments and how they can be addressed, what additional work we need to do in the PR vs future PRs, and so on. David has implemented the approach described by Alice on Zulip (to be able to use most -C options as -T), and I've also expanded this forward compatibility to the current unstable target modifiers (so -Z in addition to -C/-T). However, after doing the work, David and I discussed some of our conclusions about this plan, and the tradeoffs we saw made us feel like the idea of using -T for target modifiers may not be worth it in practice. From the experience of implementing it, seeing the complexity, the impact on tests and users, etc versus the perceived usefulness of it, it makes us think we probably wouldn't want to actually land this PR (or rust-lang/compiler-team#980 in general), not even the first implementation before implementing Alice's suggestion, that we can see in the first 16 commits or so. I'll post updates in the other PRs marked as blocked on that work as well. And let's close this PR as well. |
Oh. What is the alternative though? The current target modifier system is kind of messy on the implementation side and a bit ad hoc too. I quite liked the easy " |
|
The main alternative I can see is to only have |
|
Yeah that is pretty much the status quo. I guess we can just keep going in that direction. Hopefully the implementation can be cleaned up a bit, it is currently very macro-heavy and does not work well for values that need to be recorded and in sync across the crate graph without being literally the value of a
Let's do that then. |
Yeah, I think everyone who has looked into this agrees 100%.
I'm not sure we need an alternative. To me, we keep doing what we're already doing, with the currently suboptimal system and try to slowly improve it to remove the cruft. |
View all comments
cc rust-lang/compiler-team#980 (#t-compiler/major changes > group target modifier options under `-T` compiler-team#980)
This patch re-implements target modifiers so that they are grouped under
-Tinstead of being regular flags.The current implementation is quite complex, using lots of
macro_rules!s to filter out the target modifier options from the rest of the codegen options, and then storing the original string values of the target modifiers in cross-crate metadata before re-parsing them again in the downstream crate. Some of this complexity is desirable - we don't want to store every option value in the cross-crate metadata because that would hurt compile times. This patch removes the current approach entirely and starts again, leveraging simplifications made possible by the-Tdesign.There's a decent amount of code here but it hopefully isn't too tricky to review.
sess: option metadatauntilsess: -Tllvm-target-feature) implements group target modifier options under-Tcompiler-team#980TargetOptionsstruct is introduced that is parsed from-Tand target modifier options are moved to itTargetOptionsis serialised in its entirety into cross-crate metadata, which is a lot simpler and isn't storing any more information than necessaryTRACKED_UNSTABLEto require that-Zunstable-optionsbe provided if they are used - all current target modifiers are unstable so this is used for all of them-Tand-Z, with onlyaddressandleakbeing in-Zand everything else being in-Tw/-Zunstable-options-Ttarget-cpuis required for targets withTargetOptions::requires_consistent_cpu, otherwise-Ctarget-cpuremains usable-Titself is insta-stable, but all the options under are unstable, so it's effectively unstablesess: -Tllvm-target-feature) implements @Darksonn's suggestion from #t-compiler > Using -T for target modifiers and forwards compatibility @ 💬-Coptions can also be used as-ToptionsTargetOptionsis removed again and target modifier options are now moved intoCodegenOptions(they're still unstable thanks to the aforementionedTRACKED_UNSTABLE)CodegenOptionsis parsed from both-Cand-T-Ttakes precedenceTargetModifierFilter::Only(only-T, no-C) orTargetModifierFilter::Never(only-C, no-T)-Toption values are stored into aFxHashMap, these are stored into cross-crate metadata so we know which options were set as target modifiers in dependencies and we only store those that were set with-TCodegenOptionsKeyenum that has a variant for each optionTargetModifierValuetype that contains variants for each distinct value type of the options we support as being target modifiersTargetModifierValuedoesn't support should be marked as never-target-modifiers, I haven't done that yet and rustc will ICE if you use them with-TTargetModifierValuewas introduced as an attempt to try and keep cross-crate metadata size down - avoidingBox<dyn Any>or storing strings for every option-Tis insta-stable for any of the currently stable-Coptions (but this is prevented for each flag currently withTargetModifierFilter::Never)Questions:
-Cand-Tmost of the time, or flags can interchangably be used with-Cand-T-C/-Tversion) All flags that aren't currently target modifiers are marked as not being usable with-Tto minimise the change from this patch-C/-Tversion)-Csanitizersonly acceptsleafandaddressin this patch, rather than relying on the-C/-Tinterchangability, is that desirable?-C/-Tversion) All of the target modifier flags are limited to-T, is that desirable?-Zsanitizers-cfi-normalize-integerswas previously only a target modifier for-Zsanitizers=kcfi, not-Zsanitizers=cfi, but it is now a target modifier for both, what do we want to do about this?-Zunstable-optionsin addition to the per-target stability check that the flag has always had