-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"paca" and "pacg" features are tied in rustc, but detection isn't tied #1352
Comments
They are enabled by different registers: https://github.com/torvalds/linux/blob/4bbf3422df78029f03161640dcb1e9d1ed64d1ea/arch/arm64/kernel/cpufeature.c#L2704-L2735 I don't know if there exist cpu's that support one but not the other. |
Yeah, they are definitely distinct features and I think it's likely "more wrong" to tie them together, but this limitation seems to come from LLVM which ties them together as a single "pauth" feature. The way I look at it, detection should match codegen, because there's no way of knowing something like this happens without reading rustc's source. |
IIRC the split was introduced because some OS only provide one of the 2 features. At the CPU level this is a single feature but availability depends on the OS exposing the necessary functionality. |
In that case, I wonder if |
Well it's a bit tricky: we can't safely enable the LLVM feature without OS support. But perhaps something like a JIT compiler could use the feature detection to decide whether it wants to make use of one of the two sub-features. |
I guess it's a question of should |
See rust-lang/rust#86941 for the background on the split. cc @adamgemmell |
Your earlier comment here hints at one of the ideas I had, enabling the entirety of The other idea of only allowing enabling the features together seems... reasonable? This would still allow separate detection and still imply that you need to detect both |
I agree with your other idea, that would be the best way to handle this. Perhaps in the future LLVM will also split this into two separate features like they did for the |
Splitting the two features was a precautionary decision mainly to ensure we'd keep stability if LLVM split
It shouldn't and your example doesn't compile when I tried just now. What should happen is the other idea - it should error saying that
We made a point of having the same feature set for target_feature and feature detection as the two are often used together. I think a stable set of features handled by Rust, portable across OSes is quite valuable. There's also the possibility of backends other than LLVM to consider too. Given that, the intention was that if both must be explicitly enabled together then it's a programmer error to only check for one. Perhaps a new |
Hmm you're right... which is good news. I think there are a few things that don't work quite right and I jumped to conclusions
|
This could be due to issues with how late the feature validation happens - it happens right before we hand over to LLVM. Could the function be optimised out in debug builds before getting to rustc_codegen_llvm? The validation should probably occur earlier given the move towards a unified Rust feature set across all backends.
It looks like a bug with the cfg directive. Maybe both the command-line and |
A minor victory, but now both |
I added rust-lang/rust#105110 and rust-lang/rust#105111 to address those issues. I think detection is correct so I'm closing this. |
In rustc, the "paca" and "pacg" features are tied together: https://github.com/rust-lang/rust/blob/a876a4df32b402e3886cd9f2af02cff3dd8e21c8/compiler/rustc_codegen_ssa/src/target_features.rs#L147-L149
Enabling one always enables the other, so I think detection should check both as well.
I don't know if there are any CPUs that have one and not the other, but this could potentially be unsound:
The text was updated successfully, but these errors were encountered: