perf build: PowerPC: Fix build breakage due to libbpf
Subsystems (3)
v4 cover perf build: PowerPC: Fix build breakage due to libbpf
Fix PowerPC build breakage found by Naveen.
Perf building should not be blocked if BPF syscall is broken in some platform.
In v3 a problem in 3/3 is found and fixed, but I only sent v4 of 3/3. Send all 3 patches together again.
Naveen N. Rao (1):
perf: bpf: Fix build breakage due to libbpf
Wang Nan (2):
perf tools: Fix PowerPC native building
tools: Move Makefile.arch from perf/config to tools/scripts
tools/build/feature/test-bpf.c | 20 +++++++++++++++++++- tools/lib/bpf/Makefile | 9 ++++++++- tools/lib/bpf/bpf.c | 4 ++-- tools/perf/config/Makefile | 2 +- tools/perf/config/Makefile.arch | 18 ------------------ tools/perf/tests/make | 2 +- tools/scripts/Makefile.arch | 18 ++++++++++++++++++ 7 files changed, 49 insertions(+), 24 deletions(-) delete mode 100644 tools/perf/config/Makefile.arch create mode 100644 tools/scripts/Makefile.arch
Signature · 1 line
1.8.3.4
PATCH RESEND v4 1/3 perf tools: Fix PowerPC native building
Checks BPF syscall number, turn off libbpf building on platform doesn't correctly support sys_bpf instead of blocking compiling.
--- tools/build/feature/test-bpf.c | 20 +++++++++++++++++++- tools/lib/bpf/bpf.c | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-)
tools/build/feature/test-bpf.c +19 -1
@@ -1,9 +1,23 @@ +#include <asm/unistd.h> #include <linux/bpf.h> +#include <unistd.h> + +#ifndef __NR_bpf +# if defined(__i386__) +# define __NR_bpf 357 +# elif defined(__x86_64__) +# define __NR_bpf 321 +# elif defined(__aarch64__) +# define __NR_bpf 280 +# error __NR_bpf not defined. libbpf does not support your arch. +# endif +#endif int main (void ) {union bpf_attr attr; +/* Check fields in attr */ attr.prog_type =BPF_PROG_TYPE_KPROBE ; attr.insn_cnt =0 ; attr.insns =0 ;
@@ -14,5 +28,9 @@ int main(void) attr.kern_version =0 ; attr = attr; -return 0 ; +/* +* Test existence of __NR_bpf and BPF_PROG_LOAD. +* This call should fail if we run the testcase. +*/ +return syscall (__NR_bpf,BPF_PROG_LOAD , attr,sizeof (attr)); }
tools/lib/bpf/bpf.c +2 -2
@@ -14,8 +14,8 @@#include "bpf.h" /* -* When building perf, unistd.h is override. Define __NR_bpf is -* required to be defined. +* When building perf, unistd.h is overrided. __NR_bpf is +* required to be defined explicitly. */ #ifndef __NR_bpf# if defined(__i386__)
Signature · 1 line
1.8.3.4
PATCH RESEND v4 2/3 tools: Move Makefile.arch from perf/config to tools/scripts
In reply to Wang NanAfter this patch other directories can use this architecture detector without directly including it from perf's directory. Libbpf would utilize it to get proper $(ARCH) so it can receive correct uapi include directory.
--- tools/perf/config/Makefile | 2 +- tools/perf/config/Makefile.arch | 18 ------------------ tools/perf/tests/make | 2 +- tools/scripts/Makefile.arch | 18 ++++++++++++++++++ 4 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 tools/perf/config/Makefile.arch create mode 100644 tools/scripts/Makefile.arch
tools/perf/config/Makefile +1 -1
@@ -17,7 +17,7 @@ detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) -include $(src-perf)/config/Makefile.arch +include $(srctree)/tools/scripts/Makefile.arch $(call detected_var,ARCH)
tools/perf/config/Makefile.arch deleted +0 -18
@@ -1,18 +0,0 @@ -ifndef ARCH -ARCH := $(shell uname -m 2>/dev/null || echo not) -endif - -ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc/ -e s/sparc64/sparc/ \ - -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/tile.*/tile/ ) - -LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) -ifeq ($(LP64), 1) - IS_64_BIT := 1 -else - IS_64_BIT := 0 -endif
tools/perf/tests/make +1 -1
@@ -12,7 +12,7 @@ endif else PERF := . -include config/Makefile.arch +include $(srctree)/scripts/Makefile.arch # FIXME looks like x86 is the only arch running tests ;-) # we need some IS_(32/64) flag to make this generic
tools/scripts/Makefile.arch new file +18 -0
@@ -0,0 +1,18 @@ +ifndef ARCH +ARCH := $(shell uname -m 2>/dev/null || echo not) +endif + +ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc/ -e s/sparc64/sparc/ \ + -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/tile.*/tile/ ) + +LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) +ifeq ($(LP64), 1) + IS_64_BIT := 1 +else + IS_64_BIT := 0 +endif
Signature · 1 line
1.8.3.4
Re: [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts
Quoted 11 lines · Wang Nan
After this patch other directories can use this architecture detector without directly including it from perf's directory. Libbpf would utilize it to get proper $(ARCH) so it can receive correct uapi include directory.
Signed-off-by Wang Nan <[email protected]>Acked-by Jiri Olsa <[email protected]>Tested-by Naveen N. Rao <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Naveen N. Rao <[email protected]>Cc Sukadev Bhattiprolu <[email protected]>
Quoted 8 lines
--- tools/perf/config/Makefile | 2 +- tools/perf/config/Makefile.arch | 18 ------------------ tools/perf/tests/make | 2 +- tools/scripts/Makefile.arch | 18 ++++++++++++++++++ 4 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 tools/perf/config/Makefile.arch create mode 100644 tools/scripts/Makefile.arch
^^^^^^
This is different from your previous version. This should be a file rename.
- Naveen
Re: [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts
Quoted 20 lines · Naveen N. Rao
Quoted 11 lines · Wang Nan
After this patch other directories can use this architecture detector without directly including it from perf's directory. Libbpf would utilize it to get proper $(ARCH) so it can receive correct uapi include directory.
Signed-off-by Wang Nan <[email protected]>Acked-by Jiri Olsa <[email protected]>Tested-by Naveen N. Rao <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Naveen N. Rao <[email protected]>Cc Sukadev Bhattiprolu <[email protected]>Quoted 8 lines
--- tools/perf/config/Makefile | 2 +- tools/perf/config/Makefile.arch | 18 ------------------ tools/perf/tests/make | 2 +- tools/scripts/Makefile.arch | 18 ++++++++++++++++++ 4 files changed, 20 insertions(+), 20 deletions(-)delete mode 100644
tools/perf/config/Makefile.archcreate mode 100644tools/scripts/Makefile.arch
Quoted 3 lines
^^^^^^This is different from your previous version. This should be a file rename.
Forget to use git format -M. The content is identical. Should I send it again?
Thank you.
PATCH RESEND v4 3/3 perf: bpf: Fix build breakage due to libbpf
In reply to Wang NanFrom: "Naveen N. Rao" <[email protected]>
perf build is currently (v4.4-rc5) broken on powerpc:
bpf.c:28:4: error: #error __NR_bpf not defined. libbpf does not support your arch.
# error __NR_bpf not defined. libbpf does not support your arch.
^
Fix this by including tools/scripts/Makefile.arch for the proper $ARCH macro. While at it, remove redundant LP64 macro definition.
Also, since libbpf require $(srctree) now, detect the path of srctree like perf.
--- tools/lib/bpf/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/lib/bpf/Makefile +8 -1
@@ -6,6 +6,12 @@ BPF_EXTRAVERSION = 1 MAKEFLAGS += --no-print-directory +ifeq ($(srctree),) +srctree := $(patsubst %/,%,$(dir $(shell pwd))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +#$(info Determined 'srctree' to be $(srctree)) +endif # Makefiles suck: This macro sets a default value of $(2) for the # variable named by $(1), unless the variable has been set by
@@ -31,7 +37,8 @@ INSTALL = install DESTDIR ?= DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' -LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) +include $(srctree)/tools/scripts/Makefile.arch + ifeq ($(LP64), 1) libdir_relative = lib64 else
Signature · 1 line
1.8.3.4