stdarch icon indicating copy to clipboard operation
stdarch copied to clipboard

std_detect::detect::features() is not available

Open ronnychevalier opened this issue 2 years ago • 3 comments

While std_detect::detect::features() is declared as pub, it is not exposed in std and the latest version of std_detect available on crates.io (0.1.5, 4 years ago) does not contain this function. To access this function, one must depend on the git repository.

Would it be possible to release a new version of std_detect on crates.io? or expose std_detect::detect::features() in std like other functions of this crate?

ronnychevalier avatar Feb 26 '23 22:02 ronnychevalier

I don't think we want to expose this, and it's not clear that releasing std_detect on crates.io is the right call either these days...

What's the use case you need it for? Avoiding multiple calls to std::is_*_feature_detected?

thomcc avatar Feb 26 '23 23:02 thomcc

I have a cargo subcommand that builds multiple versions of the same binary, each with a different CPU features set, merged into a single binary. At runtime it runs the optimized version based on the list of CPU features supported by the host. I rely on std_detect::detect::features() to know the CPU features supported at runtime.

ronnychevalier avatar Feb 26 '23 23:02 ronnychevalier

The proper interface to use is the is_*_features_detected macros. Anything else is an internal implementation detail and not supported.

Amanieu avatar Feb 27 '23 14:02 Amanieu