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

Better use rust toolchain features for feature detection cfg(target_feature=) #381

Open
briansmith opened this issue Dec 15, 2016 · 2 comments

Comments

@briansmith
Copy link
Owner

briansmith commented Dec 15, 2016

When rust-lang/rust#29717 is stable, we should use that feature to do static feature detection.

In the case of 32-bit x86, we'll probably never use static feature detection. Instead, we'll always just use dynamic feature detection.

In the case of 64-bit x86-64, we'll probably only use positive feature detection, because the uesfulness of static feature detection on x86-64 seems limited to only be eliminating overhead for supporting legacy platforms. That is, we'll only use #[cfg(target_feature=)] and not #[cfg(not(target_feature=))].

In the case of ARM (ARMv{6,7}, AAarch32, and Aarch64), we'll start with positive feature detection only.

Later, we'll add negative feature detection for ARM. Negative feature detection needs to be augmented so that we can distinguish between "the target isn't guaranteed to support this feature, but ring should detect it at runtime" and "the code and feature detection for this feature should be entirely omitted because it is unwanted." For example, when compiling for a specific microcontroller, no feature detection logic should be included, and only one implementation of each primitive should be included. We can probably do this by having a "runtime-cpu-feature-detection" default feature that, when disabled, would cause #[cfg(not(target_feature="..."))] to be interpreted as "the code and feature detection for this feature should be entirely omitted because it is unwanted."

@briansmith
Copy link
Owner Author

Note that, in order for this to work optimally, we'll probably have to pull all the feature detection logic out of the asm code and move it to Rust (or C).

@briansmith
Copy link
Owner Author

This is done for AArch64 and ARM, but not for Intel yet.

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

No branches or pull requests

1 participant