Skip to content

Commit 5041188

Browse files
committed
Improve modularity of GCC compatibility resolution
This is a minor update that uses more sophisticated methods to validate the supported compiler arguments.
1 parent 85f4e9c commit 5041188

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ BENCHS = $(wildcard $(BENCHDIR)/*.cpp)
1616
TESTOBJS = $(patsubst $(TESTDIR)/%.cpp,$(TESTDIR)/%.o,$(TESTS))
1717
BENCHOBJS = $(patsubst $(BENCHDIR)/%.cpp,$(BENCHDIR)/%.o,$(BENCHS))
1818

19-
# Compiling AVX512-FP16 instructions isn't possible for g++ < 12
20-
ifeq ($(shell expr `$(CXX) -dumpversion | cut -d '.' -f 1` \< 12), 1)
21-
MARCHFLAG = -march=icelake-client
22-
BENCHOBJS_SKIP += bench-qsortfp16.o
23-
TESTOBJS_SKIP += test-qsortfp16.o
19+
test_cxx_flag = $(shell 2>/dev/null $(CXX) -o /dev/null $(1) -c -x c++ /dev/null; echo $$?)
20+
21+
# Compiling AVX512-FP16 instructions wasn't possible until GCC 12
22+
ifeq ($(call test_cxx_flag,-mavx512fp16), 1)
23+
BENCHOBJS_SKIP += bench-qsortfp16.o
24+
TESTOBJS_SKIP += test-qsortfp16.o
25+
endif
26+
27+
# Sapphire Rapids was otherwise supported from GCC 11. Downgrade if required.
28+
ifeq ($(call test_cxx_flag,$(MARCHFLAG)), 1)
29+
MARCHFLAG = -march=icelake-client
2430
endif
2531

2632
BENCHOBJS := $(filter-out $(addprefix $(BENCHDIR)/, $(BENCHOBJS_SKIP)) ,$(BENCHOBJS))

0 commit comments

Comments
 (0)