BLAKE3-team / BLAKE3

the official Rust and C implementations of the BLAKE3 cryptographic hash function
Apache License 2.0
4.71k stars 315 forks source link

factor out RISCV support from the guts_api branch #375

Open oconnor663 opened 5 months ago

oconnor663 commented 5 months ago

TODO: figure out what environment variable should enable this

silvanshade commented 5 months ago

TODO: figure out what environment variable should enable this

In the RVV support for the rust crypto packages that I've been working on, I've generally been following the scheme where first, the feature gate for v is used (e.g., #[cfg(target_feature = "v")]) and then, for the extensions which don't have corresponding Rust features yet (but are exposed to the LLVM code generator), I've been adding cfg flags that follow the naming scheme target_feature_<ext>.

The intention is that these cfg flags would be replaced by proper target_feature gates once the features are exposed to Rust.

If you followed that scheme here, you'd end up with something like this:

#[cfg(all(target_feature = "v", target_feature = "zbb", target_feature_zvbb))]
...

If you're trying to parse this through the environment variables, it looks like the variable CARGO_CFG_TARGET_FEATURE is set to a comma separated list of the target features enabled. You should be able to get general cfg flags from CARGO_CFG_<cfg>, so then target_feature_zvbb should be set as CARGO_CFG_TARGET_FEATURE_ZVBB. Referenced here.