You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codegen features are no longer recognized by rustc #96472
On beta and nightly, compiling with the same options works too, but warns that the feature is not recognized.
$ rustc +nightly --target=wasm32-unknown-unknown -C target-feature=+bulk-memory test.rs --crate-type=cdylib
warning: unknown feature specified for `-Ctarget-feature`: `bulk-memory`
|
= note: it is still passed through to the codegen backend
= note: consider filing a feature request
warning: 1 warning emitted
Target features work well.
This may be caused by #95202.
The warnings reported by @bjorn3 are the symptom of an unrelated bug in the --check-cfg implementation, specifically target features are handle in different way inside the compiler that had made target_feature (the cfg) being recognize as a known cfg condition name in all targets that have at least one target feature but it seems that for wasm32-unknown-unknown the compiler doesn't get any `arget features from the codegen leading to the warnings being emitted in a1phyr case and bjorn3 case.
Removing the regression flag as discussed in the Zulip thread of the Prioritization Working Group.
Although this looks to the end user as a regression, as explained in the comments here this is more a case of unhelpful/incomplete warning message. A patch could probably improve on that.
I stumbled on this bug and did't understand why this is a suboptimal diagnostic and not a regression. #87402, which is what introduced the warning to my understanding, only checks the actual existance of target features and if they were added with the proper + or - sign.
The bug report uses +bulk-memory, which has the + and is an existing target feature for the target used: wasm32-unknown-unknown.
Indeed the issue was a missing entry in the list of existing target features, which was fixed by @alexcrichton here: #97808.
So unless I'm simply clueless on whats actually going on here, I believe this issue can be closed.
I stumbled on this bug and did't understand why this is a suboptimal diagnostic and not a regression.
Because it is still passed to LLVM even if rustc doesn't understand it. Rustc itself didn't understand it in the past either, but it did pass them through to LLVM. The only difference is that rustc now gives a warning if it doesn't understand a feature.
Ah! Thanks @bjorn3!
You seem to appear out of thin air every time I don't understand something ❤️.
Just to clarify then, +bulk-memory is something rustc should understand, which was already fixed in #97808.
The remaining issue is to improve the diagnostic message to make it less confusing for target features that should actually not be recognized.
Does this warning actually indicate a real problem, or is it just "Hey, you should ask the rust-lang devs to add this to the list of known/sanctioned LLVM codegen options"? If it's not actually indicating a real problem, is there a way to suppress the warning? It's unclear from the warning message what I need to pass to suppress it. My team uses an LLVM option not recognized by rustc, and the noise from this warning actively pushes us away from upgrading past 1.60.
We could offer a way to suppress the warning, but then users would not request that we canonicalize in rustc the target features LLVM currently recognizes and Rust does not, as they would simply turn off the warning instead. I understand it can be quite annoying, but the reason to have these canonicalizing mappings is not just an abstract decision about supporting multiple codegen backends. It is at least partly to make it so that we do not expose features LLVM may decide to change its support levels for, as happened with e.g. -Cinline-threshold, or at least to allow us to silence the problems in our own logic rather than simply emitting an LLVM error.
This applies to target features because LLVM reserves the right to change its own target feature definitions and has in the recent past, which is part of why we now map certain features to multiple features, now:
Without a canonicalizing mapping in Rust's lowering, any target feature you use may break on the next LLVM upgrade if you are using our bundled LLVM. LLVM cuts releases on a 6 month cadence. We try to offer more stable interfaces in rustc than "my code works today, but in six months it may break". Target featureful code is effectively unsafe by definition for most targets, and unsafe weakens certain clauses of our stability promises, but I assume you're actually using it in a way that should in fact be quite defined behavior and that we should consider quite sound.
With that prelude, to answer your question:
Q. Does this warning actually indicate a real problem?
A. That depends on how you feel about the stability of your code compiling.
I suspect that what might be a good general solution to the D-confusing part of this issue is to rework this issue (or open a new tracking issue) with more information on what this is, and link the issue from the diagnostic. We already do something along the lines for the future compatibility warnings, and this is kinda similar in nature.
Activity
[-]Codegen feature are no longer recognized by rustc[/-][+]Codegen features are no longer recognized by rustc[/+]ehuss commentedon Apr 27, 2022
This is caused by #87402 which contains some motivation for displaying a warning.
bjorn3 commentedon Apr 27, 2022
When doing a local rebuild of rustc I'm getting the following which I think is related:
Details
Urgau commentedon Apr 27, 2022
The warnings reported by @bjorn3 are the symptom of an unrelated bug in the
--check-cfgimplementation, specifically target features are handle in different way inside the compiler that had madetarget_feature(the cfg) being recognize as a known cfg condition name in all targets that have at least one target feature but it seems that forwasm32-unknown-unknownthe compiler doesn't get any `arget features from the codegen leading to the warnings being emitted in a1phyr case and bjorn3 case.Rollup merge of rust-lang#96483 - Urgau:check-cfg-target_feature, r=p…
apiraino commentedon May 12, 2022
Removing the regression flag as discussed in the Zulip thread of the Prioritization Working Group.
Although this looks to the end user as a regression, as explained in the comments here this is more a case of unhelpful/incomplete warning message. A patch could probably improve on that.
@rustbot label -I-prioritize -regression-from-stable-to-beta
1 remaining item
x86: rust: move unknown-to-`rustc` codegen features back to the targe…
x86: rust: move unknown-to-`rustc` codegen features back to the targe…
daxpedda commentedon Jul 23, 2022
I stumbled on this bug and did't understand why this is a suboptimal diagnostic and not a regression.
#87402, which is what introduced the warning to my understanding, only checks the actual existance of target features and if they were added with the proper
+or-sign.The bug report uses
+bulk-memory, which has the+and is an existing target feature for the target used:wasm32-unknown-unknown.Indeed the issue was a missing entry in the list of existing target features, which was fixed by @alexcrichton here: #97808.
So unless I'm simply clueless on whats actually going on here, I believe this issue can be closed.
bjorn3 commentedon Jul 23, 2022
Because it is still passed to LLVM even if rustc doesn't understand it. Rustc itself didn't understand it in the past either, but it did pass them through to LLVM. The only difference is that rustc now gives a warning if it doesn't understand a feature.
daxpedda commentedon Jul 23, 2022
Ah! Thanks @bjorn3!
You seem to appear out of thin air every time I don't understand something ❤️.
Just to clarify then,
+bulk-memoryis somethingrustcshould understand, which was already fixed in #97808.The remaining issue is to improve the diagnostic message to make it less confusing for target features that should actually not be recognized.
Rollup merge of rust-lang#99643 - daxpedda:sign-ext-wasm, r=oli-obk
JennDahm commentedon Jul 27, 2022
Does this warning actually indicate a real problem, or is it just "Hey, you should ask the rust-lang devs to add this to the list of known/sanctioned LLVM codegen options"? If it's not actually indicating a real problem, is there a way to suppress the warning? It's unclear from the warning message what I need to pass to suppress it. My team uses an LLVM option not recognized by rustc, and the noise from this warning actively pushes us away from upgrading past 1.60.
workingjubilee commentedon Jul 31, 2022
We could offer a way to suppress the warning, but then users would not request that we canonicalize in rustc the target features LLVM currently recognizes and Rust does not, as they would simply turn off the warning instead. I understand it can be quite annoying, but the reason to have these canonicalizing mappings is not just an abstract decision about supporting multiple codegen backends. It is at least partly to make it so that we do not expose features LLVM may decide to change its support levels for, as happened with e.g.
-Cinline-threshold, or at least to allow us to silence the problems in our own logic rather than simply emitting an LLVM error.This applies to target features because LLVM reserves the right to change its own target feature definitions and has in the recent past, which is part of why we now map certain features to multiple features, now:
rust/compiler/rustc_codegen_llvm/src/llvm_util.rs
Lines 177 to 182 in 0f4bcad
Without a canonicalizing mapping in Rust's lowering, any target feature you use may break on the next LLVM upgrade if you are using our bundled LLVM. LLVM cuts releases on a 6 month cadence. We try to offer more stable interfaces in rustc than "my code works today, but in six months it may break". Target featureful code is effectively
unsafeby definition for most targets, andunsafeweakens certain clauses of our stability promises, but I assume you're actually using it in a way that should in fact be quite defined behavior and that we should consider quite sound.With that prelude, to answer your question:
x86: rust: move unknown-to-`rustc` codegen features back to the targe…
x86: rust: move unknown-to-`rustc` codegen features back to the targe…
nagisa commentedon Oct 28, 2022
I suspect that what might be a good general solution to the D-confusing part of this issue is to rework this issue (or open a new tracking issue) with more information on what this is, and link the issue from the diagnostic. We already do something along the lines for the future compatibility warnings, and this is kinda similar in nature.
Rollup merge of rust-lang#103638 - ia0:multivalue, r=nagisa
Rollup merge of rust-lang#144613 - pantsman0:nintendo_switch_cpu_feat…
Unrolled build for #144613
Rollup merge of #144613 - pantsman0:nintendo_switch_cpu_features, r=w…