@@ -14,6 +14,27 @@ pub fn build_zlib_ng(target: &str, compat: bool) {
1414 . define ( "WITH_DFLTCC_INFLATE" , "1" )
1515 . cflag ( "-DDFLTCC_LEVEL_MASK=0x7e" ) ;
1616 }
17+ if target. contains ( "riscv" ) {
18+ // Check if we should pass on an explicit boolean value of the WITH_RVV build option.
19+ // See: https://github.com/zlib-ng/zlib-ng?tab=readme-ov-file#advanced-build-options
20+ if let Ok ( value) = env:: var ( "RISCV_WITH_RVV" ) {
21+ match value. trim ( ) . to_uppercase ( ) . as_str ( ) {
22+ "OFF" | "NO" | "FALSE" | "0" => {
23+ // Force RVV off. This turns off RVV entirely, as well as the runtime check for it.
24+ // This is not usually necessary, but can be useful for building binaries portable
25+ // to systems that do not support RVV but where auto-detection fails to identify
26+ // this (as in https://github.com/zlib-ng/zlib-ng/issues/1705).
27+ cmake. define ( "WITH_RVV" , "OFF" ) ;
28+ }
29+ "ON" | "YES" | "TRUE" | "1" => {
30+ // Try to use RVV, but still don't do so if a runtime check finds it unavailable.
31+ // This has the same effect as omitting WITH_RVV, unless it has already been set.
32+ cmake. define ( "WITH_RVV" , "ON" ) ;
33+ }
34+ _ => { }
35+ }
36+ }
37+ }
1738 if target == "i686-pc-windows-msvc" {
1839 cmake. define ( "CMAKE_GENERATOR_PLATFORM" , "Win32" ) ;
1940 }
0 commit comments