Skip to content

Tracking Issue for CPUID target feature #146558

@sayantn

Description

@sayantn

The feature gate for the issue is #![feature(cpuid_target_feature)].

Motivation

The x86 CPUID instruction is extremely useful in determining what CPU features are available during runtime. core::arch::x86::__cpuid and friends are a useful tool to call CPUID without writing the ASM yourself, but these are marked unsafe, and can't be made safe currently because

  • very old CPUs that don't support it
  • target_env = "sgx" doesn't support it

So, we introduce a detection-only (no codegen effects) target feature cpuid, which will guard the core::arch::x86::__cpuid function and friends. It is implied from all other x86 target features (except for soft-float), so for most cases __cpuid will be safe to call, and in general, users will be able to check if it is callable by is_x86_feature_detected!("cpuid").

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Unresolved Questions

  • Should x87 and soft-float imply cpuid?

Implementation history

@rustbot label O-x86_32 O-x86_64 T-libs-api A-target-feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)O-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions