Re: [PATCH 5/7] perf tools: Force fixdep compilation at the start of the build

From: Arnaldo Carvalho de Melo
Date: Mon Dec 05 2016 - 15:03:22 EST


Em Sun, Dec 04, 2016 at 09:42:56PM +0100, Jiri Olsa escreveu:
> The fixdep tool needs to be built before everything else,
> because it fixes every object dependency file.
>
> We handle this currently by making all objects to depend
> on fixdep, which is error prone and is easily forgotten
> when new object is added.
>
> Instead of this, this patch force fixdep tool to be built
> as the first target in the separate make session. This way
> we don't need to handle extra fixdep dependencies and we are
> certain there's no fixdep race with any parallel make job.

With your updated version I'm getting this:

$ make -k O=/tmp/build/perf -C tools/perf install-bin
<BIG SNIP>
LINK /tmp/build/perf/libperf-gtk.so
INSTALL GTK UI
install: cannot change permissions of â/lib64â: Operation not permitted
install: cannot create regular file '/lib64/libperf-gtk.so': Permission denied
Makefile.perf:738: recipe for target 'install-gtk' failed
make[2]: *** [install-gtk] Error 1
make[2]: *** Waiting for unfinished jobs....
Makefile.perf:383: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
Makefile:108: recipe for target 'install-bin' failed
make: *** [install-bin] Error 2
make: Leaving directory '/home/acme/git/linux/tools/perf'

> Link: http://lkml.kernel.org/n/tip-b6wi5cssl8apu74o2kbfheag@xxxxxxxxxxxxxx
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/Makefile.perf | 54 +++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 42 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 112f4f7bb200..25d9d6653746 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -179,6 +179,27 @@ ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
> endif
> endif
>
> +# The fixdep build - we force fixdep tool to be built as
> +# the first target in the separate make session not to be
> +# disturbed by any parallel make jobs. Once fixdep is done
> +# we issue the requested build with FIXDEP=1 variable.
> +#
> +# The fixdep build is disabled for $(NON_CONFIG_TARGETS)
> +# targets, because it's not necessary.
> +
> +ifdef FIXDEP
> + force_fixdep := 0
> +else
> + force_fixdep := $(config)
> +endif
> +
> +# Disable config, we are forcing fixdep rule first
> +# and it does not need config data.
> +
> +ifeq ($(force_fixdep),1)
> + config := 0
> +endif
> +
> # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
> # Without this setting the output feature dump file misses some features, for
> # example, liberty. Select all checkers so we won't get an incomplete feature
> @@ -324,10 +345,22 @@ LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group
>
> export INSTALL SHELL_PATH
>
> +export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK
> +export HOSTCC HOSTLD HOSTAR
> +include $(srctree)/tools/build/Makefile.include
> +
> ### Build rules
>
> SHELL = $(SHELL_PATH)
>
> +ifeq ($(force_fixdep),1)
> +goals := $(filter-out all sub-make, $(MAKECMDGOALS))
> +
> +$(goals) all: sub-make
> +
> +sub-make: fixdep
> + $(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals)
> +else
> all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
>
> $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
> @@ -348,10 +381,6 @@ strip: $(PROGRAMS) $(OUTPUT)perf
>
> PERF_IN := $(OUTPUT)perf-in.o
>
> -export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK
> -export HOSTCC HOSTLD HOSTAR
> -include $(srctree)/tools/build/Makefile.include
> -
> JEVENTS := $(OUTPUT)pmu-events/jevents
> JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o
>
> @@ -470,7 +499,7 @@ $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_L
> $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
> $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
>
> -$(GTK_IN): fixdep FORCE
> +$(GTK_IN): FORCE
> $(Q)$(MAKE) $(build)=gtk
>
> $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
> @@ -515,7 +544,7 @@ endif
> __build-dir = $(subst $(OUTPUT),,$(dir $@))
> build-dir = $(if $(__build-dir),$(__build-dir),.)
>
> -prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep archheaders
> +prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders
>
> $(OUTPUT)%.o: %.c prepare FORCE
> $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
> @@ -565,7 +594,7 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
>
> LIBPERF_IN := $(OUTPUT)libperf-in.o
>
> -$(LIBPERF_IN): prepare fixdep FORCE
> +$(LIBPERF_IN): prepare FORCE
> $(Q)$(MAKE) $(build)=libperf
>
> $(LIB_FILE): $(LIBPERF_IN)
> @@ -573,10 +602,10 @@ $(LIB_FILE): $(LIBPERF_IN)
>
> LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
>
> -$(LIBTRACEEVENT): fixdep FORCE
> +$(LIBTRACEEVENT): FORCE
> $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
>
> -libtraceevent_plugins: fixdep FORCE
> +libtraceevent_plugins: FORCE
> $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
>
> $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
> @@ -589,21 +618,21 @@ $(LIBTRACEEVENT)-clean:
> install-traceevent-plugins: libtraceevent_plugins
> $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
>
> -$(LIBAPI): fixdep FORCE
> +$(LIBAPI): FORCE
> $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
>
> $(LIBAPI)-clean:
> $(call QUIET_CLEAN, libapi)
> $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
>
> -$(LIBBPF): fixdep FORCE
> +$(LIBBPF): FORCE
> $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
>
> $(LIBBPF)-clean:
> $(call QUIET_CLEAN, libbpf)
> $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
>
> -$(LIBSUBCMD): fixdep FORCE
> +$(LIBSUBCMD): FORCE
> $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
>
> $(LIBSUBCMD)-clean:
> @@ -811,3 +840,4 @@ FORCE:
> .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
> .PHONY: libtraceevent_plugins archheaders
>
> +endif # force_fixdep
> --
> 2.7.4