From 51e8872804971cb6022913c47671addc8de774bd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2020 10:50:36 +0000 Subject: [PATCH] Fix avx check with newest nightly compiler (#13465) (#13809) (cherry picked from commit c644b05c5456b3be056eb10efb90226c8d1ff30a) Co-authored-by: sakridge --- core/src/validator.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 82c51214f9..7740970a25 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -947,18 +947,22 @@ fn report_target_features() { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - // 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")] - { - 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"); - process::exit(1); - } - } + 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" + ); + process::exit(1); } }