Skip to contentSkip to conversation

perf tools: Fix build on powerpc broken by pt/bts

PATCH Superseded Adrian Hunter 4 participants 14 messages Aug 25, 2015 – Sep 1, 2015 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

PATCH 1/2 perf tools: Fix build on powerpc broken by pt/bts

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +1 -1
index e912856cc4e5..8ae31e5131ee 100644
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
 libperf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8fcd559..d23138c06665 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;
Signature · 1 line
1.9.1
author reviewer
#1 lore raw

PATCH 2/2 perf tools: Make NO_AUXTRACE default for non-x86 architectures

Currently the AUXTRACE infrastructure is only used by Intel PT and Intel BTS but is compiled into all architectures to support the ability to process a perf.data file (including one containing Intel PT or Intel BTS data) from any architecture on any other architecture.

Generally people don't want that ability with respect to AUXTRACE by default.

Make the build option NO_AUXTRACE the default for non-x86 architectures. To build with AUXTRACE on those architectures use NO_AUXTRACE=0.

The build-test is updated accordingly.

---
 tools/perf/config/Makefile | 8 ++++++++
 tools/perf/tests/make      | 2 ++
 2 files changed, 10 insertions(+)
tools/perf/config/Makefile +8 -0
index 827557fc7511..ddc3b64fdad2 100644
@@ -621,6 +621,14 @@ ifdef LIBBABELTRACE
 endif
 
 ifndef NO_AUXTRACE
+  ifneq ($(ARCH),x86)
+    NO_AUXTRACE := 1
+  else
+    NO_AUXTRACE := 0
+  endif
+endif
+
+ifeq ($(NO_AUXTRACE), 0)
   $(call detected,CONFIG_AUXTRACE)
   CFLAGS += -DHAVE_AUXTRACE_SUPPORT
 endif
tools/perf/tests/make +2 -0
index ba31c4bd441d..977ded210de2 100644
@@ -44,6 +44,7 @@ make_no_libnuma     := NO_LIBNUMA=1
 make_no_libaudit    := NO_LIBAUDIT=1
 make_no_libbionic   := NO_LIBBIONIC=1
 make_no_auxtrace    := NO_AUXTRACE=1
+make_auxtrace       := NO_AUXTRACE=0
 make_tags           := tags
 make_cscope         := cscope
 make_help           := help
@@ -94,6 +95,7 @@ run += make_no_libnuma
 run += make_no_libaudit
 run += make_no_libbionic
 run += make_no_auxtrace
+run += make_auxtrace
 run += make_help
 run += make_doc
 run += make_perf_o
Signature · 1 line
1.9.1
#2 lore raw
In reply to Adrian Hunter

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

As we have in drivers/Makefile, in the kernel sources:

drivers/Makefile:obj-$(CONFIG_PCI) += usb/
drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/
drivers/Makefile:obj-$(CONFIG_USB_PHY) += usb/
drivers/Makefile:obj-$(CONFIG_USB) += usb/

Quoted 1 line

From Documentation/kbuild/makefiles.txt:

--- 3.2 Built-in object goals - obj-y

The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration.

Kbuild compiles all the $(obj-y) files. It then calls "$(LD) -r" to merge these files into one built-in.o file. built-in.o is later linked into vmlinux by the parent Makefile.

The order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into built-in.o and succeeding instances will be ignored.

------------------------

Jiri?

- Arnaldo

Quoted 19 lines

libperf-y += cloexec.o
libperf-y += thread-stack.o
libperf-$(CONFIG_AUXTRACE) += auxtrace.o

tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8fcd559..d23138c06665 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;
Signature · 1 line
1.9.1
author reviewer
#3 lore raw
Quoted 41 lines · Arnaldo Carvalho de Melo

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

Quoted 2 lines

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

I tried that first but it doesn't work:

util/tsc.o: In function `perf_time_to_tsc':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: multiple definition of perf_time_to_tsc' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: first defined here util/tsc.o: In function tsc_to_perf_time':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: multiple definition of `tsc_to_perf_time' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

