Skip to content

Commit

Permalink
Conditionally enable avx2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
berbiche authored and AntoineGagne committed Jun 3, 2024
1 parent 43bfc6d commit d4ff942
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion c_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif

CC = gcc

GEN_CFLAGS = -finline-functions -mavx2 -fPIC \
GEN_CFLAGS = -finline-functions -fPIC \
-std=gnu99 -Wall -Wextra -Wno-missing-field-initializers

UNAME_SYS := $(shell uname -s)
Expand All @@ -28,6 +28,17 @@ ifeq ($(UNAME_SYS), Darwin)
LDFLAGS ?= -flat_namespace -undefined suppress
endif

HAS_AVX2 := $(shell \
if $(CC) -O -mavx2 -o $(BASEDIR)/../test_for_rdrand ./test_for_rdrand.c 2>/dev/null; then \
echo 1; \
else \
echo 0; \
fi; \
)
ifeq ($(HAS_AVX2), 1)
GEN_CFLAGS += -mavx2
endif

HAS_RDRAND := $(shell \
if $(CC) -O -o $(BASEDIR)/../test_for_rdrand ./test_for_rdrand.c 2>/dev/null; then \
$(BASEDIR)/../test_for_rdrand && echo 1; \
Expand Down

0 comments on commit d4ff942

Please sign in to comment.