Skip to content
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

Detect CPU features at build time #58

Closed
wants to merge 3 commits into from
Closed

Conversation

ogxd
Copy link
Owner

@ogxd ogxd commented Jan 5, 2024

No description provided.

@ogxd ogxd self-assigned this Jan 5, 2024
@ogxd ogxd force-pushed the build-time-feature-detection branch from 0c90808 to 570e986 Compare January 5, 2024 19:22
@ogxd ogxd linked an issue Jan 5, 2024 that may be closed by this pull request
@notsatvrn
Copy link
Contributor

is_aarch64_feature_detected is available, and also is_arm_feature_detected with the stdsimd feature enabled. ARM32 support actually depends on this feature to work, something I didn't notice when writing #53. These should be added.

@ogxd
Copy link
Owner Author

ogxd commented Jan 6, 2024

I tried using https://github.com/cross-rs/cross to try out building for various platforms. It seems the target_arch in the build.rs does not match the actual target platform for some reason, while the environment variable CARGO_CFG_TARGET_ARCH does have the appropriate value. This is annoying because using is_x86_feature_detected requires usage #[cfg(any(target_arch = "x86", target_arch = "x86_64"))].

For instance when doing cross test --target aarch64-unknown-linux-gnu, target_arch in build.rs is x86_64, so it does not check for the correct target features. It looks like an universally complex topic. In the meantime I am also exploring the runtime feature resolution, but that would require a fallback, as we don't want the crate to build but to panic at runtime.

@ogxd ogxd changed the title Detect CPU features at build time Draft: Detect CPU features at build time Jan 6, 2024
@ogxd ogxd marked this pull request as draft January 6, 2024 16:59
@ogxd ogxd changed the title Draft: Detect CPU features at build time Detect CPU features at build time Jan 6, 2024
@ogxd ogxd closed this Jan 20, 2024
@ogxd
Copy link
Owner Author

ogxd commented Jan 20, 2024

Closed in favor of #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error[E0432]: unresolved import platform
2 participants