tools, bpf/build: Cleanup feature files on make clean
authorJesper Dangaard Brouer <brouer@redhat.com>
Thu, 27 Aug 2020 08:53:36 +0000 (10:53 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 28 Aug 2020 12:04:27 +0000 (14:04 +0200)
The system for "Auto-detecting system features" located under
tools/build/ are (currently) used by perf, libbpf and bpftool. It can
contain stalled feature detection files, which are not cleaned up by
libbpf and bpftool on make clean (side-note: perf tool is correct).

Fix this by making the users invoke the make clean target.

Some details about the changes. The libbpf Makefile already had a
clean-config target (which seems to be copy-pasted from perf), but this
target was not "connected" (a make dependency) to clean target. Choose
not to rename target as someone might be using it. Did change the output
from "CLEAN config" to "CLEAN feature-detect", to make it more clear
what happens.

This is related to the complaint and troubleshooting in the following
link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/
Link: https://lore.kernel.org/bpf/159851841661.1072907.13770213104521805592.stgit@firesoul
tools/bpf/bpftool/Makefile
tools/build/Makefile
tools/lib/bpf/Makefile

index 8462690a039b8e7390f5e71e58bac66fbb1b7947..02c99bc95c6906b426a894b055ed9fb3740cb0f5 100644 (file)
@@ -176,7 +176,11 @@ $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
 $(OUTPUT)%.o: %.c
        $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $<
 
-clean: $(LIBBPF)-clean
+feature-detect-clean:
+       $(call QUIET_CLEAN, feature-detect)
+       $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
+
+clean: $(LIBBPF)-clean feature-detect-clean
        $(call QUIET_CLEAN, bpftool)
        $(Q)$(RM) -- $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
        $(Q)$(RM) -- $(BPFTOOL_BOOTSTRAP) $(OUTPUT)*.skel.h $(OUTPUT)vmlinux.h
index 727050c40f0961c219e6b8e6138df5a7edd17905..722f1700d96a8bce36bb459db981700e87946f7c 100644 (file)
@@ -38,6 +38,8 @@ clean:
        $(call QUIET_CLEAN, fixdep)
        $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
        $(Q)rm -f $(OUTPUT)fixdep
+       $(call QUIET_CLEAN, feature-detect)
+       $(Q)$(MAKE) -C feature/ clean >/dev/null
 
 $(OUTPUT)fixdep-in.o: FORCE
        $(Q)$(MAKE) $(build)=fixdep
index 66b2cfadf26269ecce7f532a8719517fdb61d6eb..adbe994610f2492c130151e0c7c2e7600658c5ad 100644 (file)
@@ -264,10 +264,10 @@ install: install_lib install_pkgconfig install_headers
 ### Cleaning rules
 
 config-clean:
-       $(call QUIET_CLEAN, config)
+       $(call QUIET_CLEAN, feature-detect)
        $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
 
-clean:
+clean: config-clean
        $(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS)                 \
                *~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_HELPER_DEFS)              \
                $(SHARED_OBJDIR) $(STATIC_OBJDIR)                            \