Skip to content

Commit 4b8560e

Browse files
authored
make : fix clang++ detection, move some definitions to CPPFLAGS (#3155)
* make : fix clang++ detection * make : fix compiler definitions outside of CPPFLAGS
1 parent 83a53b7 commit 4b8560e

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

Makefile

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,50 +110,42 @@ MK_LDFLAGS =
110110
# CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional
111111
# posix_memalign came in POSIX.1-2001 / SUSv3
112112
# M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985)
113-
MK_CFLAGS += -D_XOPEN_SOURCE=600
114-
MK_CXXFLAGS += -D_XOPEN_SOURCE=600
113+
MK_CPPFLAGS += -D_XOPEN_SOURCE=600
115114

116115
# Somehow in OpenBSD whenever POSIX conformance is specified
117116
# some string functions rely on locale_t availability,
118117
# which was introduced in POSIX.1-2008, forcing us to go higher
119118
ifeq ($(UNAME_S),OpenBSD)
120-
MK_CFLAGS += -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700
121-
MK_CXXFLAGS += -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700
119+
MK_CPPFLAGS += -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700
122120
endif
123121

124122
# Data types, macros and functions related to controlling CPU affinity and
125123
# some memory allocation are available on Linux through GNU extensions in libc
126124
ifeq ($(UNAME_S),Linux)
127-
MK_CFLAGS += -D_GNU_SOURCE
128-
MK_CXXFLAGS += -D_GNU_SOURCE
125+
MK_CPPFLAGS += -D_GNU_SOURCE
129126
endif
130127

131128
# RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1,
132129
# and on macOS its availability depends on enabling Darwin extensions
133130
# similarly on DragonFly, enabling BSD extensions is necessary
134131
ifeq ($(UNAME_S),Darwin)
135-
MK_CFLAGS += -D_DARWIN_C_SOURCE
136-
MK_CXXFLAGS += -D_DARWIN_C_SOURCE
132+
MK_CPPFLAGS += -D_DARWIN_C_SOURCE
137133
endif
138134
ifeq ($(UNAME_S),DragonFly)
139-
MK_CFLAGS += -D__BSD_VISIBLE
140-
MK_CXXFLAGS += -D__BSD_VISIBLE
135+
MK_CPPFLAGS += -D__BSD_VISIBLE
141136
endif
142137

143138
# alloca is a non-standard interface that is not visible on BSDs when
144139
# POSIX conformance is specified, but not all of them provide a clean way
145140
# to enable it in such cases
146141
ifeq ($(UNAME_S),FreeBSD)
147-
MK_CFLAGS += -D__BSD_VISIBLE
148-
MK_CXXFLAGS += -D__BSD_VISIBLE
142+
MK_CPPFLAGS += -D__BSD_VISIBLE
149143
endif
150144
ifeq ($(UNAME_S),NetBSD)
151-
MK_CFLAGS += -D_NETBSD_SOURCE
152-
MK_CXXFLAGS += -D_NETBSD_SOURCE
145+
MK_CPPFLAGS += -D_NETBSD_SOURCE
153146
endif
154147
ifeq ($(UNAME_S),OpenBSD)
155-
MK_CFLAGS += -D_BSD_SOURCE
156-
MK_CXXFLAGS += -D_BSD_SOURCE
148+
MK_CPPFLAGS += -D_BSD_SOURCE
157149
endif
158150

159151
ifdef LLAMA_DEBUG
@@ -182,7 +174,7 @@ MK_CFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow
182174
-Wmissing-prototypes -Werror=implicit-int -Wno-unused-function
183175
MK_CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar
184176

185-
ifeq '' '$(findstring clang++,$(CXX))'
177+
ifeq '' '$(findstring clang,$(shell $(CXX) --version))'
186178
# g++ only
187179
MK_CXXFLAGS += -Wno-format-truncation -Wno-array-bounds
188180
endif

0 commit comments

Comments
 (0)