Skip to content

Commit fdb12c8

Browse files
committed
kbuild: Leave objtool binary around with 'make clean'
The difference between 'make clean' and 'make mrproper' is documented in 'make help' as: clean - Remove most generated files but keep the config and enough build support to build external modules mrproper - Remove all generated files + config + various backup files After commit 68b4fe3 ("kbuild: Add objtool to top-level clean target"), running 'make clean' then attempting to build an external module with the resulting build directory fails with $ make ARCH=x86_64 O=build clean $ make -C build M=... MO=... ... /bin/sh: line 1: .../build/tools/objtool/objtool: No such file or directory as 'make clean' removes the objtool binary. Split the objtool clean target into mrproper and clean like Kbuild does and remove all generated artifacts with 'make clean' except for the objtool binary, which is removed with 'make mrproper'. To avoid a small race when running the objtool clean target through both objtool_mrproper and objtool_clean when running 'make mrproper', modify objtool's clean up find command to avoid using find's '-delete' command by piping the files into 'xargs rm -f' like the rest of Kbuild does. Cc: stable@vger.kernel.org Fixes: 68b4fe3 ("kbuild: Add objtool to top-level clean target") Reported-by: Michal Suchanek <msuchanek@suse.de> Closes: https://lore.kernel.org/20260225112633.6123-1-msuchanek@suse.de/ Reported-by: Rainer Fiebig <jrf@mailbox.org> Closes: https://lore.kernel.org/62d12399-76e5-3d40-126a-7490b4795b17@mailbox.org/ Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Tested-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260227-avoid-objtool-binary-removal-clean-v1-1-122f3e55eae9@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 459cb3c commit fdb12c8

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,13 +1497,13 @@ ifneq ($(wildcard $(resolve_btfids_O)),)
14971497
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
14981498
endif
14991499

1500-
PHONY += objtool_clean
1500+
PHONY += objtool_clean objtool_mrproper
15011501

15021502
objtool_O = $(abspath $(objtree))/tools/objtool
15031503

1504-
objtool_clean:
1504+
objtool_clean objtool_mrproper:
15051505
ifneq ($(wildcard $(objtool_O)),)
1506-
$(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean
1506+
$(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) $(patsubst objtool_%,%,$@)
15071507
endif
15081508

15091509
tools/: FORCE
@@ -1686,7 +1686,7 @@ PHONY += $(mrproper-dirs) mrproper
16861686
$(mrproper-dirs):
16871687
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
16881688

1689-
mrproper: clean $(mrproper-dirs)
1689+
mrproper: clean objtool_mrproper $(mrproper-dirs)
16901690
$(call cmd,rmfiles)
16911691
@find . $(RCS_FIND_IGNORE) \
16921692
\( -name '*.rmeta' \) \

tools/objtool/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ $(LIBSUBCMD)-clean:
142142
$(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT)
143143

144144
clean: $(LIBSUBCMD)-clean
145-
$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
146-
$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
145+
$(Q)find $(OUTPUT) \( -name '*.o' -o -name '\.*.cmd' -o -name '\.*.d' \) -type f -print | xargs $(RM)
147146
$(Q)$(RM) $(OUTPUT)arch/x86/lib/cpu-feature-names.c $(OUTPUT)fixdep
148147
$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
149148
$(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.objtool
150149
$(Q)$(RM) -r -- $(OUTPUT)feature
151150

151+
mrproper: clean
152+
$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
153+
152154
FORCE:
153155

154-
.PHONY: clean FORCE
156+
.PHONY: clean mrproper FORCE

0 commit comments

Comments
 (0)