From 44dc84171adefbbe75a25b72c35f773a643655a0 Mon Sep 17 00:00:00 2001 From: Resende <17102689+ZePedroResende@users.noreply.github.com> Date: Wed, 22 Mar 2023 15:34:44 +0000 Subject: [PATCH] Enable librocksdb-sys to be built by rustc_codegen_cranelift (#760) --- librocksdb-sys/build.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 7cbe5c5..94526e1 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -101,12 +101,15 @@ fn build_rocksdb() { .filter(|file| !matches!(*file, "util/build_version.cc")) .collect::>(); - if target.contains("x86_64") { + if let (true, Ok(target_feature_value)) = ( + target.contains("x86_64"), + env::var("CARGO_CFG_TARGET_FEATURE"), + ) { // This is needed to enable hardware CRC32C. Technically, SSE 4.2 is // only available since Intel Nehalem (about 2010) and AMD Bulldozer // (about 2011). - let target_feature = env::var("CARGO_CFG_TARGET_FEATURE").unwrap(); - let target_features: Vec<_> = target_feature.split(',').collect(); + let target_features: Vec<_> = target_feature_value.split(',').collect(); + if target_features.contains(&"sse2") { config.flag_if_supported("-msse2"); }