From: Viktor Malik on
gitlab.com
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2490#note_1409...
I agree that it's a mess, but this part has been overridden by 56a2df7615
("tools/resolve_btfids: Compile resolve_btfids as host program").
I believe that the actual problem is that `resolve_btfids/Makefile` overrides
`HOSTCFLAGS` (used to be `CFLAGS` but it's the same issue) and that has been
there since the beginning. We just started hitting it now b/c we override
`HOSTCFLAGS` but not `CFLAGS`.
A possible solution would be to change the overridden variable to:
```diff
diff --git a/tools/bpf/resolve_btfids/Makefile
b/tools/bpf/resolve_btfids/Makefile
index ac548a7baa73..aabccc2da1b6 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -67,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)
-HOSTCFLAGS += -g \
+HOSTCFLAGS_resolve_btfids := -g \
-I$(srctree)/tools/include \
-I$(srctree)/tools/include/uapi \
-I$(LIBBPF_INCLUDE) \
@@ -76,7 +76,7 @@ HOSTCFLAGS += -g \
LIBS = $(LIBELF_LIBS) -lz
-export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR
+export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR
include $(srctree)/tools/build/Makefile.include
$(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
```
This way, the update is specific for `resolve_btfids` and can be used in
combination with overriding `HOSTCFLAGS` from the make command.
WDYT @jbencrh? Does this make sense to be sent upstream, too?