-
Notifications
You must be signed in to change notification settings - Fork 1.7k
uv python install: Detect hard-float support #7725
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Fetches CPU information. | ||
|
||
use anyhow::Error; | ||
#[cfg(target_os = "linux")] | ||
use procfs::{CpuInfo, Current}; | ||
|
||
/// Detects whether the hardware supports floating-point operations using ARM's Vector Floating Point (VFP) hardware. | ||
/// | ||
/// This function is relevant specifically for ARM architectures, where the presence of the "vfp" flag in `/proc/cpuinfo` | ||
/// indicates that the CPU supports hardware floating-point operations. | ||
/// This helps determine whether the system is using the `gnueabihf` (hard-float) ABI or `gnueabi` (soft-float) ABI. | ||
/// | ||
/// More information on this can be found in the [Debian ARM Hard Float Port documentation](https://wiki.debian.org/ArmHardFloatPort#VFP). | ||
#[cfg(target_os = "linux")] | ||
pub(crate) fn detect_hardware_floating_point_support() -> Result<bool, Error> { | ||
let cpu_info = CpuInfo::current()?; | ||
|
||
// Iterate through each core and check if the "vfp" flag is present, | ||
// indicating hardware floating-point support. | ||
for num in 0..cpu_info.num_cores() { | ||
if let Some(flags) = cpu_info.flags(num) { | ||
if flags.contains(&"vfp") { | ||
kakkoyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Ok(true); // Hardware floating-point (gnueabihf) detected. | ||
} | ||
} | ||
} | ||
|
||
Ok(false) // Default to soft-float (gnueabi) if no "vfp" flag is found | ||
} | ||
|
||
/// For non-Linux systems or architectures, the function will return `false` as hardware floating-point detection | ||
/// is not applicable outside of Linux ARM architectures. | ||
#[cfg(not(target_os = "linux"))] | ||
#[allow(clippy::unnecessary_wraps)] | ||
pub(crate) fn detect_hardware_floating_point_support() -> Result<bool, Error> { | ||
Ok(false) // Non-Linux or non-ARM systems: hardware floating-point detection is not applicable | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.