Skip to content

Commit 49b3cd3

Browse files
committed
tools: Set the maximum optimization level according to the compiler being used
To avoid this when using clang: warning: optimization level '-O6' is not supported; using '-O3' instead Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-kaghp8ddvzdsg03putemcq96@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 093b75e commit 49b3cd3

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎tools/lib/api/Makefile‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ MAKEFLAGS += --no-print-directory
1717
LIBFILE = $(OUTPUT)libapi.a
1818

1919
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
20-
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
20+
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
21+
22+
ifeq ($(CC), clang)
23+
CFLAGS += -O3
24+
else
25+
CFLAGS += -O6
26+
endif
2127

2228
# Treat warnings as errors unless directed not to
2329
ifneq ($(WERROR),0)

‎tools/lib/subcmd/Makefile‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ MAKEFLAGS += --no-print-directory
1919
LIBFILE = $(OUTPUT)libsubcmd.a
2020

2121
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
22-
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
22+
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
23+
24+
ifeq ($(CC), clang)
25+
CFLAGS += -O3
26+
else
27+
CFLAGS += -O6
28+
endif
2329

2430
# Treat warnings as errors unless directed not to
2531
ifneq ($(WERROR),0)

‎tools/perf/Makefile.config‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ ifndef DEBUG
144144
endif
145145

146146
ifeq ($(DEBUG),0)
147+
ifeq ($(CC), clang)
148+
CFLAGS += -O3
149+
else
147150
CFLAGS += -O6
148151
endif
152+
endif
149153

150154
ifdef PARSER_DEBUG
151155
PARSER_DEBUG_BISON := -t

0 commit comments

Comments
 (0)