Skip to content

Commit 5554211

Browse files
olsajiriacmel
authored andcommitted
perf tools: Propagate CFLAGS to libperf
Andi reported that 'make DEBUG=1' does not propagate to the libbperf code. It's true also for the other flags. Changing the code to propagate the global build flags to libperf compilation. Reported-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20191011122155.15738-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 84227cb commit 5554211

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

tools/perf/Makefile.config

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ endif
188188

189189
# Treat warnings as errors unless directed not to
190190
ifneq ($(WERROR),0)
191-
CFLAGS += -Werror
191+
CORE_CFLAGS += -Werror
192192
CXXFLAGS += -Werror
193193
endif
194194

@@ -198,9 +198,9 @@ endif
198198

199199
ifeq ($(DEBUG),0)
200200
ifeq ($(CC_NO_CLANG), 0)
201-
CFLAGS += -O3
201+
CORE_CFLAGS += -O3
202202
else
203-
CFLAGS += -O6
203+
CORE_CFLAGS += -O6
204204
endif
205205
endif
206206

@@ -245,12 +245,12 @@ FEATURE_CHECK_LDFLAGS-libaio = -lrt
245245

246246
FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
247247

248-
CFLAGS += -fno-omit-frame-pointer
249-
CFLAGS += -ggdb3
250-
CFLAGS += -funwind-tables
251-
CFLAGS += -Wall
252-
CFLAGS += -Wextra
253-
CFLAGS += -std=gnu99
248+
CORE_CFLAGS += -fno-omit-frame-pointer
249+
CORE_CFLAGS += -ggdb3
250+
CORE_CFLAGS += -funwind-tables
251+
CORE_CFLAGS += -Wall
252+
CORE_CFLAGS += -Wextra
253+
CORE_CFLAGS += -std=gnu99
254254

255255
CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti
256256
CXXFLAGS += -Wall
@@ -272,12 +272,12 @@ include $(FEATURES_DUMP)
272272
endif
273273

274274
ifeq ($(feature-stackprotector-all), 1)
275-
CFLAGS += -fstack-protector-all
275+
CORE_CFLAGS += -fstack-protector-all
276276
endif
277277

278278
ifeq ($(DEBUG),0)
279279
ifeq ($(feature-fortify-source), 1)
280-
CFLAGS += -D_FORTIFY_SOURCE=2
280+
CORE_CFLAGS += -D_FORTIFY_SOURCE=2
281281
endif
282282
endif
283283

@@ -301,10 +301,12 @@ INC_FLAGS += -I$(src-perf)/util
301301
INC_FLAGS += -I$(src-perf)
302302
INC_FLAGS += -I$(srctree)/tools/lib/
303303

304-
CFLAGS += $(INC_FLAGS)
304+
CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
305+
306+
CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
305307
CXXFLAGS += $(INC_FLAGS)
306308

307-
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
309+
LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)
308310

309311
ifeq ($(feature-sync-compare-and-swap), 1)
310312
CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT

tools/perf/Makefile.perf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ $(LIBBPF)-clean:
769769
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
770770

771771
$(LIBPERF): FORCE
772-
$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) $(OUTPUT)libperf.a
772+
$(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a
773773

774774
$(LIBPERF)-clean:
775775
$(call QUIET_CLEAN, libperf)

tools/perf/lib/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
#include <stdio.h>
66
#include <stdarg.h>
77
#include <unistd.h>
8+
#include <linux/compiler.h>
89
#include <perf/core.h>
910
#include <internal/lib.h>
1011
#include "internal.h"
1112

12-
static int __base_pr(enum libperf_print_level level, const char *format,
13+
static int __base_pr(enum libperf_print_level level __maybe_unused, const char *format,
1314
va_list args)
1415
{
1516
return vfprintf(stderr, format, args);

0 commit comments

Comments
 (0)