Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize RISCV_WITH_RVV env var on RISC-V to set WITH_RVV cmake var #218

Merged
merged 8 commits into from
Sep 23, 2024
Prev Previous commit
Next Next commit
Also recognize an environment variable
To aid in testing, and possibly as something that should even be
kept in some form, this checks if an `RVV_OFF` environment variable
is set and, if so, behaves as though the `rvv-off` feature is
enabled, whether that feature is actually enabled or not.
  • Loading branch information
EliahKagan committed Sep 22, 2024
commit d76bc6d74e92fc21653906fe2ec1d3d342fbf887
2 changes: 1 addition & 1 deletion zng/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn build_zlib_ng(target: &str, compat: bool) {
.define("WITH_DFLTCC_INFLATE", "1")
.cflag("-DDFLTCC_LEVEL_MASK=0x7e");
}
if cfg!(feature = "rvv-off") && target.contains("riscv64") {
if target.contains("riscv64") && (cfg!(feature = "rvv-off") || env::var_os("RVV_OFF").is_some()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I prefer "positive" features over "negative" features. By this I mean that the feature sounds like it adds something rather than taking something away.

For example, you could name the environment variable WITH_RVV and allowing the values ON and OFF. This would be familiar to someone who knows the zlib-ng build. It would allow forcing the use of RVV if there was ever a case where it was disabled.

You could name the feature with-rvv. However this would require the default to compile without RVV. This has the advantage of working in more places, at the cost of behaving differently to the default behavior of zlib-ng.

cmake.define("WITH_RVV", "OFF");
}
if target == "i686-pc-windows-msvc" {
Expand Down