perf tools: Use per-file CFLAGS in Makefile
Namhyung Kim
maintainerPATCH 1/1 perf tools: Use per-file CFLAGS in Makefile
From: Namhyung Kim <[email protected]>
Some files need additional compiler flags to be built successfully. Cleanup Makefile by using optional per-file CFLAGS which look like CFLAGS_dir_filename.o
--- tools/perf/Makefile | 128 ++++++++++++++++++--------------------------- tools/perf/config/Makefile | 2 +- 2 files changed, 52 insertions(+), 78 deletions(-)
tools/perf/Makefile +51 -77
@@ -522,7 +522,8 @@ ifdef ASCIIDOC8 export ASCIIDOC8 endif -LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group +LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive +LIBS += -Wl,--start-group $(EXTLIBS) -Wl,--end-group export INSTALL SHELL_PATH
@@ -549,17 +550,11 @@ $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \ $(BUILTIN_OBJS) $(LIBS) -o $@ -$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ - '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< +$(OUTPUT)perf-%: %.o $(PERFLIBS) + $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) -$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ - '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< +$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) +$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
@@ -577,15 +572,6 @@ $(OUTPUT)perf.o perf.spec \ .SUFFIXES: .SUFFIXES: .o .c .S .s -# These two need to be here so that when O= is not used they take precedence -# over the general rule for .o - -$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -w $< - -$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $< - $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< $(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
@@ -597,64 +583,52 @@ $(OUTPUT)%.o: %.S $(OUTPUT)%.s: %.S $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $< -$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \ - '-DPREFIX="$(prefix_SQ)"' \ - $< - -$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \ - $< - -$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - -DPYTHONPATH='"$(OUTPUT)python"' \ - -DPYTHON='"$(PYTHON_WORD)"' \ - $< - -$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - -$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< +# Support to pass additional cflags per file +# Directory was separated by '_' -$(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - -$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $< - -$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $< - -$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $< - -$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< - -$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $< - -$(OUTPUT)perf-%: %.o $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) - -$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) -$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) +ifneq ($(OUTPUT),) +_target = $(filter-out $(OUTPUT),$@) +else +_target = $@ +endif +target = $(subst /,_,$(_target)) + +CFLAGS += $(CFLAGS_$(target)) + +slang_cflags = -DENABLE_SLFUTURE_CONST +flex_cflags = -w +bison_cflags = -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w +perl_cflags = $(PERL_EMBED_CCOPTS) -w +python_cflags = $(PYTHON_EMBED_CCOPTS) -w + +CFLAGS_builtin-help.o = -DPERF_HTML_PATH='"$(htmldir_SQ)"' +CFLAGS_builtin-help.o += -DPERF_MAN_PATH='"$(mandir_SQ)"' +CFLAGS_builtin-help.o += -DPERF_INFO_PATH='"$(infodir_SQ)"' +CFLAGS_builtin-timechart.o = -DPERF_HTML_PATH='"$(htmldir_SQ)"' +CFLAGS_builtin-timechart.o += -DPERF_MAN_PATH='"$(mandir_SQ)"' +CFLAGS_builtin-timechart.o += -DPERF_INFO_PATH='"$(infodir_SQ)"' +CFLAGS_util_config.o = -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' +CFLAGS_util_exec_cmd.o = -DPERF_EXEC_PATH='"$(perfexecdir_SQ)"' +CFLAGS_util_exec_cmd.o += -DPREFIX='"$(prefix_SQ)"' +CFLAGS_util_parse-events.o = -Wno-redundant-decls +CFLAGS_util_parse-events-flex.o = $(flex_cflags) +CFLAGS_util_parse-events-bison.o = $(bison_cflags) +CFLAGS_util_pmu-flex.o = $(flex_cflags) +CFLAGS_util_pmu-bison.o = $(bison_cflags) +CFLAGS_util_rbtree.o = -Wno-unused-parameter +CFLAGS_util_rbtree.o += -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' +CFLAGS_tests_attr.o = -DBINDIR='"$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' +CFLAGS_tests_python-use.o = -DPYTHONPATH='"$(OUTPUT)python"' +CFLAGS_tests_python-use.o += -DPYTHON='"$(PYTHON_WORD)"' +CFLAGS_ui_browser.o = $(slang_cflags) +CFLAGS_ui_browsers_annotate.o = $(slang_cflags) +CFLAGS_ui_browsers_hists.o = $(slang_cflags) +CFLAGS_ui_browsers_map.o = $(slang_cflags) +CFLAGS_ui_browsers_scripts.o = $(slang_cflags) +CFLAGS_util_scripting-engines_trace-event-perl.o = $(perl_cflags) +CFLAGS_util_scripting-engines_trace-event-python.o = $(python_cflags) +CFLAGS_scripts_perl_Perf-Trace-Util_Context.o = $(perl_cflags) +CFLAGS_scripts_python_Perf-Trace-Util_Context.o = $(python_cflags) # we compile into subdirectories. if the target directory is not the source directory, they might not exists. So # we depend the various files onto their directories.
tools/perf/config/Makefile +1 -1
@@ -6,7 +6,7 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) NO_PERF_REGS := 1 -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) +CFLAGS = $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) # Additional ARCH settings for x86 ifeq ($(ARCH),i386)
Signature · 1 line
1.7.11.7
tools/perf/Makefile $(OUTPUT)%.o: %.S · line 651
Quoted 11 lines · Namhyung Kim
-$(OUTPUT)util/scripting-engines/trace-event-perl.o:
util/scripting-engines/trace-event-perl.c$(OUTPUT)PERF-CFLAGStools/perf/Makefile +0
-10- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $< - -$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $< - -$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< - -$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
What happened with the trailing -W options in each target above? Looks like they've been dropped because I can't find them in the new definitions...
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Namhyung Kim
maintainerHi Borislav,
Quoted 16 lines · Borislav Petkov
tools/perf/Makefile $(OUTPUT)%.o: %.S · line 651
Quoted 11 lines · Namhyung Kim
-$(OUTPUT)util/scripting-engines/trace-event-perl.o:
util/scripting-engines/trace-event-perl.c$(OUTPUT)PERF-CFLAGStools/perf/Makefile +0
-10- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $< - -$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $< - -$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< - -$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<What happened with the trailing -W options in each target above? Looks like they've been dropped because I can't find them in the new definitions...
I replaced them to a single -w option since all we want to do is suppress any warning, right?
Thanks,
Namhyung
Quoted 2 lines · Namhyung Kim
I replaced them to a single -w option since all we want to do is suppress any warning, right?
Do we? And besides, -w is a big hammer as it shuts up all warnings. acme?
I think special handling those files grew out of necessity to shut up some warnings but acme would know better.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Namhyung Kim
maintainerHi Boris,
Quoted 9 lines · Borislav Petkov
Quoted 2 lines · Namhyung Kim
I replaced them to a single -w option since all we want to do is suppress any warning, right?
Do we? And besides, -w is a big hammer as it shuts up all warnings. acme?
I think special handling those files grew out of necessity to shut up some warnings but acme would know better.
I don't know. I just thought there's not much thing we can do for those files other than shutting up all warnings.
But if you think that's not the right thing, I'll keep the existing options. What do you think, Arnaldo?
Thanks,
Namhyung
Em Tue, Sep 24, 2013 at 05:09:21PM +0900, Namhyung Kim escreveu:
Quoted 10 lines · Borislav Petkov
Quoted 9 lines · Namhyung Kim
Quoted 2 lines
I replaced them to a single -w option since all we want to do is suppress any warning, right?
Do we? And besides, -w is a big hammer as it shuts up all warnings. acme?
I think special handling those files grew out of necessity to shut up some warnings but acme would know better.
Yes, there were reasons for disabling some warnings on some files, would have to look at the git history to see...
commit 09c0211c0bb0e40231e6ee9a35041d467ed72f16
Author: Greg Kroah-Hartman <[email protected]> Date: Fri May 4 11:32:54 2012 -0700
perf: Turn off compiler warnings for flex and bison generated files
We don't know what types of warnings different versions of flex and bison combined with different versions of gcc is going to generate, so just punt and don't warn about anything.
This fixes the build of perf for me on an openSUSE 12.1 system.
commit 575bf1d04e908469d26da424b52fc1b12a1db9d8
Author: Kirill A. Shutemov <[email protected]> Date: Mon Jun 24 11:43:14 2013 +0300
perf tools: Fix build with perl 5.18
perl.h from new Perl release doesn't like -Wundef and -Wswitch-default:
etc.
Quoted 5 lines
I don't know. I just thought there's not much thing we can do for those files other than shutting up all warnings.
But if you think that's not the right thing, I'll keep the existing options. What do you think, Arnaldo?
I think keeping the existing options is the right thing to do, if some of that can be simplified or made like you did it in your patch, then that is the matter for a separate patch, with proper explanation.
- Arnaldo
Namhyung Kim
maintainerHi Arnaldo,
Quoted 10 lines · Arnaldo Carvalho de Melo
Em Tue, Sep 24, 2013 at 05:09:21PM +0900, Namhyung Kim escreveu:
Quoted 5 lines
I don't know. I just thought there's not much thing we can do for those files other than shutting up all warnings.
But if you think that's not the right thing, I'll keep the existing options. What do you think, Arnaldo?
I think keeping the existing options is the right thing to do, if some of that can be simplified or made like you did it in your patch, then that is the matter for a separate patch, with proper explanation.
Okay, I'll just keep them and resend v2.
Thanks,
Namhyung
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Some files need additional compiler flags to be built successfully. Cleanup
Makefileby using optional per-file CFLAGS which look like CFLAGS_dir_filename.o
I like it, but I'm getting following error:
$ make
...
AR libperf.a
ar: util/rbtree.o: No such file or directory
make: *** [libperf.a] Error 1
$probably because rbtree object is based in kernel lib
Also this patch collides with your previous:
perf tools: Separate out GTK codes to libperf-gtk.so
which I needed to revert first to get this one applied.
jirka
Namhyung Kim
maintainerHi Jiri,
Quoted 16 lines · Jiri Olsa
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Some files need additional compiler flags to be built successfully. Cleanup
Makefileby using optional per-file CFLAGS which look like CFLAGS_dir_filename.oI like it, but I'm getting following error:
$ make ... AR libperf.a ar: util/rbtree.o: No such file or directory make: *** [libperf.a] Error 1 $
Quoted 7 lines
probably because rbtree object is based in kernel lib
Also this patch collides with your previous:
perf tools: Separate out GTK codes to libperf-gtk.sowhich I needed to revert first to get this one applied.
Thanks for the feedback. I'll take a look and fix them.
Thanks,
Namhyung