Skip to content

Commit 2bf74bc

Browse files
committed
chore(build): rework clang version detection for Apple compilers
1 parent 40cbbb0 commit 2bf74bc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

include/Makefile.global.in

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,22 @@ ifeq ($(IS_GCC),1)
118118

119119
else ifeq ($(IS_CLANG),1)
120120

121-
# Only compute CLANG_MAJOR for clang
122-
CLANG_MAJOR := $(shell echo '$(CC_VERSION)' | \
123-
sed -n 's/.*clang-\([0-9][0-9]*\)\..*/\1/p; \
124-
s/.*LLVM version \([0-9][0-9]*\)\..*/\1/p; \
125-
s/.*clang version \([0-9][0-9]*\)\..*/\1/p')
121+
# Only compute CLANG_MAJOR for clang. More tricky, since we have to
122+
# deal with Apple variants as well
126123

127-
# Clang > 13 (i.e. >= 14): enable extensive checks
124+
CLANG_MAJOR := $(shell printf '%s\n' '$(CC_VERSION)' | \
125+
sed -n 's/.*based on LLVM \([0-9][0-9]*\)\..*/\1/p; \
126+
s/.*clang version \([0-9][0-9]*\)\..*/\1/p; \
127+
s/.*LLVM version \([0-9][0-9]*\)\..*/\1/p; \
128+
s/.*clang-\([0-9][0-9]*\)\..*/\1/p' | \
129+
head -n 1)
130+
131+
#$(info CC_VERSION = '$(CC_VERSION)')
132+
#$(info CLANG_MAJOR = '$(CLANG_MAJOR)')
133+
134+
# Clang > 3.* (i.e. >= 4): enable more extensive checks
128135
ifneq ($(CLANG_MAJOR),)
129-
ifeq ($(call lt,$(CLANG_MAJOR),14),0)
136+
ifeq ($(call lt,$(CLANG_MAJOR),4),0)
130137
CFLAGS_CONVERSION_DEFAULT = -Wconversion -Wsign-conversion -Wbad-function-cast -Wcast-align
131138
CFLAGS_FORMAT_DEFAULT = -Wmissing-format-attribute -Wformat-security -Wformat=2
132139
CFLAGS_DEFINITION_DEFAULT = -Wwrite-strings -Wdeclaration-after-statement -Wmissing-prototypes -Wmissing-declarations

0 commit comments

Comments
 (0)