From 50d3a3f81689586697a38cd60070181ebe626ad9 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Fri, 5 Feb 2021 13:40:20 +0100 Subject: kbuild: Add resolve_btfids clean to root clean target The resolve_btfids tool is used during the kernel build, so we should clean it on kernel's make clean. Invoking the the resolve_btfids clean as part of root 'make clean'. Signed-off-by: Jiri Olsa Signed-off-by: Andrii Nakryiko Acked-by: Song Liu Link: https://lore.kernel.org/bpf/20210205124020.683286-5-jolsa@kernel.org --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b0e4767735dc..159d9592b587 100644 --- a/Makefile +++ b/Makefile @@ -1086,6 +1086,11 @@ ifdef CONFIG_STACK_VALIDATION endif endif +PHONY += resolve_btfids_clean + +resolve_btfids_clean: + $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(abspath $(objtree))/tools/bpf/resolve_btfids clean + ifdef CONFIG_BPF ifdef CONFIG_DEBUG_INFO_BTF ifeq ($(has_libelf),1) @@ -1495,7 +1500,7 @@ vmlinuxclean: $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) -clean: archclean vmlinuxclean +clean: archclean vmlinuxclean resolve_btfids_clean # mrproper - Delete all generated files, including .config # -- cgit v1.2.3 From 0e1aa629f1ce9e8cb89e0cefb9e3bfb3dfa94821 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 11 Feb 2021 13:40:04 +0100 Subject: kbuild: Do not clean resolve_btfids if the output does not exist Nathan reported issue with cleaning empty build directory: $ make -s O=build distclean ../../scripts/Makefile.include:4: *** \ O=/ho...build/tools/bpf/resolve_btfids does not exist. Stop. The problem that tools scripts require existing output directory, otherwise it fails. Adding check around the resolve_btfids clean target to ensure the output directory is in place. Signed-off-by: Jiri Olsa Signed-off-by: Andrii Nakryiko Tested-by: Nathan Chancellor Link: https://lore.kernel.org/bpf/20210211124004.1144344-1-jolsa@kernel.org --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 159d9592b587..b6fa039c18b8 100644 --- a/Makefile +++ b/Makefile @@ -1088,8 +1088,14 @@ endif PHONY += resolve_btfids_clean +resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids + +# tools/bpf/resolve_btfids directory might not exist +# in output directory, skip its clean in that case resolve_btfids_clean: - $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(abspath $(objtree))/tools/bpf/resolve_btfids clean +ifneq ($(wildcard $(resolve_btfids_O)),) + $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean +endif ifdef CONFIG_BPF ifdef CONFIG_DEBUG_INFO_BTF -- cgit v1.2.3