I will have a look at why, unless Jiri knows?

Quoted 51 lines

As we have in drivers/Makefile, in the kernel sources:

drivers/Makefile:obj-$(CONFIG_PCI) += usb/
drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/
drivers/Makefile:obj-$(CONFIG_USB_PHY) += usb/
drivers/Makefile:obj-$(CONFIG_USB) += usb/

Quoted 1 line

From Documentation/kbuild/makefiles.txt:

--- 3.2 Built-in object goals - obj-y

The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration.

Kbuild compiles all the $(obj-y) files. It then calls "$(LD) -r" to merge these files into one built-in.o file. built-in.o is later linked into vmlinux by the parent Makefile.

The order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into built-in.o and succeeding instances will be ignored.

------------------------

Jiri?

- Arnaldo

Quoted 19 lines

libperf-y += cloexec.o
libperf-y += thread-stack.o
libperf-$(CONFIG_AUXTRACE) += auxtrace.o

tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8fcd559..d23138c06665 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;
Signature · 1 line
1.9.1
#4 lore raw
Quoted 58 lines · Adrian Hunter
Quoted 41 lines · Arnaldo Carvalho de Melo

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

Quoted 2 lines

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

I tried that first but it doesn't work:

util/tsc.o: In function `perf_time_to_tsc':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: multiple definition of perf_time_to_tsc' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: first defined here util/tsc.o: In function tsc_to_perf_time':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: multiple definition of `tsc_to_perf_time' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

Quoted 2 lines

I will have a look at why, unless Jiri knows?

I'm now testing attached patch, does it fix it for you?

thanks,
jirka

---

tools/build/Makefile.build +1 -1
index 8120af9c0341..0c5f485521d6 100644
@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN      $@
 # If there's nothing to link, create empty $@ object.
 quiet_cmd_ld_multi = LD       $@
       cmd_ld_multi = $(if $(strip $(obj-y)),\
-		       $(LD) -r -o $@ $(obj-y),rm -f $@; $(AR) rcs $@)
+		       $(LD) -r -o $@  $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
 
 # Build rules
 $(OUTPUT)%.o: %.c FORCE
tools/build/tests/ex/Build +1 -0
index 70d876237c57..429c7d452101 100644
@@ -1,6 +1,7 @@
 ex-y += ex.o
 ex-y += a.o
 ex-y += b.o
+ex-y += b.o
 ex-y += empty/
 ex-y += empty2/
 
author reviewer
#5 lore raw
Quoted 59 lines · Jiri Olsa
Quoted 58 lines · Adrian Hunter
Quoted 41 lines · Arnaldo Carvalho de Melo

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

Quoted 2 lines

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

I tried that first but it doesn't work:

util/tsc.o: In function `perf_time_to_tsc':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: multiple definition of perf_time_to_tsc' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: first defined here util/tsc.o: In function tsc_to_perf_time':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: multiple definition of `tsc_to_perf_time' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

Quoted 4 lines
Quoted 2 lines

I will have a look at why, unless Jiri knows?

I'm now testing attached patch, does it fix it for you?

Yup! Thanks Jiri! :-)

Quoted 33 lines

thanks,
jirka

---

tools/build/Makefile.build +1 -1
index 8120af9c0341..0c5f485521d6 100644
@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN      $@
 # If there's nothing to link, create empty $@ object.
 quiet_cmd_ld_multi = LD       $@
       cmd_ld_multi = $(if $(strip $(obj-y)),\
-		       $(LD) -r -o $@ $(obj-y),rm -f $@; $(AR) rcs $@)
+		       $(LD) -r -o $@  $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
 
 # Build rules
 $(OUTPUT)%.o: %.c FORCE
tools/build/tests/ex/Build +1 -0
index 70d876237c57..429c7d452101 100644
@@ -1,6 +1,7 @@
 ex-y += ex.o
 ex-y += a.o
 ex-y += b.o
