diff --git a/Makefile.system b/Makefile.system index ff15b6400..0203e7c72 100644 --- a/Makefile.system +++ b/Makefile.system @@ -197,9 +197,17 @@ endif # On x86_64 build getarch with march=native unless the compiler is PGI. This is required to detect AVX512 support in getarch. ifeq ($(HOSTARCH), x86_64) -ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),) -GETARCH_FLAGS += -march=native -endif + ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),) + ifdef TARGET +GETARCH_NOPROBE=1 + endif + ifdef TARGET_CORE +GETARCH_NOPROBE=1 + endif + ifndef GETARCH_NOPROBE +GETARCH_FLAGS += -march=native -DAUTOPROBE + endif + endif endif ifdef INTERFACE64 diff --git a/cmake/system.cmake b/cmake/system.cmake index e0e92bde7..27c453906 100644 --- a/cmake/system.cmake +++ b/cmake/system.cmake @@ -55,8 +55,8 @@ if (DEFINED TARGET) endif () # On x86_64 build getarch with march=native. This is required to detect AVX512 support in getarch. -if (X86_64 AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "PGI") - set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native") +if (X86_64 AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT DEFINED TARGET) + set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native -DAUTOPROBE") endif () # On x86 no AVX support is available diff --git a/getarch.c b/getarch.c index 00e544bc7..3adf530f5 100644 --- a/getarch.c +++ b/getarch.c @@ -94,7 +94,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif -#if defined(__x86_64__) || defined(_M_X64) +#if defined (AUTOPROBE) && (defined(__x86_64__) || defined(_M_X64)) #if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6)) #else #ifndef NO_AVX512