Skip to content

Commit 7a9a4db

Browse files
committed
Fix detection of AVX512 capable compilers in getarch
21eda8b introduced a check in getarch.c to test if the compiler is capable of AVX512. This check currently fails, since the used __AVX2__ macro is only defined if getarch itself was compiled with AVX2/AVX512 support. Make sure this is the case by building getarch with -march=native on x86_64. It is only supposed to run on the build host anyway.
1 parent 27649b9 commit 7a9a4db

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Makefile.system

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ ifndef TOPDIR
99
TOPDIR = .
1010
endif
1111

12+
# If ARCH is not set, we use the host system's architecture.
13+
ifndef ARCH
14+
ARCH := $(shell uname -m)
15+
endif
16+
1217
# Catch conflicting usage of ARCH in some BSD environments
1318
ifeq ($(ARCH), amd64)
1419
override ARCH=x86_64
@@ -137,6 +142,10 @@ endif
137142
endif
138143

139144

145+
# On x86_64 build getarch with march=native. This is required to detect AVX512 support in getarch.
146+
ifeq ($(ARCH), x86_64)
147+
GETARCH_FLAGS += -march=native
148+
endif
140149

141150

142151
ifdef INTERFACE64

cmake/system.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ if (DEFINED TARGET)
6565
set(GETARCH_FLAGS "-DFORCE_${TARGET}")
6666
endif ()
6767

68+
# On x86_64 build getarch with march=native. This is required to detect AVX512 support in getarch.
69+
if (X86_64)
70+
set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native")
71+
endif ()
72+
6873
if (INTERFACE64)
6974
message(STATUS "Using 64-bit integers.")
7075
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DUSE64BITINT")

0 commit comments

Comments
 (0)