Skip to contentSkip to conversation

perf tools: Force fixdep to be built first

PATCH Superseded Jiri Olsa 4 participants 16 messages Dec 4, 2016 – Dec 6, 2016 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover perf tools: Force fixdep to be built first

hi,
changing Makefile.perf to force building fixdep before everything else, in order to avoid fixdep build races due to forgotten dependencies.

And some build fixes that piled up around the fixdep change.

Available also here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes

Arnaldo,
this is based on top of your acme/tmp.perf/fixdep branch.

thanks,
jirka
---
Jiri Olsa (7):
tools build: Make the .cmd file more readable
tools build: Move tabs to spaces where suitable perf tools: Move install-gtk target into rules area perf tools: Move python/perf.so target into rules area perf tools: Force fixdep compilation at the start of the build perf tools: Add non config targets
perf tools: Cleanup build directory before each test

 tools/build/Build.include    |  14 +++++------
 tools/build/Makefile.feature | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------
 tools/build/feature/Makefile | 102 +++++++++++++++++++++++++++++++++++++--------------------------------------
 tools/perf/Makefile.perf     |  87 ++++++++++++++++++++++++++++++++++++++++++----------------------
 tools/perf/tests/make        |   2 +-
 5 files changed, 186 insertions(+), 157 deletions(-)
author reviewer
#1 lore raw

PATCH 1/7 tools build: Make the .cmd file more readable

Putting extra line between dependencies and cmd_* definition to make it more readable.

Before:

  $ cat .builtin-top.o.cmd
  ...
  /home/jolsa/kernel/linux-perf/tools/include/linux/stringify.h \
  /home/jolsa/kernel/linux-perf/tools/include/linux/time64.h
  cmd_builtin-top.o := gcc -Wp,-MD,./.builtin-top.o.d -Wp,-MT,builtin-...
  ...

After:

  $ cat .builtin-top.o.cmd
  ...
  /home/jolsa/kernel/linux-perf/tools/include/linux/stringify.h \
  /home/jolsa/kernel/linux-perf/tools/include/linux/time64.h

cmd_builtin-top.o := gcc -Wp,-MD,./.builtin-top.o.d -Wp,-MT,builtin-...
...

---
 tools/build/Build.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Build.include +1 -1
