Skip to content

Detect CPU features at build time#58

Closed
ogxd wants to merge 3 commits into
mainfrom
build-time-feature-detection
Closed

Detect CPU features at build time#58
ogxd wants to merge 3 commits into
mainfrom
build-time-feature-detection

Conversation

@ogxd

@ogxd ogxd commented Jan 5, 2024

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

ogxd commented Jan 6, 2024

Copy link
Copy Markdown
Owner Author

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

ogxd commented Jan 20, 2024

Copy link
Copy Markdown
Owner Author

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