From: Nai-Chen Cheng bleach1827@gmail.com
[ Upstream commit d3f7457da7b9527a06dbcbfaf666aa51ac2eeb53 ]
The selftests 'make clean' does not clean the net/lib because it only processes $(TARGETS) and ignores $(INSTALL_DEP_TARGETS). This leaves compiled objects in net/lib after cleaning, requiring manual cleanup.
Include $(INSTALL_DEP_TARGETS) in clean target to ensure net/lib dependency is properly cleaned.
Signed-off-by: Nai-Chen Cheng bleach1827@gmail.com Reviewed-by: Simon Horman horms@kernel.org Tested-by: Simon Horman horms@kernel.org # build-tested Acked-by: Shuah Khan skhan@linuxfoundation.org Link: https://patch.msgid.link/20250910-selftests-makefile-clean-v1-1-29e7f496cd87... Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES – updating `tools/testing/selftests/Makefile:319` to iterate over `$(TARGETS) $(INSTALL_DEP_TARGETS)` brings the `clean` recipe in line with the existing `all` and `install` loops (`tools/testing/selftests/Makefile:211` and `:276`), so the implicit net/lib helper that gets built for networking selftests is now removed during `make clean`. This fixes a real annoyance where stale objects remain under `net/lib/` after cleaning, forcing manual removal and risking rebuild flakiness if headers or tooling change. The change is tiny, selftests-only, and mirrors logic already exercised in other targets, so regression risk is negligible. Just make sure the stable branch you target already carries the dependency hook that introduced `INSTALL_DEP_TARGETS` (commit b86761ff6374813cdf64ffd6b95ddd1813c435d8 or equivalent); older branches without that infrastructure don’t need this patch. Natural follow-up: once backported, run `make -C tools/testing/selftests clean` after building the net tests to confirm the stale net/lib objects are cleared.
tools/testing/selftests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 030da61dbff3a..a2d8e1093b005 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -314,7 +314,7 @@ gen_tar: install @echo "Created ${TAR_PATH}"
clean: - @for TARGET in $(TARGETS); do \ + @for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ done;