Run-time CPU feature detection

June 25, 2026 ยท View on GitHub

This module has run-time CPU feature detection implementations.

Here is the table of targets that support run-time CPU feature detection and the instruction or API used:

target_archtarget_os/target_envinstruction/APIfeaturesnote
x86_64all (except for sgx)cpuidallEnabled by default
aarch64linux (gnu/ohos/uclibc)getauxvalallEnabled by default (dlsym is used by default if needed for compatibility with older versions)
aarch64linux (musl)getauxvalallOnly enabled by default when dynamic linking or std feature enabled (both disabled by default, see auxv.rs)
aarch64androidgetauxvalallEnabled by default
aarch64freebsdelf_aux_infoallEnabled by default
aarch64netbsdsysctlbynameallEnabled by default
aarch64openbsdsysctlallEnabled by default
aarch64macos/ios/tvos/watchos/visionossysctlbynameallEnabled by default
aarch64illumosgetisaxlse, lse2Enabled by default
aarch64/arm64ecwindowsIsProcessorFeaturePresentlse, lse2Enabled by default
aarch64fuchsiazx_system_get_featureslseEnabled by default
riscv32/riscv64linux/androidriscv_hwprobeallEnabled by default
powerpc64linux (gnu/ohos/uclibc)getauxvalallEnabled by default (dlsym is used by default if needed for compatibility with older versions)
powerpc64linux (musl)getauxvalallOnly enabled by default when dynamic linking or std feature enabled (both disabled by default, see auxv.rs)
powerpc64freebsdelf_aux_infoallEnabled by default (dlsym is used by default for compatibility with older versions)
powerpc64openbsdelf_aux_infoallEnabled by default (dlsym is used by default for compatibility with older versions)
powerpc64aixgetsystemcfgallRequires LLVM 20+. Disabled by default (see powerpc64_aix.rs)

Run-time detection is enabled by default on most targets and can be disabled with --cfg portable_atomic_no_outline_atomics.

On some targets, run-time detection is disabled by default mainly for compatibility with incomplete build environments or support for it is experimental, and can be enabled by --cfg portable_atomic_outline_atomics. (When both cfg are enabled, *_no_* cfg is preferred.)

dlsym usually not working with static linking, so detection using implementations that use dlsym for compatibility will be disabled if static linking is enabled. You can use --cfg portable_atomic_outline_atomics to force the use of non-dlsym implementations and enable run-time detection in such an environment.

For targets not included in the above table, run-time detection is always disabled and works the same as when --cfg portable_atomic_no_outline_atomics is set.

See auxv.rs module-level comments for more details on Linux/Android/FreeBSD/OpenBSD.

See also docs about portable_atomic_no_outline_atomics cfg in the top-level readme.