+ex-y += b.o
 ex-y += empty/
 ex-y += empty2/
 
#6 lore raw
Quoted 60 lines · Adrian Hunter
Quoted 59 lines · Jiri Olsa
Quoted 58 lines · Adrian Hunter
Quoted 41 lines · Arnaldo Carvalho de Melo

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

Quoted 2 lines

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

I tried that first but it doesn't work:

util/tsc.o: In function `perf_time_to_tsc':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: multiple definition of perf_time_to_tsc' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: first defined here util/tsc.o: In function tsc_to_perf_time':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: multiple definition of `tsc_to_perf_time' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I will have a look at why, unless Jiri knows?

I'm now testing attached patch, does it fix it for you?

Yup! Thanks Jiri! :-)

cool, I'll send it out soon..

Arnaldo,
the tarpkg test is failing on me because of removed export.h not sure I missed attached update in your patch queue

jirka

---

tools/perf/MANIFEST +0 -1
index d01a0aad5a01..4d16e8af18b7 100644
@@ -40,7 +40,6 @@ tools/include/asm-generic/bitops.h
 tools/include/linux/atomic.h
 tools/include/linux/bitops.h
 tools/include/linux/compiler.h
-tools/include/linux/export.h
 tools/include/linux/hash.h
 tools/include/linux/kernel.h
 tools/include/linux/list.h
#7 lore raw

PATCH 1/1 tools build: Allow duplicate objects in the object list

On Wed, Aug 26, 2015 at 10:07:50AM +0200, Jiri Olsa wrote:

SNIP

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

I will have a look at why, unless Jiri knows?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I'm now testing attached patch, does it fix it for you?

Yup! Thanks Jiri! :-)

cool, I'll send it out soon..

---
It's sometimes useful to specify the object affiliation to multiple config options like:
libperf-$(CONFIG_X86) += tsc.o libperf-$(CONFIG_AUXTRACE) += tsc.o

while the object itself is linked only once. Adding the support for this and ignoring duplicate objects in the object list.

---
 tools/build/Documentation/Build.txt | 1 +
 tools/build/Makefile.build          | 2 +-
 tools/build/tests/ex/Build          | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
tools/build/Documentation/Build.txt +1 -0
index 00ad2d608727..aa5e092c4352 100644
@@ -66,6 +66,7 @@ To follow the above example, the user provides following 'Build' files:
   ex/Build:
     ex-y += a.o
     ex-y += b.o
+    ex-y += b.o # duplicates in the lists are allowed
 
     libex-y += c.o
     libex-y += d.o
tools/build/Makefile.build +1 -1
index 8120af9c0341..0c5f485521d6 100644
@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN      $@
 # If there's nothing to link, create empty $@ object.
 quiet_cmd_ld_multi = LD       $@
       cmd_ld_multi = $(if $(strip $(obj-y)),\
-		       $(LD) -r -o $@ $(obj-y),rm -f $@; $(AR) rcs $@)
+		       $(LD) -r -o $@  $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
 
 # Build rules
 $(OUTPUT)%.o: %.c FORCE
tools/build/tests/ex/Build +1 -0
index 70d876237c57..429c7d452101 100644
@@ -1,6 +1,7 @@
 ex-y += ex.o
 ex-y += a.o
 ex-y += b.o
+ex-y += b.o
 ex-y += empty/
 ex-y += empty2/
 
Signature · 1 line
2.4.3
#8 lore raw

[tip:perf/core] tools build: Allow duplicate objects in the object list

tools build: Allow duplicate objects in the object list
Commit-ID:  0bdede8a3e4ff7710622a2e6713d04b3243c24a8
Gitweb:     http://git.kernel.org/tip/0bdede8a3e4ff7710622a2e6713d04b3243c24a8
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 26 Aug 2015 15:01:03 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 26 Aug 2015 10:34:58 -0300

tools build: Allow duplicate objects in the object list

