All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1
@ 2023-10-27 14:18 Arnaldo Carvalho de Melo
  2023-10-27 15:00 ` Ian Rogers
  2023-10-30 18:59 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-10-27 14:18 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Linux Kernel Mailing List,
	linux-perf-users

While building on a wide range of distros and clang versions it was
noticed that at least version 12.0.1 (noticed on Alpine 3.15 with
"Alpine clang version 12.0.1") is needed to not fail with BTF generation
errors such as:

Debian:10

  Debian clang version 11.0.1-2~deb10u1:

    CLANG   /tmp/build/perf/util/bpf_skel/.tmp/sample_filter.bpf.o
  <SNIP>
    GENSKEL /tmp/build/perf/util/bpf_skel/sample_filter.skel.h
  libbpf: failed to find BTF for extern 'bpf_cast_to_kern_ctx' [21] section: -2
  Error: failed to open BPF object file: No such file or directory
  make[2]: *** [Makefile.perf:1121: /tmp/build/perf/util/bpf_skel/sample_filter.skel.h] Error 254
  make[2]: *** Deleting file '/tmp/build/perf/util/bpf_skel/sample_filter.skel.h'

Amazon Linux 2:

  clang version 11.1.0 (Amazon Linux 2 11.1.0-1.amzn2.0.2)

    GENSKEL /tmp/build/perf/util/bpf_skel/sample_filter.skel.h
  libbpf: elf: skipping unrecognized data section(18) .eh_frame
  libbpf: elf: skipping relo section(19) .rel.eh_frame for section(18) .eh_frame
  libbpf: failed to find BTF for extern 'bpf_cast_to_kern_ctx' [21] section: -2
  Error: failed to open BPF object file: No such file or directory
  make[2]: *** [/tmp/build/perf/util/bpf_skel/sample_filter.skel.h] Error 254
  make[2]: *** Deleting file `/tmp/build/perf/util/bpf_skel/sample_filter.skel.h'

Ubuntu 20.04:

  clang version 10.0.0-4ubuntu1

    CLANG   /tmp/build/perf/util/bpf_skel/.tmp/augmented_raw_syscalls.bpf.o
    GENSKEL /tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h
    GENSKEL /tmp/build/perf/util/bpf_skel/bperf_leader.skel.h
  libbpf: sec '.reluprobe': corrupted symbol #27 pointing to invalid section #65522 for relo #0
    GENSKEL /tmp/build/perf/util/bpf_skel/bperf_follower.skel.h
  Error: failed to open BPF object file: BPF object format invalid
  make[2]: *** [Makefile.perf:1121: /tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h] Error 95
  make[2]: *** Deleting file '/tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h'

So check if the version is at least 12.0.1 otherwise disable building
BPF skels and provide a message about it, continuing the build.

The message, when running on amazonlinux:2:

  Makefile.config:698: Warning: Disabled BPF skeletons as reliable BTF generation needs at least clang version 12.0.1

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 4300a9e4253a0c87..8b6cffbc485834c8 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -693,6 +693,13 @@ ifeq ($(BUILD_BPF_SKEL),1)
     dummy := $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing)
     BUILD_BPF_SKEL := 0
   else
