-
Notifications
You must be signed in to change notification settings - Fork 13.7k
check before test for hardware capabilites in bits 32~63 of usize #146323
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a bit more to the PR description: a short summary of the problem, and of the solution.
Also, does this change actually fix the issue you're observing?
#[cfg(target_pointer_width = "64")] | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should at least get a comment, because I think it's quite reasonable to assume that aarch64 implies 64-bit pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also now you're basically saying that the features in this block cannot be queried for on ilp32, is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will add some comment to clarify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also now you're basically saying that the features in this block cannot be queried for on ilp32, is that correct?
Yes, the libc::getauxval
returns 32 bit c_ulong
for aarch64 ILP32 target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also now you're basically saying that the features in this block cannot be queried for on ilp32, is that correct?
Well, to be more accurate, they can be queried, but the values will all be false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should at least get a comment, because I think it's quite reasonable to assume that aarch64 implies 64-bit pointers.
I have added some comments to clarify it.
I have updated the PR description.
It should. I will test it on the real hardware soon. |
Yes, it does fix the issue. I have verified that on the real hardware. The following code ran and printed fn main() {
println!("{:?}", std::arch::is_aarch64_feature_detected!("lse"));
} |
This comment has been minimized.
This comment has been minimized.
|
||
// Hardware capabilities from bits 32 to 63 should only | ||
// be tested on LP64 targets with 64 bits `usize`. | ||
// On ILP32 targets like `aarch64-unknown-linux-gun_ilp32`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// On ILP32 targets like `aarch64-unknown-linux-gun_ilp32`, | |
// On ILP32 targets like `aarch64-unknown-linux-gnu_ilp32`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
@bors r+ |
check before test for hardware capabilites in bits 32~63 of usize This commit tries to fix rust-lang#146230. `std::arch::is_aarch64_feature_detected` panics on aarch64 ILP32 targets. After some digging, the real problem is https://github.com/rust-lang/rust/blob/91edc3ebccc4daa46c20a93f4709862376da1fdd/library/std_detect/src/detect/os/linux/aarch64.rs#L210-L241 checks bits 32~63 of usize unconditionally on normal aarch64 LP64 target and aarch64 ILP32 target. Here I propose to move these to a block guarded by `#[cfg(target_pointer_width="64")]`. See rust-lang#146230 for more detailed analysis. r? `@Amanieu`
Rollup of 16 pull requests Successful merges: - #145660 (initial implementation of the darwin_objc unstable feature) - #145895 (thread parking: fix docs and examples) - #146308 (support integer literals in `${concat()}`) - #146323 (check before test for hardware capabilites in bits 32~63 of usize) - #146332 (tidy: make behavior of extra-checks more uniform) - #146338 (Extends AArch64 branch protection support to include GCS) - #146374 (Update `browser-ui-test` version to `0.22.2`) - #146413 (Improve suggestion in case a bare URL is surrounded by brackets) - #146426 (Bump miow to 0.60.1) - #146432 (Implement `Socket::take_error` for Hermit) - #146433 (rwlock tests: fix miri macos test regression) - #146435 (Change the default value of `gcc.download-ci-gcc` to `true`) - #146439 (fix cfg for poison test macro) - #146448 ([rustdoc] Correctly handle literal search on paths) - #146449 (Fix `libgccjit` symlink when we build GCC locally) - #146455 (test: remove an outdated normalization for rustc versions) Failed merges: - #146389 (Convert `no_std` and `no_core` to the new attribute infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
check before test for hardware capabilites in bits 32~63 of usize This commit tries to fix rust-lang#146230. `std::arch::is_aarch64_feature_detected` panics on aarch64 ILP32 targets. After some digging, the real problem is https://github.com/rust-lang/rust/blob/91edc3ebccc4daa46c20a93f4709862376da1fdd/library/std_detect/src/detect/os/linux/aarch64.rs#L210-L241 checks bits 32~63 of usize unconditionally on normal aarch64 LP64 target and aarch64 ILP32 target. Here I propose to move these to a block guarded by `#[cfg(target_pointer_width="64")]`. See rust-lang#146230 for more detailed analysis. r? ``@Amanieu``
Rollup of 16 pull requests Successful merges: - #144549 (match clang's `va_arg` assembly on arm targets) - #145660 (initial implementation of the darwin_objc unstable feature) - #145895 (thread parking: fix docs and examples) - #146308 (support integer literals in `${concat()}`) - #146323 (check before test for hardware capabilites in bits 32~63 of usize) - #146332 (tidy: make behavior of extra-checks more uniform) - #146374 (Update `browser-ui-test` version to `0.22.2`) - #146413 (Improve suggestion in case a bare URL is surrounded by brackets) - #146426 (Bump miow to 0.60.1) - #146432 (Implement `Socket::take_error` for Hermit) - #146433 (rwlock tests: fix miri macos test regression) - #146435 (Change the default value of `gcc.download-ci-gcc` to `true`) - #146439 (fix cfg for poison test macro) - #146448 ([rustdoc] Correctly handle literal search on paths) - #146449 (Fix `libgccjit` symlink when we build GCC locally) - #146455 (test: remove an outdated normalization for rustc versions) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 15 pull requests Successful merges: - #144549 (match clang's `va_arg` assembly on arm targets) - #145895 (thread parking: fix docs and examples) - #146308 (support integer literals in `${concat()}`) - #146323 (check before test for hardware capabilites in bits 32~63 of usize) - #146332 (tidy: make behavior of extra-checks more uniform) - #146374 (Update `browser-ui-test` version to `0.22.2`) - #146413 (Improve suggestion in case a bare URL is surrounded by brackets) - #146426 (Bump miow to 0.60.1) - #146432 (Implement `Socket::take_error` for Hermit) - #146433 (rwlock tests: fix miri macos test regression) - #146435 (Change the default value of `gcc.download-ci-gcc` to `true`) - #146439 (fix cfg for poison test macro) - #146448 ([rustdoc] Correctly handle literal search on paths) - #146449 (Fix `libgccjit` symlink when we build GCC locally) - #146455 (test: remove an outdated normalization for rustc versions) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #146323 - h3fang:issue-146230-fix, r=Amanieu check before test for hardware capabilites in bits 32~63 of usize This commit tries to fix #146230. `std::arch::is_aarch64_feature_detected` panics on aarch64 ILP32 targets. After some digging, the real problem is https://github.com/rust-lang/rust/blob/91edc3ebccc4daa46c20a93f4709862376da1fdd/library/std_detect/src/detect/os/linux/aarch64.rs#L210-L241 checks bits 32~63 of usize unconditionally on normal aarch64 LP64 target and aarch64 ILP32 target. Here I propose to move these to a block guarded by `#[cfg(target_pointer_width="64")]`. See #146230 for more detailed analysis. r? ```@Amanieu```
This commit tries to fix #146230.
std::arch::is_aarch64_feature_detected
panics on aarch64 ILP32 targets.After some digging, the real problem is
rust/library/std_detect/src/detect/os/linux/aarch64.rs
Lines 210 to 241 in 91edc3e
checks bits 32~63 of usize unconditionally on normal aarch64 LP64 target and aarch64 ILP32 target.
Here I propose to move these to a block guarded by
#[cfg(target_pointer_width="64")]
.See #146230 for more detailed analysis.
r? @Amanieu