Skip to content

Commit 3a1ea59

Browse files
committed
Basic idea for rvv-off feature
So far, this only attempts to have an effect when `cmake` is used, even though I documented it to be broader than that. In addition to testing this feature, it should either: - Be broadened to cover the non-`cmake` case (which I am unsure how to do, because which `-march` selection should be passed to `cc` varies according to other features too, which I believe `cmake` takes care of detecting), or - Have its documentation narrowed to say it only applies when `cmake` is used.
1 parent cbfee75 commit 3a1ea59

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Cargo-zng.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,11 @@ libc = "0.2.43"
3838
[build-dependencies]
3939
cmake = "0.1.50"
4040

41+
[features]
42+
# This feature builds riscv64 binaries portable to machines without RVV, even if the build machine
43+
# is riscv64 and detected to support RVV. This is useful for building a more portable binary, or on
44+
# systems where auto-detection is incorrect (as in https://github.com/zlib-ng/zlib-ng/issues/1705).
45+
rvv-off = []
46+
4147
[lints.rust]
4248
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zng)'] }

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ zlib-ng = ["libc", "cmake"]
8989
# or be completely removed in the future
9090
zlib-ng-no-cmake-experimental-community-maintained = ["libc"]
9191
stock-zlib = []
92+
# This feature only affects zlib-ng and is only relevant to riscv64 targets. It
93+
# builds binaries portable to machines without RVV, even if the build machine
94+
# is riscv64 and detected to support RVV. This is useful for building a more
95+
# portable binary, or on systems where auto-detection is incorrect
96+
# (as in https://github.com/zlib-ng/zlib-ng/issues/1705).
97+
rvv-off = []
9298
# Deprecated: the assembly routines are outdated, and either reduce performance
9399
# or cause segfaults.
94100
asm = []

zng/cmake.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub fn build_zlib_ng(target: &str, compat: bool) {
1414
.define("WITH_DFLTCC_INFLATE", "1")
1515
.cflag("-DDFLTCC_LEVEL_MASK=0x7e");
1616
}
17+
if cfg!(feature = "rvv-off") && target.contains("riscv64") {
18+
cmake.define("WITH_RVV", "OFF");
19+
}
1720
if target == "i686-pc-windows-msvc" {
1821
cmake.define("CMAKE_GENERATOR_PLATFORM", "Win32");
1922
}

0 commit comments

Comments
 (0)