Skip to content
Permalink
Browse files
FROMGIT: 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
(cherry picked from commit 0e3a1c9
 git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master)
Bug: 203823368
Test: build with CONFIG_DEBUG_INFO_BTF=y
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I09ee10b29b57933653eb1cdd4249bac2d9cebf22
  • Loading branch information
cobrien7 committed Jan 18, 2022
1 parent 5c1e9f3 commit 44b9bfcd4cdbc57889a0fecf79a6d30237f21bed
Showing 1 changed file with 5 additions and 2 deletions.
@@ -19,6 +19,8 @@ CC = $(HOSTCC)
LD = $(HOSTLD)
ARCH = $(HOSTARCH)
RM ?= rm
CFLAGS := $(KBUILD_HOSTCFLAGS)
LDFLAGS := $(KBUILD_HOSTLDFLAGS)

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

@@ -41,9 +43,10 @@ $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)

$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ \
EXTRA_CFLAGS="$(CFLAGS)" $(abspath $@)

CFLAGS := -g \
CFLAGS += -g \
-I$(srctree)/tools/include \
-I$(srctree)/tools/include/uapi \
-I$(LIBBPF_SRC) \

0 comments on commit 44b9bfc

Please sign in to comment.