Skip to content

Commit

Permalink
perf tools: Robustify detection of clang binary
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
David Carrillo-Cisneros authored and acmel committed Aug 28, 2017
1 parent 12024aa commit 3866058
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tools/lib/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LIBFILE = $(OUTPUT)libapi.a
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC

ifeq ($(CC), clang)
ifeq ($(CC_NO_CLANG), 0)
CFLAGS += -O3
else
CFLAGS += -O6
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/subcmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LIBFILE = $(OUTPUT)libsubcmd.a
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC

ifeq ($(CC), clang)
ifeq ($(CC_NO_CLANG), 0)
CFLAGS += -O3
else
CFLAGS += -O6
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ ifndef DEBUG
endif

ifeq ($(DEBUG),0)
ifeq ($(CC), clang)
ifeq ($(CC_NO_CLANG), 0)
CFLAGS += -O3
else
CFLAGS += -O6
Expand Down Expand Up @@ -184,7 +184,7 @@ ifdef PYTHON_CONFIG
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
ifeq ($(CC), clang)
ifeq ($(CC_NO_CLANG), 1)
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
endif
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/intel-pt-decoder/Build
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/in

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

ifneq ($(CC), clang)
ifeq ($(CC_NO_CLANG), 1)
CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init
endif
4 changes: 3 additions & 1 deletion tools/scripts/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ EXTRA_WARNINGS += -Wundef
EXTRA_WARNINGS += -Wwrite-strings
EXTRA_WARNINGS += -Wformat

ifneq ($(CC), clang)
CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)

ifeq ($(CC_NO_CLANG), 1)
EXTRA_WARNINGS += -Wstrict-aliasing=3
endif

Expand Down

0 comments on commit 3866058

Please sign in to comment.