linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Fix dynamic libbpf link
@ 2021-05-08 20:50 Jiri Olsa
  2021-05-09 12:48 ` Arnaldo Carvalho de Melo
  2021-05-10 21:34 ` Justin Forbes
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Olsa @ 2021-05-08 20:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Justin M . Forbes, lkml, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Namhyung Kim, Alexander Shishkin, Michael Petlan

Justin reported broken build with LIBBPF_DYNAMIC=1.

When linking libbpf dynamically we need to use perf's
hashmap object, because it's not exported in libbpf.so
(only in libbpf.a).

Following build is now passing:

  $ make LIBBPF_DYNAMIC=1
    BUILD:   Doing 'make -j8' parallel build
    ...
  $ ldd perf | grep libbpf
        libbpf.so.0 => /lib64/libbpf.so.0 (0x00007fa7630db000)

Fixes: eee19501926d ("perf tools: Grab a copy of libbpf's hashmap")
Cc: Ian Rogers <irogers@google.com>
Reported-by: Justin M. Forbes <jforbes@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Makefile.config | 1 +
 tools/perf/util/Build      | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 7b195e16040e..dacd16874d3d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -546,6 +546,7 @@ ifndef NO_LIBELF
       ifdef LIBBPF_DYNAMIC
         ifeq ($(feature-libbpf), 1)
           EXTLIBS += -lbpf
+          $(call detected,CONFIG_LIBBPF_DYNAMIC)
         else
           dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
         endif
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index e27a551acd3a..95e15d1035ab 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -145,7 +145,14 @@ perf-$(CONFIG_LIBELF) += symbol-elf.o
 perf-$(CONFIG_LIBELF) += probe-file.o
 perf-$(CONFIG_LIBELF) += probe-event.o
 
+ifdef CONFIG_LIBBPF_DYNAMIC
+  hashmap := 1
+endif
 ifndef CONFIG_LIBBPF
+  hashmap := 1
+endif
+
+ifdef hashmap
 perf-y += hashmap.o
 endif
 
-- 
2.31.1


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

* Re: [PATCH] perf tools: Fix dynamic libbpf link
  2021-05-08 20:50 [PATCH] perf tools: Fix dynamic libbpf link Jiri Olsa
@ 2021-05-09 12:48 ` Arnaldo Carvalho de Melo
  2021-05-10 21:34 ` Justin Forbes
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-05-09 12:48 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Ian Rogers, Justin M . Forbes, lkml, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Namhyung Kim, Alexander Shishkin, Michael Petlan

Em Sat, May 08, 2021 at 10:50:20PM +0200, Jiri Olsa escreveu:
> Justin reported broken build with LIBBPF_DYNAMIC=1.
> 
> When linking libbpf dynamically we need to use perf's
> hashmap object, because it's not exported in libbpf.so
> (only in libbpf.a).
> 
> Following build is now passing:
> 
>   $ make LIBBPF_DYNAMIC=1
>     BUILD:   Doing 'make -j8' parallel build
>     ...
>   $ ldd perf | grep libbpf
>         libbpf.so.0 => /lib64/libbpf.so.0 (0x00007fa7630db000)

Thanks, applied.

- Arnaldo

 
> Fixes: eee19501926d ("perf tools: Grab a copy of libbpf's hashmap")
> Cc: Ian Rogers <irogers@google.com>
> Reported-by: Justin M. Forbes <jforbes@redhat.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/Makefile.config | 1 +
>  tools/perf/util/Build      | 7 +++++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 7b195e16040e..dacd16874d3d 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -546,6 +546,7 @@ ifndef NO_LIBELF
>        ifdef LIBBPF_DYNAMIC
>          ifeq ($(feature-libbpf), 1)
>            EXTLIBS += -lbpf
> +          $(call detected,CONFIG_LIBBPF_DYNAMIC)
>          else
>            dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
>          endif
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index e27a551acd3a..95e15d1035ab 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -145,7 +145,14 @@ perf-$(CONFIG_LIBELF) += symbol-elf.o
>  perf-$(CONFIG_LIBELF) += probe-file.o
>  perf-$(CONFIG_LIBELF) += probe-event.o
>  
> +ifdef CONFIG_LIBBPF_DYNAMIC
> +  hashmap := 1
> +endif
>  ifndef CONFIG_LIBBPF
> +  hashmap := 1
> +endif
> +
> +ifdef hashmap
>  perf-y += hashmap.o
>  endif
>  
> -- 
> 2.31.1
> 

-- 

- Arnaldo

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

* Re: [PATCH] perf tools: Fix dynamic libbpf link
  2021-05-08 20:50 [PATCH] perf tools: Fix dynamic libbpf link Jiri Olsa
  2021-05-09 12:48 ` Arnaldo Carvalho de Melo
@ 2021-05-10 21:34 ` Justin Forbes
  1 sibling, 0 replies; 3+ messages in thread
From: Justin Forbes @ 2021-05-10 21:34 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Justin M . Forbes, lkml,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Namhyung Kim,
	Alexander Shishkin, Michael Petlan

On Sat, May 8, 2021 at 3:50 PM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Justin reported broken build with LIBBPF_DYNAMIC=1.
>
> When linking libbpf dynamically we need to use perf's
> hashmap object, because it's not exported in libbpf.so
> (only in libbpf.a).
>
> Following build is now passing:
>
>   $ make LIBBPF_DYNAMIC=1
>     BUILD:   Doing 'make -j8' parallel build
>     ...
>   $ ldd perf | grep libbpf
>         libbpf.so.0 => /lib64/libbpf.so.0 (0x00007fa7630db000)
>
> Fixes: eee19501926d ("perf tools: Grab a copy of libbpf's hashmap")
> Cc: Ian Rogers <irogers@google.com>
> Reported-by: Justin M. Forbes <jforbes@redhat.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---

This patch fixes it for me.

Tested-by: Justin M. Forbes <jforbes@redhat.com>

>  tools/perf/Makefile.config | 1 +
>  tools/perf/util/Build      | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 7b195e16040e..dacd16874d3d 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -546,6 +546,7 @@ ifndef NO_LIBELF
>        ifdef LIBBPF_DYNAMIC
>          ifeq ($(feature-libbpf), 1)
>            EXTLIBS += -lbpf
> +          $(call detected,CONFIG_LIBBPF_DYNAMIC)
>          else
>            dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
>          endif
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index e27a551acd3a..95e15d1035ab 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -145,7 +145,14 @@ perf-$(CONFIG_LIBELF) += symbol-elf.o
>  perf-$(CONFIG_LIBELF) += probe-file.o
>  perf-$(CONFIG_LIBELF) += probe-event.o
>
> +ifdef CONFIG_LIBBPF_DYNAMIC
> +  hashmap := 1
> +endif
>  ifndef CONFIG_LIBBPF
> +  hashmap := 1
> +endif
> +
> +ifdef hashmap
>  perf-y += hashmap.o
>  endif
>
> --
> 2.31.1
>

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

end of thread, other threads:[~2021-05-10 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 20:50 [PATCH] perf tools: Fix dynamic libbpf link Jiri Olsa
2021-05-09 12:48 ` Arnaldo Carvalho de Melo
2021-05-10 21:34 ` Justin Forbes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).