Fix hard and soft float libc detection for managed Python distributions on ARM (#8498)

This commit is contained in:
Pietro Zambelli
2024-10-30 00:46:21 +01:00
committed by GitHub
parent 08d022984c
commit 2b0e16cb75
6 changed files with 75 additions and 1 deletions
+12 -1
View File
@@ -1,3 +1,4 @@
use crate::cpuinfo::detect_hardware_floating_point_support;
use crate::libc::{detect_linux_libc, LibcDetectionError, LibcVersion};
use std::fmt::Display;
use std::ops::Deref;
@@ -30,7 +31,17 @@ impl Libc {
pub(crate) fn from_env() -> Result<Self, LibcDetectionError> {
match std::env::consts::OS {
"linux" => Ok(Self::Some(match detect_linux_libc()? {
LibcVersion::Manylinux { .. } => target_lexicon::Environment::Gnu,
LibcVersion::Manylinux { .. } => match std::env::consts::ARCH {
// Checks if the CPU supports hardware floating-point operations.
// Depending on the result, it selects either the `gnueabihf` (hard-float) or `gnueabi` (soft-float) environment.
// download-metadata.json only includes armv7.
"arm" | "armv7" => match detect_hardware_floating_point_support() {
Ok(true) => target_lexicon::Environment::Gnueabihf,
Ok(false) => target_lexicon::Environment::Gnueabi,
Err(_) => target_lexicon::Environment::Gnu,
},
_ => target_lexicon::Environment::Gnu,
},
LibcVersion::Musllinux { .. } => target_lexicon::Environment::Musl,
})),
"windows" | "macos" => Ok(Self::None),