Better codegen for CPU feature detection

No? On Linux with musl libc (as opposed to glibc) this works perfectly fine. So you are going to have to explain your point of view here.

Again, musl doesn't support IFUNCs (neither when statically nor when dynamically linked), and that is an intentional design choice by them.

1 Like

FWIW a data race is UB even if both writes write the same data.

2 Likes

Is there any update on any of this getting implemented? Even something as simple as allowing users to query multiple features at once to prevent multiple redundant reads.

It's a bit annoying that this feature is still so suboptimal to use, which just directs users to other libraries (creating the xkcd 927 problem), especially since you'd expect features of the Rust standard library to be the best overall implementation of any given feature.

An ACP was accepted

It's different in a couple different ways:

is_x86_feature_detected! caches all of CPUID, then extracts the feature you ask for from the cache.

cpufeatures queries for a set of features, then stores if the combination you specify is present as an atomic. It should address at least one of the problems described, which was codegen for an && chain of features, but also generally the codegen should be more efficient since it does the check for the presence of the combination of features AOT, whereas is_x86_feature_detected! needs to extract it out of the cached CPUID.