Skip to content

Commit 13e0769

Browse files
captain5050borkmann
authored andcommitted
tools/resolve_btfids: Alter how HOSTCC is forced
HOSTCC is always wanted when building. Setting CC to HOSTCC happens after tools/scripts/Makefile.include is included, meaning flags are set assuming say CC is gcc, but then it can be later set to HOSTCC which may be clang. tools/scripts/Makefile.include is needed for host set up and common macros in objtool's Makefile. Rather than override CC to HOSTCC, just pass CC as HOSTCC to Makefile.build, the libsubcmd builds and the linkage step. This means the Makefiles don't see things like CC changing and tool flag determination, and similar, work properly. Also, clear the passed subdir as otherwise an outer build may break by inadvertently passing an inappropriate value. Signed-off-by: Ian Rogers <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent af03299 commit 13e0769

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tools/bpf/resolve_btfids/Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ else
1818
endif
1919

2020
# always use the host compiler
21-
AR = $(HOSTAR)
22-
CC = $(HOSTCC)
23-
LD = $(HOSTLD)
24-
ARCH = $(HOSTARCH)
21+
HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \
22+
EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)"
23+
2524
RM ?= rm
2625
CROSS_COMPILE =
27-
CFLAGS := $(KBUILD_HOSTCFLAGS)
28-
LDFLAGS := $(KBUILD_HOSTLDFLAGS)
2926

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

@@ -56,12 +53,12 @@ $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
5653

5754
$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
5855
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \
59-
DESTDIR=$(SUBCMD_DESTDIR) prefix= \
56+
DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
6057
$(abspath $@) install_headers
6158

6259
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
6360
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \
64-
DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
61+
DESTDIR=$(LIBBPF_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
6562
$(abspath $@) install_headers
6663

6764
LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
@@ -80,11 +77,11 @@ export srctree OUTPUT CFLAGS Q
8077
include $(srctree)/tools/build/Makefile.include
8178

8279
$(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
83-
$(Q)$(MAKE) $(build)=resolve_btfids
80+
$(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES)
8481

8582
$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
8683
$(call msg,LINK,$@)
87-
$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
84+
$(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HOSTLDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
8885

8986
clean_objects := $(wildcard $(OUTPUT)/*.o \
9087
$(OUTPUT)/.*.o.cmd \

0 commit comments

Comments
 (0)