Makefile | 8 ++++---- tools/objtool/Makefile | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-)
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 68b4fe32d737 ("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'.
Cc: stable@vger.kernel.org
Fixes: 68b4fe32d737 ("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/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
I realize that this will technically decend into tools/objtool twice
during cleaning when running mrproper but I don't think it is the end of
the world for a much simpler implementation.
I can take this via kbuild-fixes with a proper Ack or it can go through
-tip, does not matter to me.
---
Makefile | 8 ++++----
tools/objtool/Makefile | 6 ++++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index e944c6e71e81..d76d706a5580 100644
--- a/Makefile
+++ b/Makefile
@@ -1497,13 +1497,13 @@ ifneq ($(wildcard $(resolve_btfids_O)),)
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
endif
-PHONY += objtool_clean
+PHONY += objtool_clean objtool_mrproper
objtool_O = $(abspath $(objtree))/tools/objtool
-objtool_clean:
+objtool_clean objtool_mrproper:
ifneq ($(wildcard $(objtool_O)),)
- $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean
+ $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) $(patsubst objtool_%,%,$@)
endif
tools/: FORCE
@@ -1686,7 +1686,7 @@ PHONY += $(mrproper-dirs) mrproper
$(mrproper-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
-mrproper: clean $(mrproper-dirs)
+mrproper: clean objtool_mrproper $(mrproper-dirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.rmeta' \) \
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 6964175abdfd..50d3e38e6137 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -142,13 +142,15 @@ $(LIBSUBCMD)-clean:
$(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT)
clean: $(LIBSUBCMD)-clean
- $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT)arch/x86/lib/cpu-feature-names.c $(OUTPUT)fixdep
$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
$(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.objtool
$(Q)$(RM) -r -- $(OUTPUT)feature
+mrproper: clean
+ $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
+
FORCE:
-.PHONY: clean FORCE
+.PHONY: clean mrproper FORCE
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260227-avoid-objtool-binary-removal-clean-83ce7fbcc8a1
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
On Fri, 27 Feb 2026 22:40:48 -0700, Nathan Chancellor wrote:
> 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
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-fixes
Thanks!
[1/1] kbuild: Leave objtool binary around with 'make clean'
https://git.kernel.org/kbuild/c/fdb12c8a24a45
Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted. Patches applied to an "unstable" branch are accepted pending
wider testing in -next and any post-commit review; they will generally
be moved to the main branch in a week if no issues are found.
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
On Fri, Feb 27, 2026 at 10:40:48PM -0700, Nathan Chancellor wrote:
> 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 68b4fe32d737 ("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'.
>
> Cc: stable@vger.kernel.org
> Fixes: 68b4fe32d737 ("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/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I realize that this will technically decend into tools/objtool twice
> during cleaning when running mrproper but I don't think it is the end of
> the world for a much simpler implementation.
>
> I can take this via kbuild-fixes with a proper Ack or it can go through
> -tip, does not matter to me.
Thanks for fixing it!
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
--
Josh
On Fri, Feb 27, 2026 at 10:40:48PM -0700, Nathan Chancellor wrote:
> 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 68b4fe32d737 ("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'.
>
> Cc: stable@vger.kernel.org
> Fixes: 68b4fe32d737 ("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/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I realize that this will technically decend into tools/objtool twice
> during cleaning when running mrproper but I don't think it is the end of
> the world for a much simpler implementation.
>
> I can take this via kbuild-fixes with a proper Ack or it can go through
> -tip, does not matter to me.
Feel free to take though kbuild-fixes:
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
On Fri, Feb 27, 2026 at 10:40:48PM -0700, Nathan Chancellor wrote:
> 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 68b4fe32d737 ("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'.
>
> Cc: stable@vger.kernel.org
> Fixes: 68b4fe32d737 ("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/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I realize that this will technically decend into tools/objtool twice
> during cleaning when running mrproper but I don't think it is the end of
> the world for a much simpler implementation.
Yes, I think that should be ok.
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Tested-by: Nicolas Schier <nsc@kernel.org>
--
Nicolas
© 2016 - 2026 Red Hat, Inc.