Do not attempt to check host CPU if TARGET is set.

This wired 'autodetection' breaks DYNAMIC arch (or makes the build
unreproducible) and will most likely not work with cross compiling.

Presently, this is only relevant for SkylakeX, Cooperlake and
Sapphire Rapids cores, that's what has been implemented. Going
forward, other cores would have to be added here as well (in sync
with Markfile.$(arch) as this needs to be kept in sync with changes
to getarch.
It would be better to remove this hack (and the counterpart in
getarch) entirely.
This fixes issue #3557.

Signed-off-by: Egbert Eich <eich@suse.com>
This commit is contained in:
Egbert Eich 2022-03-01 18:18:54 +01:00
parent 51c11cf4bf
commit 943ffbb778
3 changed files with 14 additions and 6 deletions

View File

@ -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. # 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 ($(HOSTARCH), x86_64)
ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),) ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),)
GETARCH_FLAGS += -march=native ifdef TARGET
endif GETARCH_NOPROBE=1
endif
ifdef TARGET_CORE
GETARCH_NOPROBE=1
endif
ifndef GETARCH_NOPROBE
GETARCH_FLAGS += -march=native -DAUTOPROBE
endif
endif
endif endif
ifdef INTERFACE64 ifdef INTERFACE64

View File

@ -55,8 +55,8 @@ if (DEFINED TARGET)
endif () endif ()
# On x86_64 build getarch with march=native. This is required to detect AVX512 support in getarch. # 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") if (X86_64 AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT DEFINED TARGET)
set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native") set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native -DAUTOPROBE")
endif () endif ()
# On x86 no AVX support is available # On x86 no AVX support is available

View File

@ -94,7 +94,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#endif #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)) #if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6))
#else #else
#ifndef NO_AVX512 #ifndef NO_AVX512