It's sometimes useful to specify the object affiliation to multiple config options like:

  libperf-$(CONFIG_X86) += tsc.o
  libperf-$(CONFIG_AUXTRACE) += tsc.o

while the object itself is linked only once. Adding the support for this and ignoring duplicate objects in the object list.

---
 tools/build/Documentation/Build.txt | 1 +
 tools/build/Makefile.build          | 2 +-
 tools/build/tests/ex/Build          | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
tools/build/Documentation/Build.txt +1 -0
index 00ad2d6..aa5e092 100644
@@ -66,6 +66,7 @@ To follow the above example, the user provides following 'Build' files:
   ex/Build:
     ex-y += a.o
     ex-y += b.o
+    ex-y += b.o # duplicates in the lists are allowed
 
     libex-y += c.o
     libex-y += d.o
tools/build/Makefile.build +1 -1
index 8120af9..0c5f485 100644
@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN      $@
 # If there's nothing to link, create empty $@ object.
 quiet_cmd_ld_multi = LD       $@
       cmd_ld_multi = $(if $(strip $(obj-y)),\
-		       $(LD) -r -o $@ $(obj-y),rm -f $@; $(AR) rcs $@)
+		       $(LD) -r -o $@  $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
 
 # Build rules
 $(OUTPUT)%.o: %.c FORCE
tools/build/tests/ex/Build +1 -0
index 70d8762..429c7d4 100644
@@ -1,6 +1,7 @@
 ex-y += ex.o
 ex-y += a.o
 ex-y += b.o
+ex-y += b.o
 ex-y += empty/
 ex-y += empty2/
 
#9 lore raw
In reply to Jiri Olsa

Em Wed, Aug 26, 2015 at 10:07:50AM +0200, Jiri Olsa escreveu:

Quoted 66 lines · Adrian Hunter
Quoted 65 lines · Jiri Olsa
Quoted 63 lines · Adrian Hunter
Quoted 58 lines · Arnaldo Carvalho de Melo
Quoted 41 lines

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

Quoted 2 lines

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

I tried that first but it doesn't work:

util/tsc.o: In function `perf_time_to_tsc':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: multiple definition of perf_time_to_tsc' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:7: first defined here util/tsc.o: In function tsc_to_perf_time':
/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: multiple definition of `tsc_to_perf_time' util/tsc.o:/mnt/ssd/ahunter/git/linux-perf/tools/perf/util/tsc.c:18: first defined here make[3]: *** [util/libperf-in.o] Error 1
make[2]: *** [util] Error 2
make[1]: *** [libperf-in.o] Error 2
make: *** [all] Error 2

Quoted 2 lines

I will have a look at why, unless Jiri knows?

I'm now testing attached patch, does it fix it for you?

Quoted 8 lines
Quoted 2 lines

Yup! Thanks Jiri! :-)

cool, I'll send it out soon..

Arnaldo,
the tarpkg test is failing on me because of removed export.h not sure I missed attached update in your patch queue

Thanks, applying, strange this remained there :-\

Quoted 16 lines

jirka

---

tools/perf/MANIFEST +0 -1
index d01a0aad5a01..4d16e8af18b7 100644
@@ -40,7 +40,6 @@ tools/include/asm-generic/bitops.h
 tools/include/linux/atomic.h
 tools/include/linux/bitops.h
 tools/include/linux/compiler.h
-tools/include/linux/export.h
 tools/include/linux/hash.h
 tools/include/linux/kernel.h
 tools/include/linux/list.h
#10 lore raw

[tip:perf/core] perf tools: Remove export.h from MANIFEST

In reply to Jiri Olsa
perf tools: Remove export.h from MANIFEST
Commit-ID:  18b9a05868391e8f617febb4528bc1765dc921cf
Gitweb:     http://git.kernel.org/tip/18b9a05868391e8f617febb4528bc1765dc921cf
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 26 Aug 2015 10:07:50 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 26 Aug 2015 10:34:57 -0300

