git.iko.soy/typeable/nixpkgs
on master help sign in
perf: apply patch to fix build of 4.9
commit44dc31bad1a3e35fd07c78fb3ecf1811db8f95e3 authorBen Wolsieffer <benwolsieffer@gmail.com> dateFri 19 Jan 2018, 22:23 (9 years ago) parent8c25e0d
2 files changed+258
pkgs/os-specific/linux/kernel/perf-tools-fix-build-with-arch-x86_64.patch+255 pkgs/os-specific/linux/kernel/perf.nix+3
pkgs/os-specific/linux/kernel/perf-tools-fix-build-with-arch-x86_64.patchnew file+255
@@ -0,0 +1,255 @@
1+From bfb560d4184c5371f0628c2473eacfb9b4ee8519 Mon Sep 17 00:00:00 2001
2+From: Jiada Wang <jiada_wang@mentor.com>
3+Date: Sun, 9 Apr 2017 20:02:37 -0700
4+Subject: [PATCH] perf tools: Fix build with ARCH=x86_64
5+
6+With commit: 0a943cb10ce78 (tools build: Add HOSTARCH Makefile variable)
7+when building for ARCH=x86_64, ARCH=x86_64 is passed to perf instead of
8+ARCH=x86, so the perf build process searchs header files from
9+tools/arch/x86_64/include, which doesn't exist.
10+
11+The following build failure is seen:
12+
13+ In file included from util/event.c:2:0:
14+ tools/include/uapi/linux/mman.h:4:27: fatal error: uapi/asm/mman.h: No such file or directory
15+ compilation terminated.
16+
17+Fix this issue by using SRCARCH instead of ARCH in perf, just like the
18+main kernel Makefile and tools/objtool's.
19+
20+Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
21+Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
22+Acked-by: Jiri Olsa <jolsa@kernel.org>
23+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
24+Cc: Andi Kleen <ak@linux.intel.com>
25+Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
26+Cc: Jan Stancek <jstancek@redhat.com>
27+Cc: Masami Hiramatsu <mhiramat@kernel.org>
28+Cc: Peter Zijlstra <peterz@infradead.org>
29+Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
30+Cc: Rui Teng <rui.teng@linux.vnet.ibm.com>
31+Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
32+Cc: Wang Nan <wangnan0@huawei.com>
33+Fixes: 0a943cb10ce7 ("tools build: Add HOSTARCH Makefile variable")
34+Link: http://lkml.kernel.org/r/1491793357-14977-2-git-send-email-jiada_wang@mentor.com
35+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
36+---
37+ tools/perf/Makefile.config | 38 +++++++++++++++++++-------------------
38+ tools/perf/Makefile.perf | 2 +-
39+ tools/perf/arch/Build | 2 +-
40+ tools/perf/pmu-events/Build | 4 ++--
41+ tools/perf/tests/Build | 2 +-
42+ tools/perf/util/header.c | 2 +-
43+ 6 files changed, 25 insertions(+), 25 deletions(-)
44+
45+diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
46+index cffdd9cf3ebf..ff375310efe4 100644
47+--- a/tools/perf/Makefile.config
48++++ b/tools/perf/Makefile.config
49+@@ -19,18 +19,18 @@ CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
50+
51+ include $(srctree)/tools/scripts/Makefile.arch
52+
53+-$(call detected_var,ARCH)
54++$(call detected_var,SRCARCH)
55+
56+ NO_PERF_REGS := 1
57+
58+ # Additional ARCH settings for ppc
59+-ifeq ($(ARCH),powerpc)
60++ifeq ($(SRCARCH),powerpc)
61+ NO_PERF_REGS := 0
62+ LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
63+ endif
64+
65+ # Additional ARCH settings for x86
66+-ifeq ($(ARCH),x86)
67++ifeq ($(SRCARCH),x86)
68+ $(call detected,CONFIG_X86)
69+ ifeq (${IS_64_BIT}, 1)
70+ CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated
71+@@ -43,12 +43,12 @@ ifeq ($(ARCH),x86)
72+ NO_PERF_REGS := 0
73+ endif
74+
75+-ifeq ($(ARCH),arm)
76++ifeq ($(SRCARCH),arm)
77+ NO_PERF_REGS := 0
78+ LIBUNWIND_LIBS = -lunwind -lunwind-arm
79+ endif
80+
81+-ifeq ($(ARCH),arm64)
82++ifeq ($(SRCARCH),arm64)
83+ NO_PERF_REGS := 0
84+ LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
85+ endif
86+@@ -61,7 +61,7 @@ endif
87+ # Disable it on all other architectures in case libdw unwind
88+ # support is detected in system. Add supported architectures
89+ # to the check.
90+-ifneq ($(ARCH),$(filter $(ARCH),x86 arm))
91++ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm))
92+ NO_LIBDW_DWARF_UNWIND := 1
93+ endif
94+
95+@@ -115,9 +115,9 @@ endif
96+ FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
97+ FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
98+
99+-FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi
100++FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
101+ # include ARCH specific config
102+--include $(src-perf)/arch/$(ARCH)/Makefile
103++-include $(src-perf)/arch/$(SRCARCH)/Makefile
104+
105+ ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
106+ CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
107+@@ -205,12 +205,12 @@ ifeq ($(DEBUG),0)
108+ endif
109+
110+ CFLAGS += -I$(src-perf)/util/include
111+-CFLAGS += -I$(src-perf)/arch/$(ARCH)/include
112++CFLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
113+ CFLAGS += -I$(srctree)/tools/include/uapi
114+ CFLAGS += -I$(srctree)/tools/include/
115+-CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi
116+-CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/
117+-CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/
118++CFLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
119++CFLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
120++CFLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
121+
122+ # $(obj-perf) for generated common-cmds.h
123+ # $(obj-perf)/util for generated bison/flex headers
124+@@ -321,7 +321,7 @@ ifndef NO_LIBELF
125+
126+ ifndef NO_DWARF
127+ ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
128+- msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
129++ msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
130+ NO_DWARF := 1
131+ else
132+ CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
133+@@ -346,7 +346,7 @@ ifndef NO_LIBELF
134+ CFLAGS += -DHAVE_BPF_PROLOGUE
135+ $(call detected,CONFIG_BPF_PROLOGUE)
136+ else
137+- msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset());
138++ msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
139+ endif
140+ else
141+ msg := $(warning DWARF support is off, BPF prologue is disabled);
142+@@ -372,7 +372,7 @@ ifdef PERF_HAVE_JITDUMP
143+ endif
144+ endif
145+
146+-ifeq ($(ARCH),powerpc)
147++ifeq ($(SRCARCH),powerpc)
148+ ifndef NO_DWARF
149+ CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
150+ endif
151+@@ -453,7 +453,7 @@ else
152+ endif
153+
154+ ifndef NO_LOCAL_LIBUNWIND
155+- ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
156++ ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
157+ $(call feature_check,libunwind-debug-frame)
158+ ifneq ($(feature-libunwind-debug-frame), 1)
159+ msg := $(warning No debug_frame support found in libunwind);
160+@@ -717,7 +717,7 @@ ifeq (${IS_64_BIT}, 1)
161+ NO_PERF_READ_VDSO32 := 1
162+ endif
163+ endif
164+- ifneq ($(ARCH), x86)
165++ ifneq ($(SRCARCH), x86)
166+ NO_PERF_READ_VDSOX32 := 1
167+ endif
168+ ifndef NO_PERF_READ_VDSOX32
169+@@ -746,7 +746,7 @@ ifdef LIBBABELTRACE
170+ endif
171+
172+ ifndef NO_AUXTRACE
173+- ifeq ($(ARCH),x86)
174++ ifeq ($(SRCARCH),x86)
175+ ifeq ($(feature-get_cpuid), 0)
176+ msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
177+ NO_AUXTRACE := 1
178+@@ -793,7 +793,7 @@ sysconfdir = $(prefix)/etc
179+ ETC_PERFCONFIG = etc/perfconfig
180+ endif
181+ ifndef lib
182+-ifeq ($(ARCH)$(IS_64_BIT), x861)
183++ifeq ($(SRCARCH)$(IS_64_BIT), x861)
184+ lib = lib64
185+ else
186+ lib = lib
187+diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
188+index ef52d1e3d431..2b92ffef554b 100644
189+--- a/tools/perf/Makefile.perf
190++++ b/tools/perf/Makefile.perf
191+@@ -192,7 +192,7 @@ endif
192+
193+ ifeq ($(config),0)
194+ include $(srctree)/tools/scripts/Makefile.arch
195+--include arch/$(ARCH)/Makefile
196++-include arch/$(SRCARCH)/Makefile
197+ endif
198+
199+ # The FEATURE_DUMP_EXPORT holds location of the actual
200+diff --git a/tools/perf/arch/Build b/tools/perf/arch/Build
201+index 109eb75cf7de..d9b6af837c7d 100644
202+--- a/tools/perf/arch/Build
203++++ b/tools/perf/arch/Build
204+@@ -1,2 +1,2 @@
205+ libperf-y += common.o
206+-libperf-y += $(ARCH)/
207++libperf-y += $(SRCARCH)/
208+diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
209+index 9213a1273697..999a4e878162 100644
210+--- a/tools/perf/pmu-events/Build
211++++ b/tools/perf/pmu-events/Build
212+@@ -2,7 +2,7 @@ hostprogs := jevents
213+
214+ jevents-y += json.o jsmn.o jevents.o
215+ pmu-events-y += pmu-events.o
216+-JDIR = pmu-events/arch/$(ARCH)
217++JDIR = pmu-events/arch/$(SRCARCH)
218+ JSON = $(shell [ -d $(JDIR) ] && \
219+ find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
220+ #
221+@@ -10,4 +10,4 @@ JSON = $(shell [ -d $(JDIR) ] && \
222+ # directory and create tables in pmu-events.c.
223+ #
224+ $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
225+- $(Q)$(call echo-cmd,gen)$(JEVENTS) $(ARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
226++ $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
227+diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
228+index 8a4ce492f7b2..546250a273e7 100644
229+--- a/tools/perf/tests/Build
230++++ b/tools/perf/tests/Build
231+@@ -71,7 +71,7 @@ $(OUTPUT)tests/llvm-src-relocation.c: tests/bpf-script-test-relocation.c tests/B
232+ $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@
233+ $(Q)echo ';' >> $@
234+
235+-ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64 powerpc))
236++ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc))
237+ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
238+ endif
239+
240+diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
241+index 5337f49db361..28bdb48357f0 100644
242+--- a/tools/perf/util/header.c
243++++ b/tools/perf/util/header.c
244+@@ -826,7 +826,7 @@ static int write_group_desc(int fd, struct perf_header *h __maybe_unused,
245+
246+ /*
247+ * default get_cpuid(): nothing gets recorded
248+- * actual implementation must be in arch/$(ARCH)/util/header.c
249++ * actual implementation must be in arch/$(SRCARCH)/util/header.c
250+ */
251+ int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused)
252+ {
253+--
254+2.15.1
255+
pkgs/os-specific/linux/kernel/perf.nix+3
@@ -50,6 +50,9 @@ stdenv.mkDerivation {
5050 --prefix PATH : "${binutils}/bin"
5151 '';
5252
53+
54+ patches = optional (hasPrefix "4.9" kernel.version) [ ./perf-tools-fix-build-with-arch-x86_64.patch ];
55+
5356 meta = {
5457 homepage = https://perf.wiki.kernel.org/;
5558 description = "Linux tools to profile with performance counters";