Skip to content

Commit e38250e

Browse files
authored
Do not fallback to "arm" in rustup-init.sh on aarch64 with 32-bit userland
aarch64 always has neon enabled, and thus it's not included in /proc/cpuinfo. Previously, we'd fall back to arm when running with a 32-bit userland, even though armv7 is perfectly appropriate in this case. This would then run into the issue described in rust-lang/rust#58414 with "CP15 barrier emulation". This PR fixes that.
1 parent d4c6844 commit e38250e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rustup-init.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ ensure_loongarch_uapi() {
291291
}
292292

293293
get_architecture() {
294-
local _ostype _cputype _bitness _arch _clibtype
294+
local _ostype _cputype _bitness _arch _clibtype _arm6432
295295
_ostype="$(uname -s)"
296296
_cputype="$(uname -m)"
297297
_clibtype="gnu"
@@ -501,6 +501,7 @@ get_architecture() {
501501
;;
502502
aarch64)
503503
_cputype=armv7
504+
_arm6432=1
504505
if [ "$_ostype" = "linux-android" ]; then
505506
_ostype=linux-androideabi
506507
else
@@ -516,7 +517,10 @@ get_architecture() {
516517
# Detect armv7 but without the CPU features Rust needs in that build,
517518
# and fall back to arm.
518519
# See https://github.com/rust-lang/rustup.rs/issues/587.
519-
if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then
520+
# If we're on an aarch64 CPU with a 32-bit userland, do not fall back to
521+
# arm -- aarch64 always has neon, and so it's not actually included in
522+
# /proc/cpuinfo
523+
if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ] && [ "$_arm6432" != 1 ]; then
520524
if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
521525
# At least one processor does not have NEON.
522526
_cputype=arm

0 commit comments

Comments
 (0)