tools/resolve_btfids: Compile resolve_btfids as host program
Jiri Olsa
reviewerPATCH 1/1 tools/resolve_btfids: Compile resolve_btfids as host program
Making resolve_btfids to be compiled as host program so we can avoid cross compile issues as reported by Nathan.
Also we no longer need HOST_OVERRIDES for BINARY target, just for 'prepare' targets.
--- tools/bpf/resolve_btfids/Build | 4 +++- tools/bpf/resolve_btfids/Makefile | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)
tools/bpf/resolve_btfids/Build +3 -1
@@ -1,3 +1,5 @@ +hostprogs := resolve_btfids + resolve_btfids-y += main.o resolve_btfids-y += rbtree.o resolve_btfids-y += zalloc.o
@@ -7,4 +9,4 @@ resolve_btfids-y += str_error_r.o $(OUTPUT)%.o: ../../lib/%.c FORCE $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) + $(call if_changed_dep,host_cc_o_c)
tools/bpf/resolve_btfids/Makefile +6 -3
@@ -22,6 +22,9 @@ HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" RM ?= rm +HOSTCC ?= gcc +HOSTLD ?= ld +HOSTAR ?= ar CROSS_COMPILE = OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
@@ -64,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) -CFLAGS += -g \ +HOSTCFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \
@@ -73,11 +76,11 @@ CFLAGS += -g \ LIBS = $(LIBELF_LIBS) -lz -export srctree OUTPUT CFLAGS Q +export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) - $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) + $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@)
Signature · 1 line
2.39.1
Quoted 10 lines · Jiri Olsa
Making
resolve_btfidsto be compiled as host program so we can avoid cross compile issues as reported by Nathan.Also we no longer need
HOST_OVERRIDESfor BINARY target, just for 'prepare' targets.Cc Ian Rogers <[email protected]>Fixes 13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jiri Olsa <[email protected]>
Quoted 61 lines
--- tools/bpf/resolve_btfids/Build | 4 +++- tools/bpf/resolve_btfids/Makefile | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)tools/bpf/resolve_btfids/Build +3
-1@@ -1,3 +1,5 @@ +hostprogs := resolve_btfids + resolve_btfids-y += main.o resolve_btfids-y += rbtree.o resolve_btfids-y += zalloc.o@@ -7,4 +9,4 @@ resolve_btfids-y += str_error_r.o $(OUTPUT)%.o: ../../lib/%.c FORCE $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) + $(call if_changed_dep,host_cc_o_c)tools/bpf/resolve_btfids/Makefile +6
-3@@ -22,6 +22,9 @@ HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" RM ?= rm +HOSTCC ?= gcc +HOSTLD ?= ld +HOSTAR ?= ar CROSS_COMPILE = OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/@@ -64,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) -CFLAGS += -g \ +HOSTCFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \@@ -73,11 +76,11 @@ CFLAGS += -g \ LIBS = $(LIBELF_LIBS) -lz -export srctree OUTPUT CFLAGS Q +export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) - $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) + $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@)Signature · 1 line
2.39.1
Ian Rogers
Acked-byQuoted 8 lines · Nathan Chancellor
Quoted 6 lines · Jiri Olsa
Making
resolve_btfidsto be compiled as host program so we can avoid cross compile issues as reported by Nathan.Also we no longer need
HOST_OVERRIDESfor BINARY target, just for 'prepare' targets.
Quoted 7 lines
Quoted 4 lines
Cc Ian Rogers <[email protected]>Fixes 13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jiri Olsa <[email protected]>Tested-by Nathan Chancellor <[email protected]>
This change has my,
but I wonder about cleaning HOST_OVERRIDES. From the patch I sent, would it be worth adding:
``` --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -17,9 +17,9 @@ else MAKEFLAGS=--no-print-directory endif -# always use the host compiler +# Overrides for the prepare step libraries. HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \ - EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" + CROSS_COMPILE="" RM ?= rm HOSTCC ?= gcc ```
It seems odd passing HOSTCFLAGS this way and mixing HOSTCC as CC with CROSS_COMPILE set seems open to failure. Perhaps we should just get rid of this, add something like a HOST=1 option for building the library and then in the library code do the right thing. That would fix the issue that libsubcmd and libbpf here are being built reporting CC rather than HOSTCC, make the build flags in general more sane.
Thanks,
Ian
Quoted 61 lines
Quoted 61 lines
--- tools/bpf/resolve_btfids/Build | 4 +++- tools/bpf/resolve_btfids/Makefile | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)tools/bpf/resolve_btfids/Build +3
-1@@ -1,3 +1,5 @@ +hostprogs := resolve_btfids + resolve_btfids-y += main.o resolve_btfids-y += rbtree.o resolve_btfids-y += zalloc.o@@ -7,4 +9,4 @@ resolve_btfids-y += str_error_r.o $(OUTPUT)%.o: ../../lib/%.c FORCE $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) + $(call if_changed_dep,host_cc_o_c)tools/bpf/resolve_btfids/Makefile +6
-4@@ -22,6 +22,9 @@ HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" RM ?= rm +HOSTCC ?= gcc +HOSTLD ?= ld +HOSTAR ?= ar CROSS_COMPILE = OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/@@ -64,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) -CFLAGS += -g \ +HOSTCFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \@@ -73,11 +76,11 @@ CFLAGS += -g \ LIBS = $(LIBELF_LIBS) -lz -export srctree OUTPUT CFLAGS Q +export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) - $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) + $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@) --2.39.1
Quoted 14 lines · Ian Rogers
Quoted 13 lines · Nathan Chancellor
Quoted 10 lines · Jiri Olsa
Making
resolve_btfidsto be compiled as host program so we can avoid cross compile issues as reported by Nathan.Also we no longer need
HOST_OVERRIDESfor BINARY target, just for 'prepare' targets.Cc Ian Rogers <[email protected]>Fixes 13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jiri Olsa <[email protected]>
Quoted 5 lines
Quoted 2 lines
Tested-by Nathan Chancellor <[email protected]>This change has my,
Acked-by Ian Rogers <[email protected]>
thanks
Quoted 16 lines
but I wonder about cleaning
HOST_OVERRIDES. From the patch I sent, would it be worth adding:
```tools/bpf/resolve_btfids/Makefile +0
-0@@ -17,9 +17,9 @@ else MAKEFLAGS=--no-print-directoryendif
tools/bpf/resolve_btfids/Makefile +1
-1-# always use the host compiler +# Overrides for the prepare step libraries.
HOST_OVERRIDES:= AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \tools/bpf/resolve_btfids/Makefile +1
-1- EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" + CROSS_COMPILE=""
Quoted 9 lines
RM ?= rm
HOSTCC ?= gcc
```
It seems odd passing HOSTCFLAGS this way and mixing HOSTCC as CC withCROSS_COMPILEset seems open to failure. Perhaps we should just get rid of this, add something like a HOST=1 option for building the library and then in the library code do the right thing. That would fix the issue that libsubcmd and libbpf here are being built reporting CC rather than HOSTCC, make the build flags in general more sane.
could you send separate patch with that?
also I'll try to check if we could make prepare libs as hostprogs, because I think the changes you suggest might depend on that
jirka
Quoted 65 lines
Thanks,
IanQuoted 61 lines
Quoted 61 lines
--- tools/bpf/resolve_btfids/Build | 4 +++- tools/bpf/resolve_btfids/Makefile | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)tools/bpf/resolve_btfids/Build +3
-1@@ -1,3 +1,5 @@ +hostprogs := resolve_btfids + resolve_btfids-y += main.o resolve_btfids-y += rbtree.o resolve_btfids-y += zalloc.o@@ -7,4 +9,4 @@ resolve_btfids-y += str_error_r.o $(OUTPUT)%.o: ../../lib/%.c FORCE $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) + $(call if_changed_dep,host_cc_o_c)tools/bpf/resolve_btfids/Makefile +6
-4@@ -22,6 +22,9 @@ HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" RM ?= rm +HOSTCC ?= gcc +HOSTLD ?= ld +HOSTAR ?= ar CROSS_COMPILE = OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/@@ -64,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) -CFLAGS += -g \ +HOSTCFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \@@ -73,11 +76,11 @@ CFLAGS += -g \ LIBS = $(LIBELF_LIBS) -lz -export srctree OUTPUT CFLAGS Q +export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) - $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) + $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@) --2.39.1
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 6 lines · On Thu, 2 Feb 2023 12:28:39 +0100 you wrote:
Making
resolve_btfidsto be compiled as host program so we can avoid cross compile issues as reported by Nathan.Also we no longer need
HOST_OVERRIDESfor BINARY target, just for 'prepare' targets.
Quoted 6 lines
Cc Ian Rogers <[email protected]>Fixes 13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jiri Olsa <[email protected]>[...]
Here is the summary with links:
- [bpf-next] tools/resolve_btfids: Compile resolve_btfids as host program
https://git.kernel.org/bpf/bpf-next/c/56a2df7615fa
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html