Skip to content

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

@briansmith

Description

@briansmith

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."

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions