All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf
@ 2022-12-15  4:47 Shen Jiamin
  2022-12-15  8:29 ` Jiri Olsa
  2022-12-15 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Shen Jiamin @ 2022-12-15  4:47 UTC (permalink / raw)
  To: Jiri Olsa, bpf; +Cc: Shen Jiamin, Nathan Chancellor

When libelf was not installed in the standard location, it cannot be
located by the current building config.

Use pkg-config to help locate libelf in such cases.

Signed-off-by: Shen Jiamin <shen_jiamin@comp.nus.edu.sg>
---
 tools/bpf/resolve_btfids/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index 19a3112e271a..f7375a119f54 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -56,13 +56,17 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
 		    DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
 		    $(abspath $@) install_headers

+LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
+LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
+
 CFLAGS += -g \
           -I$(srctree)/tools/include \
           -I$(srctree)/tools/include/uapi \
           -I$(LIBBPF_INCLUDE) \
-          -I$(SUBCMD_SRC)
+          -I$(SUBCMD_SRC) \
+          $(LIBELF_FLAGS)

-LIBS = -lelf -lz
+LIBS = $(LIBELF_LIBS) -lz

 export srctree OUTPUT CFLAGS Q
 include $(srctree)/tools/build/Makefile.include
--
2.34.1

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

* Re: [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf
  2022-12-15  4:47 [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf Shen Jiamin
@ 2022-12-15  8:29 ` Jiri Olsa
  2022-12-15 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2022-12-15  8:29 UTC (permalink / raw)
  To: Shen Jiamin; +Cc: bpf, Nathan Chancellor

On Thu, Dec 15, 2022 at 12:47:03PM +0800, Shen Jiamin wrote:
> When libelf was not installed in the standard location, it cannot be
> located by the current building config.
> 
> Use pkg-config to help locate libelf in such cases.
> 
> Signed-off-by: Shen Jiamin <shen_jiamin@comp.nus.edu.sg>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/bpf/resolve_btfids/Makefile | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index 19a3112e271a..f7375a119f54 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -56,13 +56,17 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
>  		    DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
>  		    $(abspath $@) install_headers
> 
> +LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
> +LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
> +
>  CFLAGS += -g \
>            -I$(srctree)/tools/include \
>            -I$(srctree)/tools/include/uapi \
>            -I$(LIBBPF_INCLUDE) \
> -          -I$(SUBCMD_SRC)
> +          -I$(SUBCMD_SRC) \
> +          $(LIBELF_FLAGS)
> 
> -LIBS = -lelf -lz
> +LIBS = $(LIBELF_LIBS) -lz
> 
>  export srctree OUTPUT CFLAGS Q
>  include $(srctree)/tools/build/Makefile.include
> --
> 2.34.1

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

* Re: [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf
  2022-12-15  4:47 [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf Shen Jiamin
  2022-12-15  8:29 ` Jiri Olsa
@ 2022-12-15 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-15 22:00 UTC (permalink / raw)
  To: Shen Jiamin; +Cc: jolsa, bpf, nathan

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Thu, 15 Dec 2022 12:47:03 +0800 you wrote:
> When libelf was not installed in the standard location, it cannot be
> located by the current building config.
> 
> Use pkg-config to help locate libelf in such cases.
> 
> Signed-off-by: Shen Jiamin <shen_jiamin@comp.nus.edu.sg>
> 
> [...]

Here is the summary with links:
  - [v2] tools/resolve_btfids: Use pkg-config to locate libelf
    https://git.kernel.org/bpf/bpf-next/c/0e43662e61f2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-12-15 22:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15  4:47 [PATCH v2] tools/resolve_btfids: Use pkg-config to locate libelf Shen Jiamin
2022-12-15  8:29 ` Jiri Olsa
2022-12-15 22:00 ` patchwork-bot+netdevbpf

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.