From cad6e50b2e477f5efb4f64206491e07f97fc2e9f Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Mon, 2 May 2022 10:14:13 +0200 Subject: [PATCH] Use more target features to build librocksdb-sys (#620) --- librocksdb-sys/build.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index d33e9b4..cfa2fec 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -123,7 +123,20 @@ fn build_rocksdb() { config.flag_if_supported("-msse4.2"); config.define("HAVE_SSE42", Some("1")); } - + // Pass along additional target features as defined in + // build_tools/build_detect_platform. + if target_features.contains(&"avx2") { + config.flag_if_supported("-mavx2"); + config.define("HAVE_AVX2", Some("1")); + } + if target_features.contains(&"bmi1") { + config.flag_if_supported("-mbmi"); + config.define("HAVE_BMI", Some("1")); + } + if target_features.contains(&"lzcnt") { + config.flag_if_supported("-mlzcnt"); + config.define("HAVE_LZCNT", Some("1")); + } if !target.contains("android") && target_features.contains(&"pclmulqdq") { config.define("HAVE_PCLMUL", Some("1")); config.flag_if_supported("-mpclmul"); @@ -211,6 +224,7 @@ fn build_rocksdb() { } else { config.flag(&cxx_standard()); // matches the flags in CMakeLists.txt from rocksdb + config.define("HAVE_UINT128_EXTENSION", Some("1")); config.flag("-Wsign-compare"); config.flag("-Wshadow"); config.flag("-Wno-unused-parameter");