+    CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
+    ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1)
+      dummy := $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1)
+      BUILD_BPF_SKEL := 0
+    endif
+  endif
+  ifeq ($(BUILD_BPF_SKEL),1)
     $(call feature_check,clang-bpf-co-re)
     ifeq ($(feature-clang-bpf-co-re), 0)
       dummy := $(warning Warning: Disabled BPF skeletons as clang is too old)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1
  2023-10-27 14:18 [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1 Arnaldo Carvalho de Melo
@ 2023-10-27 15:00 ` Ian Rogers
  2023-10-30 18:59 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2023-10-27 15:00 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Adrian Hunter, Jiri Olsa, Linux Kernel Mailing List,
	linux-perf-users

On Fri, Oct 27, 2023 at 7:18 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> While building on a wide range of distros and clang versions it was
> noticed that at least version 12.0.1 (noticed on Alpine 3.15 with
> "Alpine clang version 12.0.1") is needed to not fail with BTF generation
> errors such as:
>
> Debian:10
>
>   Debian clang version 11.0.1-2~deb10u1:
>
>     CLANG   /tmp/build/perf/util/bpf_skel/.tmp/sample_filter.bpf.o
>   <SNIP>
>     GENSKEL /tmp/build/perf/util/bpf_skel/sample_filter.skel.h
>   libbpf: failed to find BTF for extern 'bpf_cast_to_kern_ctx' [21] section: -2
>   Error: failed to open BPF object file: No such file or directory
>   make[2]: *** [Makefile.perf:1121: /tmp/build/perf/util/bpf_skel/sample_filter.skel.h] Error 254
>   make[2]: *** Deleting file '/tmp/build/perf/util/bpf_skel/sample_filter.skel.h'
>
> Amazon Linux 2:
>
>   clang version 11.1.0 (Amazon Linux 2 11.1.0-1.amzn2.0.2)
>
>     GENSKEL /tmp/build/perf/util/bpf_skel/sample_filter.skel.h
>   libbpf: elf: skipping unrecognized data section(18) .eh_frame
>   libbpf: elf: skipping relo section(19) .rel.eh_frame for section(18) .eh_frame
>   libbpf: failed to find BTF for extern 'bpf_cast_to_kern_ctx' [21] section: -2
>   Error: failed to open BPF object file: No such file or directory
>   make[2]: *** [/tmp/build/perf/util/bpf_skel/sample_filter.skel.h] Error 254
>   make[2]: *** Deleting file `/tmp/build/perf/util/bpf_skel/sample_filter.skel.h'
>
> Ubuntu 20.04:
>
>   clang version 10.0.0-4ubuntu1
>
>     CLANG   /tmp/build/perf/util/bpf_skel/.tmp/augmented_raw_syscalls.bpf.o
>     GENSKEL /tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h
>     GENSKEL /tmp/build/perf/util/bpf_skel/bperf_leader.skel.h
>   libbpf: sec '.reluprobe': corrupted symbol #27 pointing to invalid section #65522 for relo #0
>     GENSKEL /tmp/build/perf/util/bpf_skel/bperf_follower.skel.h
>   Error: failed to open BPF object file: BPF object format invalid
>   make[2]: *** [Makefile.perf:1121: /tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h] Error 95
>   make[2]: *** Deleting file '/tmp/build/perf/util/bpf_skel/bench_uprobe.skel.h'
>
> So check if the version is at least 12.0.1 otherwise disable building
> BPF skels and provide a message about it, continuing the build.
>
> The message, when running on amazonlinux:2:
>
>   Makefile.config:698: Warning: Disabled BPF skeletons as reliable BTF generation needs at least clang version 12.0.1
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/Makefile.config | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 4300a9e4253a0c87..8b6cffbc485834c8 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -693,6 +693,13 @@ ifeq ($(BUILD_BPF_SKEL),1)
>      dummy := $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missing)
>      BUILD_BPF_SKEL := 0
>    else
> +    CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
> +    ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1)
> +      dummy := $(warning Warning: Disabled BPF skeletons as reliable BTF generation needs at least $(CLANG) version 12.0.1)
> +      BUILD_BPF_SKEL := 0
> +    endif
> +  endif
> +  ifeq ($(BUILD_BPF_SKEL),1)
>      $(call feature_check,clang-bpf-co-re)
>      ifeq ($(feature-clang-bpf-co-re), 0)
>        dummy := $(warning Warning: Disabled BPF skeletons as clang is too old)
> --
> 2.41.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1
  2023-10-27 14:18 [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1 Arnaldo Carvalho de Melo
  2023-10-27 15:00 ` Ian Rogers
@ 2023-10-30 18:59 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2023-10-30 18:59 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, linux-perf-users, Linux Kernel Mailing List,
	Jiri Olsa, Adrian Hunter

On Fri, 27 Oct 2023 11:18:47 -0300, Arnaldo Carvalho de Melo wrote:
> While building on a wide range of distros and clang versions it was
> noticed that at least version 12.0.1 (noticed on Alpine 3.15 with
> "Alpine clang version 12.0.1") is needed to not fail with BTF generation
> errors such as:
> 
> Debian:10
> 
> [...]

Applied to perf-tools-next, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-30 18:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 14:18 [PATCH 1/1] perf build: Disable BPF skeletons if clang version is < 12.0.1 Arnaldo Carvalho de Melo
2023-10-27 15:00 ` Ian Rogers
2023-10-30 18:59 ` Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.