Skip to content

Commit 0e3a1c9

Browse files
cobrien7anakryiko
authored andcommitted
tools/resolve_btfids: Build with host flags
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> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20220112002503.115968-1-connoro@google.com
1 parent 71a3cdf commit 0e3a1c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/bpf/resolve_btfids/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ LD = $(HOSTLD)
2020
ARCH = $(HOSTARCH)
2121
RM ?= rm
2222
CROSS_COMPILE =
23+
CFLAGS := $(KBUILD_HOSTCFLAGS)
24+
LDFLAGS := $(KBUILD_HOSTLDFLAGS)
2325

2426
OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
2527

@@ -47,10 +49,10 @@ $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
4749

4850
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
4951
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \
50-
DESTDIR=$(LIBBPF_DESTDIR) prefix= \
52+
DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
5153
$(abspath $@) install_headers
5254

53-
CFLAGS := -g \
55+
CFLAGS += -g \
5456
-I$(srctree)/tools/include \
5557
-I$(srctree)/tools/include/uapi \
5658
-I$(LIBBPF_INCLUDE) \

0 commit comments

Comments
 (0)