From a75bb78c9b904c1bd50200cdaaef999a5aca2e41 Mon Sep 17 00:00:00 2001
From: Vladimir Komendantskiy <komendantsky@gmail.com>
Date: Wed, 20 May 2020 22:44:38 +0100
Subject: [PATCH 1/2] unforced avx and avx2 features

---
 core/src/validator.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/src/validator.rs b/core/src/validator.rs
index 72921a2a83f3c9..cffb51f0e3c018 100644
--- a/core/src/validator.rs
+++ b/core/src/validator.rs
@@ -774,7 +774,7 @@ fn report_target_features() {
         // Validator binaries built on a machine with AVX support will generate invalid opcodes
         // when run on machines without AVX causing a non-obvious process abort.  Instead detect
         // the mismatch and error cleanly.
-        #[target_feature(enable = "avx")]
+        #[cfg(target_feature = "avx")]
         {
             if is_x86_feature_detected!("avx") {
                 info!("AVX detected");
@@ -783,7 +783,7 @@ fn report_target_features() {
                 process::exit(1);
             }
         }
-        #[target_feature(enable = "avx2")]
+        #[cfg(target_feature = "avx2")]
         {
             if is_x86_feature_detected!("avx2") {
                 info!("AVX2 detected");

From 6071c0d209c6a24e5e538573817b02a91f1e6e21 Mon Sep 17 00:00:00 2001
From: Vladimir Komendantskiy <komendantsky@gmail.com>
Date: Mon, 25 May 2020 23:53:08 +0100
Subject: [PATCH 2/2] added RUSTFLAGS in the install script

---
 scripts/cargo-install-all.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/cargo-install-all.sh b/scripts/cargo-install-all.sh
index 02fb81f7a40fc3..6a1437a6642b1c 100755
--- a/scripts/cargo-install-all.sh
+++ b/scripts/cargo-install-all.sh
@@ -51,6 +51,8 @@ fi
 installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)"
 mkdir -p "$installDir/bin/deps"
 cargo=cargo
+# Trigger the selection of the correct set of processor features such as AVX2.
+RUSTFLAGS="$RUSTFLAGS -C target-cpu=native"
 
 echo "Install location: $installDir ($buildVariant)"