perf tools: Remove export.h from MANIFEST

We don't carry an export.h wrapper anymore, remove it from the MANIFEST file to avoid breaking the make perf-tar targets.

---
 tools/perf/MANIFEST | 1 -
 1 file changed, 1 deletion(-)
tools/perf/MANIFEST +0 -1
index f31f15a..af009bd 100644
@@ -41,7 +41,6 @@ tools/include/asm-generic/bitops.h
 tools/include/linux/atomic.h
 tools/include/linux/bitops.h
 tools/include/linux/compiler.h
-tools/include/linux/export.h
 tools/include/linux/hash.h
 tools/include/linux/kernel.h
 tools/include/linux/list.h
#11 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 59 lines · Arnaldo Carvalho de Melo

Em Tue, Aug 25, 2015 at 01:42:27PM +0300, Adrian Hunter escreveu:

Quoted 32 lines

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 2 +-
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/Build +0 -0
index e912856cc4e5..8ae31e5131ee 100644

tools/perf/util/Build libperf-y += stat-shadow.o · line 77

Quoted 5 lines
tools/perf/util/Build +1 -1
@@ -74,7 +74,7 @@ libperf-y += stat-shadow.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-$(CONFIG_X86) += tsc.o
+libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o

I think this is preferred/more clear:

libperf-$(CONFIG_X86) += tsc.o
libperf-$(CONFIG_AUXTRACE) += tsc.o

As we have in drivers/Makefile, in the kernel sources:

drivers/Makefile:obj-$(CONFIG_PCI) += usb/
drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/
drivers/Makefile:obj-$(CONFIG_USB_PHY) += usb/
drivers/Makefile:obj-$(CONFIG_USB) += usb/

From Documentation/kbuild/makefiles.txt:

--- 3.2 Built-in object goals - obj-y

The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration.

Quoted 7 lines

Kbuild compiles all the $(obj-y) files. It then calls "$(LD) -r" to merge these files into one built-in.o file. built-in.o is later linked into vmlinux by the parent Makefile.

The order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into built-in.o and succeeding instances will be ignored.

nope, we don't do that.. but it's nice feature ;-) seems easy enough, I'll check

jirka

author reviewer
#12 lore raw

PATCH v2 1/1 perf tools: Fix build on powerpc broken by pt/bts

In reply to Arnaldo Carvalho de Melo

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---

Changes in V2:

	Use:
		libperf-$(CONFIG_X86) += tsc.o
		libperf-$(CONFIG_AUXTRACE) += tsc.o

	instead of:

		libperf-$(if $(CONFIG_X86)$(CONFIG_AUXTRACE),y) += tsc.o
 tools/perf/util/Build                                    | 1 +
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+)
tools/perf/util/Build +1 -0
index e912856cc4e5..e79e4522368a 100644
@@ -75,6 +75,7 @@ libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
 libperf-$(CONFIG_X86) += tsc.o
+libperf-$(CONFIG_AUXTRACE) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
 libperf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8fcd559..d23138c06665 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;
Signature · 1 line
1.9.1
#13 lore raw

[tip:perf/urgent] perf tools: Fix build on powerpc broken by pt/ bts

perf tools: Fix build on powerpc broken by pt/bts
Commit-ID:  97db62062ac76e314c8bda4dc5b63f0ea906d15f
Gitweb:     http://git.kernel.org/tip/97db62062ac76e314c8bda4dc5b63f0ea906d15f
Author:     Adrian Hunter <[email protected]>
AuthorDate: Mon, 31 Aug 2015 21:39:44 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 31 Aug 2015 15:47:33 -0300

perf tools: Fix build on powerpc broken by pt/bts

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 1 +
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+)
tools/perf/util/Build +1 -0
index e912856..e79e452 100644
@@ -75,6 +75,7 @@ libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
 libperf-$(CONFIG_X86) += tsc.o
+libperf-$(CONFIG_AUXTRACE) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
 libperf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8f..d23138c 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;