Skip to content

Commit

Permalink
Merge pull request #218 from EliahKagan/rvv-off
Browse files Browse the repository at this point in the history
Recognize `RISCV_WITH_RVV` env var on RISC-V to set `WITH_RVV` cmake var
  • Loading branch information
Byron authored Sep 23, 2024
2 parents cbfee75 + 8636464 commit 1742670
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions zng/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ pub fn build_zlib_ng(target: &str, compat: bool) {
.define("WITH_DFLTCC_INFLATE", "1")
.cflag("-DDFLTCC_LEVEL_MASK=0x7e");
}
if target.contains("riscv") {
// Check if we should pass on an explicit boolean value of the WITH_RVV build option.
// See: https://github.com/zlib-ng/zlib-ng?tab=readme-ov-file#advanced-build-options
if let Ok(value) = env::var("RISCV_WITH_RVV") {
match value.trim().to_uppercase().as_str() {
"OFF" | "NO" | "FALSE" | "0" => {
// Force RVV off. This turns off RVV entirely, as well as the runtime check for it.
// This is not usually necessary, but can be useful for building binaries portable
// to systems that do not support RVV but where auto-detection fails to identify
// this (as in https://github.com/zlib-ng/zlib-ng/issues/1705).
cmake.define("WITH_RVV", "OFF");
}
"ON" | "YES" | "TRUE" | "1" => {
// Try to use RVV, but still don't do so if a runtime check finds it unavailable.
// This has the same effect as omitting WITH_RVV, unless it has already been set.
cmake.define("WITH_RVV", "ON");
}
_ => {}
}
}
}
if target == "i686-pc-windows-msvc" {
cmake.define("CMAKE_GENERATOR_PLATFORM", "Win32");
}
Expand Down

0 comments on commit 1742670

Please sign in to comment.