Skip to content

Commit 3866058

Browse files
David Carrillo-Cisnerosacmel
authored andcommitted
perf tools: Robustify detection of clang binary
Prior to this patch, make scripts tested for CLANG with ifeq ($(CC), clang), failing to detect CLANG binaries with different names. Fix it by testing for the existence of __clang__ macro in the list of compiler defined macros. Signed-off-by: David Carrillo-Cisneros <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Paul Turner <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 12024aa commit 3866058

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

tools/lib/api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LIBFILE = $(OUTPUT)libapi.a
1919
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
2020
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
2121

22-
ifeq ($(CC), clang)
22+
ifeq ($(CC_NO_CLANG), 0)
2323
CFLAGS += -O3
2424
else
2525
CFLAGS += -O6

tools/lib/subcmd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LIBFILE = $(OUTPUT)libsubcmd.a
2121
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
2222
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
2323

24-
ifeq ($(CC), clang)
24+
ifeq ($(CC_NO_CLANG), 0)
2525
CFLAGS += -O3
2626
else
2727
CFLAGS += -O6

tools/perf/Makefile.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ ifndef DEBUG
148148
endif
149149

150150
ifeq ($(DEBUG),0)
151-
ifeq ($(CC), clang)
151+
ifeq ($(CC_NO_CLANG), 0)
152152
CFLAGS += -O3
153153
else
154154
CFLAGS += -O6
@@ -184,7 +184,7 @@ ifdef PYTHON_CONFIG
184184
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
185185
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
186186
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
187-
ifeq ($(CC), clang)
187+
ifeq ($(CC_NO_CLANG), 1)
188188
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
189189
endif
190190
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)

tools/perf/util/intel-pt-decoder/Build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/in
2525

2626
CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder
2727

28-
ifneq ($(CC), clang)
28+
ifeq ($(CC_NO_CLANG), 1)
2929
CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init
3030
endif

tools/scripts/Makefile.include

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ EXTRA_WARNINGS += -Wundef
3939
EXTRA_WARNINGS += -Wwrite-strings
4040
EXTRA_WARNINGS += -Wformat
4141

42-
ifneq ($(CC), clang)
42+
CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
43+
44+
ifeq ($(CC_NO_CLANG), 1)
4345
EXTRA_WARNINGS += -Wstrict-aliasing=3
4446
endif
4547

0 commit comments

Comments
 (0)