index 62dcf0c7aac2..475152c52871 100644
@@ -65,7 +65,7 @@ dep-cmd = $(if $(wildcard $(fixdep)),
            printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
            printf '\# using basic dep data\n\n' >> $(dot-target).cmd;           \
            cat $(depfile) >> $(dot-target).cmd;                                 \
-           printf '%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
+           printf '\n%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
 
 ###
 # if_changed_dep  - execute command if any prerequisite is newer than
Signature · 1 line
2.7.4
#2 lore raw

[tip:perf/core] tools build: Make the .cmd file more readable

tools build: Make the .cmd file more readable
Commit-ID:  a5ba0a1a5af312c4b4bfe78dc054d832103ec27d
Gitweb:     http://git.kernel.org/tip/a5ba0a1a5af312c4b4bfe78dc054d832103ec27d
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:52 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:04:08 -0300

tools build: Make the .cmd file more readable

Putting extra line between dependencies and cmd_* definition to make it more readable.

Before:

  $ cat .builtin-top.o.cmd
  ...
  /home/jolsa/kernel/linux-perf/tools/include/linux/stringify.h \
  /home/jolsa/kernel/linux-perf/tools/include/linux/time64.h
  cmd_builtin-top.o := gcc -Wp,-MD,./.builtin-top.o.d -Wp,-MT,builtin-...
  ...

After:

  $ cat .builtin-top.o.cmd
  ...
  /home/jolsa/kernel/linux-perf/tools/include/linux/stringify.h \
  /home/jolsa/kernel/linux-perf/tools/include/linux/time64.h

cmd_builtin-top.o := gcc -Wp,-MD,./.builtin-top.o.d -Wp,-MT,builtin-...
...

---
 tools/build/Build.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Build.include +1 -1
index 62dcf0c..475152c 100644
@@ -65,7 +65,7 @@ dep-cmd = $(if $(wildcard $(fixdep)),
            printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
            printf '\# using basic dep data\n\n' >> $(dot-target).cmd;           \
            cat $(depfile) >> $(dot-target).cmd;                                 \
-           printf '%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
+           printf '\n%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
 
 ###
 # if_changed_dep  - execute command if any prerequisite is newer than
author reviewer
#3 lore raw

PATCH 2/7 tools build: Move tabs to spaces where suitable

In reply to Jiri Olsa

We've been hit several times with Makefile bug where line indented by tab was falsely considered as target command.

We prevent this to use always space indentation for everything except the target commands.

---
 tools/build/Build.include    |  12 ++--
 tools/build/Makefile.feature | 138 +++++++++++++++++++++----------------------
 tools/build/feature/Makefile | 102 ++++++++++++++++----------------
 3 files changed, 126 insertions(+), 126 deletions(-)
tools/build/Build.include +6 -6
index 475152c52871..418871d02ebf 100644
@@ -72,15 +72,15 @@ dep-cmd = $(if $(wildcard $(fixdep)),
 #                   target, or command line has changed and update
 #                   dependencies in the cmd file
 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),         \
-	@set -e;                                                   \
-	$(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
+                  @set -e;                                         \
+                  $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
 
 # if_changed      - execute command if any prerequisite is newer than
 #                   target, or command line has changed
-if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
-	@set -e;                                                   \
-	$(echo-cmd) $(cmd_$(1));                                   \
-	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+if_changed = $(if $(strip $(any-prereq) $(arg-check)),                   \
+              @set -e;                                                   \
+              $(echo-cmd) $(cmd_$(1));                                   \
+              printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 
 ###
 # C flags to be used in rule definitions, includes:
tools/build/Makefile.feature +69 -69

153 lines not on this page · raw message

tools/build/feature/Makefile +51 -51

105 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

[tip:perf/core] tools build: Move tabs to spaces where suitable

tools build: Move tabs to spaces where suitable
Commit-ID:  2fedf79b69cf05b7e8e82a42d749c621155dd812
Gitweb:     http://git.kernel.org/tip/2fedf79b69cf05b7e8e82a42d749c621155dd812
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:53 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:06:03 -0300

tools build: Move tabs to spaces where suitable

We've been hit several times by a Makefile bug where line indented by tab was falsely considered as target command.

We prevent this by always using space indentation for everything except for the target commands.

---
 tools/build/Build.include    |  12 ++--
 tools/build/Makefile.feature | 138 +++++++++++++++++++++----------------------
 tools/build/feature/Makefile | 102 ++++++++++++++++----------------
 3 files changed, 126 insertions(+), 126 deletions(-)
tools/build/Build.include +6 -6
index 475152c..418871d 100644
@@ -72,15 +72,15 @@ dep-cmd = $(if $(wildcard $(fixdep)),
 #                   target, or command line has changed and update
 #                   dependencies in the cmd file
 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),         \
-	@set -e;                                                   \
-	$(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
+                  @set -e;                                         \
+                  $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
 
 # if_changed      - execute command if any prerequisite is newer than
 #                   target, or command line has changed
-if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
-	@set -e;                                                   \
-	$(echo-cmd) $(cmd_$(1));                                   \
-	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+if_changed = $(if $(strip $(any-prereq) $(arg-check)),                   \
+              @set -e;                                                   \
+              $(echo-cmd) $(cmd_$(1));                                   \
+              printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 
 ###
 # C flags to be used in rule definitions, includes:
tools/build/Makefile.feature +69 -69

153 lines not on this page · raw message

tools/build/feature/Makefile +51 -51

105 lines not on this page · raw message

author reviewer
#5 lore raw

PATCH 3/7 perf tools: Move install-gtk target into rules area

In reply to Jiri Olsa

Following fixdep fix needs all targets at the same area, so they'll fit under signal condition block.

Moving install-gtk target into rules section.

---
 tools/perf/Makefile.perf | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/perf/Makefile.perf +7 -5
index 3cb1df43ad3e..2e95456108d7 100644
@@ -325,11 +325,6 @@ endif
 ifndef NO_GTK2
   ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
   GTK_IN := $(OUTPUT)gtk-in.o
-
-install-gtk: $(OUTPUT)libperf-gtk.so
-	$(call QUIET_INSTALL, 'GTK UI') \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
-		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
 endif
 
 ifdef ASCIIDOC8
@@ -691,7 +686,14 @@ check: $(OUTPUT)common-cmds.h
 
 ### Installation rules
 
+ifndef NO_GTK2
+install-gtk: $(OUTPUT)libperf-gtk.so
+	$(call QUIET_INSTALL, 'GTK UI') \
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
+		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
+else
 install-gtk:
+endif
 
 install-tools: all install-gtk
 	$(call QUIET_INSTALL, binaries) \
Signature · 1 line
2.7.4
#6 lore raw

[tip:perf/core] perf tools: Move install-gtk target into rules area

perf tools: Move install-gtk target into rules area
Commit-ID:  5c319a67b13da8323ec7bdb8d2ea729eb8a20735
Gitweb:     http://git.kernel.org/tip/5c319a67b13da8323ec7bdb8d2ea729eb8a20735
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:54 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:06:50 -0300

perf tools: Move install-gtk target into rules area

The upcoming fixdep fix needs all targets at the same area, so they'll fit under a signal condition block.

Move install-gtk target into the rules section.

---
 tools/perf/Makefile.perf | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/perf/Makefile.perf +7 -5
index dfb20dd..593d765 100644
@@ -331,11 +331,6 @@ endif
 ifndef NO_GTK2
   ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
   GTK_IN := $(OUTPUT)gtk-in.o
-
-install-gtk: $(OUTPUT)libperf-gtk.so
-	$(call QUIET_INSTALL, 'GTK UI') \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
-		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
 endif
 
 ifdef ASCIIDOC8
@@ -712,7 +707,14 @@ check: $(OUTPUT)common-cmds.h
 
 ### Installation rules
 
+ifndef NO_GTK2
+install-gtk: $(OUTPUT)libperf-gtk.so
+	$(call QUIET_INSTALL, 'GTK UI') \
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
+		$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
+else
 install-gtk:
+endif
 
 install-tools: all install-gtk
 	$(call QUIET_INSTALL, binaries) \
author reviewer
#7 lore raw

PATCH 4/7 perf tools: Move python/perf.so target into rules area

In reply to Jiri Olsa

Following fixdep fix needs all targets at the same area, so they'll fit under signal condition block.

Moving python/perf.so target into rules section and intentionally removing the perl script related comment.

---
 tools/perf/Makefile.perf | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
tools/perf/Makefile.perf +8 -11
index 2e95456108d7..112f4f7bb200 100644
@@ -262,17 +262,6 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT
 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
 PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
 
-$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
-	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
-        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
-	  $(PYTHON_WORD) util/setup.py \
-	  --quiet build_ext; \
-	mkdir -p $(OUTPUT)python && \
-	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
-#
-# No Perl scripts right now:
-#
-
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
 
 PROGRAMS += $(OUTPUT)perf
@@ -341,6 +330,14 @@ SHELL = $(SHELL_PATH)
 
 all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
 
+$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
+	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
+        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
+	  $(PYTHON_WORD) util/setup.py \
+	  --quiet build_ext; \
+	mkdir -p $(OUTPUT)python && \
+	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
+
 please_set_SHELL_PATH_to_a_more_modern_shell:
 	$(Q)$$(:)
 
Signature · 1 line
2.7.4
#8 lore raw

[tip:perf/core] perf tools: Move python/perf.so target into rules area

perf tools: Move python/perf.so target into rules area
Commit-ID:  0b4d4b076251542dc81d128f481c3d3b5fc24863
Gitweb:     http://git.kernel.org/tip/0b4d4b076251542dc81d128f481c3d3b5fc24863
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:55 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:11:50 -0300

perf tools: Move python/perf.so target into rules area

Following fixdep fix needs all targets at the same area, so they'll fit under signal condition block.

Moving python/perf.so target into rules section and intentionally removing the perl script related comment.

---
 tools/perf/Makefile.perf | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
tools/perf/Makefile.perf +8 -11
index 593d765..2784b58 100644
@@ -268,17 +268,6 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT
 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
 PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
 
-$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
-	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
-        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
-	  $(PYTHON_WORD) util/setup.py \
-	  --quiet build_ext; \
-	mkdir -p $(OUTPUT)python && \
-	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
-#
-# No Perl scripts right now:
-#
-
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
 
 PROGRAMS += $(OUTPUT)perf
@@ -362,6 +351,14 @@ SHELL = $(SHELL_PATH)
 
 all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
 
+$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
+	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
+        CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
+	  $(PYTHON_WORD) util/setup.py \
+	  --quiet build_ext; \
+	mkdir -p $(OUTPUT)python && \
+	cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
+
 please_set_SHELL_PATH_to_a_more_modern_shell:
 	$(Q)$$(:)
 
author reviewer
#9 lore raw

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

In reply to Jiri Olsa

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.

---
 tools/perf/Makefile.perf | 54 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 12 deletions(-)
tools/perf/Makefile.perf +42 -12
index 112f4f7bb200..25d9d6653746 100644
@@ -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
Signature · 1 line
2.7.4
#10 lore raw

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

Em Sun, Dec 04, 2016 at 09:42:56PM +0100, Jiri Olsa escreveu:

Quoted 11 lines

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'
Quoted 144 lines
---
 tools/perf/Makefile.perf | 54 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 12 deletions(-)
tools/perf/Makefile.perf +42 -12
index 112f4f7bb200..25d9d6653746 100644
@@ -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
Signature · 1 line
2.7.4
#11 lore raw

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

Quoted 15 lines · Arnaldo Carvalho de Melo

Em Sun, Dec 04, 2016 at 09:42:56PM +0100, Jiri Olsa escreveu:

Quoted 11 lines

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:

Quoted 14 lines
$ 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'

hum, tests/make does not cover $HOME installation :-\

anyway, I needed to do more changes and I pushed them all into my perf/fixes again and now I'm running all tests..

it also has the check-headers.sh fix we discussed

I'll post later today if the tests are ok

thanks,
jirka

author reviewer
#12 lore raw

PATCH 6/7 perf tools: Add non config targets

In reply to Jiri Olsa

Adding some missing non config targets that were
for some reason omitted.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index 25d9d6653746..d752b6685e57 100644
@@ -171,7 +171,7 @@ SUBCMD_DIR	= $(srctree)/tools/lib/subcmd/
 # non-config cases
 config := 1
 
-NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc
+NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc install-man install-html install-info install-pdf doc man html info pdf
 
 ifdef MAKECMDGOALS
 ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
Signature · 1 line
2.7.4
#13 lore raw

[tip:perf/core] perf tools: Add non config targets

perf tools: Add non config targets
Commit-ID:  d4dcadec43def7b2a4a4c1cae7d727c17d2f25c5
Gitweb:     http://git.kernel.org/tip/d4dcadec43def7b2a4a4c1cae7d727c17d2f25c5
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:57 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:18:49 -0300

perf tools: Add non config targets

Adding some missing non config targets that were for some reason omitted.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index 2784b58..10495c9 100644
@@ -177,7 +177,7 @@ SUBCMD_DIR	= $(srctree)/tools/lib/subcmd/
 # non-config cases
 config := 1
 
-NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc
+NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc install-man install-html install-info install-pdf doc man html info pdf
 
 ifdef MAKECMDGOALS
 ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
author reviewer
#14 lore raw

PATCH 7/7 perf tools: Cleanup build directory before each test

In reply to Jiri Olsa

Cleanup the fixdep tool before every test.

---
 tools/perf/tests/make | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/make +1 -1
index 08ed7f12cc37..ac6f3ecd4e72 100644
@@ -278,7 +278,7 @@ endif
 
 MAKEFLAGS := --no-print-directory
 
-clean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null)
+clean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null && $(MAKE) -s $(O_OPT) -C ../build clean >/dev/null)
 
 $(run):
 	$(call clean)
Signature · 1 line
2.7.4
#15 lore raw

[tip:perf/core] perf tools: Cleanup build directory before each test

perf tools: Cleanup build directory before each test
Commit-ID:  207da4739e3e6ced6dbfebed7416b35c0440e591
Gitweb:     http://git.kernel.org/tip/207da4739e3e6ced6dbfebed7416b35c0440e591
Author:     Jiri Olsa <[email protected]>
AuthorDate: Sun, 4 Dec 2016 21:42:58 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 5 Dec 2016 16:18:26 -0300

perf tools: Cleanup build directory before each test

Cleanup the fixdep tool before every test.

---
 tools/perf/tests/make | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/make +1 -1
index aa49b66..0784748 100644
@@ -280,7 +280,7 @@ endif
 
 MAKEFLAGS := --no-print-directory
 
-clean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null)
+clean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null && $(MAKE) -s $(O_OPT) -C ../build clean >/dev/null)
 
 $(run):
 	$(call clean)