From 1268eef3b21bb7d81ac82faa50d81f3db3b844c5 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Thu, 24 Jun 2021 09:41:47 -0600 Subject: [PATCH] Revert "Clean up build warning" This reverts commit 17a173ebb5cb87271069abdaa0fb9c01d4c8d9d4. (cherry picked from commit d2699757844cadf2af7bfc318f8cc712af5f01da) --- core/src/validator.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 34e83d9795..86472d69d3 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -1430,17 +1430,22 @@ fn report_target_features() { not(target_os = "macos") ))] { - // 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. - if is_x86_feature_detected!("avx") { - info!("AVX detected"); - } else { - error!( - "Your machine does not have AVX support, please rebuild from source on your machine" - ); - abort(); - } + unsafe { check_avx() }; + } +} + +// 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")] +unsafe fn check_avx() { + if is_x86_feature_detected!("avx") { + info!("AVX detected"); + } else { + error!( + "Your machine does not have AVX support, please rebuild from source on your machine" + ); + abort(); } }