bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] tools/resolve_btfids: build with host flags
@ 2022-01-12  0:25 Connor O'Brien
  2022-01-12 18:18 ` Song Liu
  2022-01-15  1:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Connor O'Brien @ 2022-01-12  0:25 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, netdev, bpf, linux-kernel, Connor O'Brien

resolve_btfids is built using $(HOSTCC) and $(HOSTLD) but does not
pick up the corresponding flags. As a result, host-specific settings
(such as a sysroot specified via HOSTCFLAGS=--sysroot=..., or a linker
specified via HOSTLDFLAGS=-fuse-ld=...) will not be respected.

Fix this by setting CFLAGS to KBUILD_HOSTCFLAGS and LDFLAGS to
KBUILD_HOSTLDFLAGS.

Also pass the cflags through to libbpf via EXTRA_CFLAGS to ensure that
the host libbpf is built with flags consistent with resolve_btfids.

Signed-off-by: Connor O'Brien <connoro@google.com>
---
 tools/bpf/resolve_btfids/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index 9ddeca947..a7f87cdf1 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -20,6 +20,8 @@ LD       = $(HOSTLD)
 ARCH     = $(HOSTARCH)
 RM      ?= rm
 CROSS_COMPILE =
+CFLAGS  := $(KBUILD_HOSTCFLAGS)
+LDFLAGS := $(KBUILD_HOSTLDFLAGS)
 
 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
 
@@ -47,10 +49,10 @@ $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
 
 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
 	$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT)    \
-		    DESTDIR=$(LIBBPF_DESTDIR) prefix=			       \
+		    DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
 		    $(abspath $@) install_headers
 
-CFLAGS := -g \
+CFLAGS += -g \
           -I$(srctree)/tools/include \
           -I$(srctree)/tools/include/uapi \
           -I$(LIBBPF_INCLUDE) \
-- 
2.34.1.575.g55b058a8bb-goog


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

* Re: [PATCH bpf] tools/resolve_btfids: build with host flags
  2022-01-12  0:25 [PATCH bpf] tools/resolve_btfids: build with host flags Connor O'Brien
@ 2022-01-12 18:18 ` Song Liu
  2022-01-15  1:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2022-01-12 18:18 UTC (permalink / raw)
  To: Connor O'Brien
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list

On Tue, Jan 11, 2022 at 4:25 PM Connor O'Brien <connoro@google.com> wrote:
>
> resolve_btfids is built using $(HOSTCC) and $(HOSTLD) but does not
> pick up the corresponding flags. As a result, host-specific settings
> (such as a sysroot specified via HOSTCFLAGS=--sysroot=..., or a linker
> specified via HOSTLDFLAGS=-fuse-ld=...) will not be respected.
>
> Fix this by setting CFLAGS to KBUILD_HOSTCFLAGS and LDFLAGS to
> KBUILD_HOSTLDFLAGS.
>
> Also pass the cflags through to libbpf via EXTRA_CFLAGS to ensure that
> the host libbpf is built with flags consistent with resolve_btfids.
>
> Signed-off-by: Connor O'Brien <connoro@google.com>

I guess this should go to bpf-next tree?

Other than that,

Acked-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCH bpf] tools/resolve_btfids: build with host flags
  2022-01-12  0:25 [PATCH bpf] tools/resolve_btfids: build with host flags Connor O'Brien
  2022-01-12 18:18 ` Song Liu
@ 2022-01-15  1:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-15  1:00 UTC (permalink / raw)
  To: Connor O'Brien
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed, 12 Jan 2022 00:25:03 +0000 you wrote:
> resolve_btfids is built using $(HOSTCC) and $(HOSTLD) but does not
> pick up the corresponding flags. As a result, host-specific settings
> (such as a sysroot specified via HOSTCFLAGS=--sysroot=..., or a linker
> specified via HOSTLDFLAGS=-fuse-ld=...) will not be respected.
> 
> Fix this by setting CFLAGS to KBUILD_HOSTCFLAGS and LDFLAGS to
> KBUILD_HOSTLDFLAGS.
> 
> [...]

Here is the summary with links:
  - [bpf] tools/resolve_btfids: build with host flags
    https://git.kernel.org/bpf/bpf-next/c/0e3a1c902ffb

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-01-15  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12  0:25 [PATCH bpf] tools/resolve_btfids: build with host flags Connor O'Brien
2022-01-12 18:18 ` Song Liu
2022-01-15  1:00 ` patchwork-bot+netdevbpf

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).