From 230fa08beaa72c00dc66365329e15d74d45546a2 Mon Sep 17 00:00:00 2001 From: greatEndian Date: Wed, 19 Aug 2026 10:12:36 -0400 Subject: [PATCH] build: make depclean remove the userspace dependency files too depclean removed only 'depends', which holds the realtime dependency files. The userspace ones are written next to their objects as objects/**/*.d (see TODEPS and the -MF "${@:.o=.d}" compile rules), and survived it -- 535 of them in a typical run-in-place tree. That matters when a source file is renamed or moved. A stale dependency file still declares, say objects/hal/utils/halrmt.o: hal/utils/halrmt.c and gcc's -MP writes dummy targets for the *headers* only, never for the main source, so once hal/utils/halrmt.c is gone nothing can satisfy that prerequisite and the whole build stops with make: *** No rule to make target 'hal/utils/halrmt.c', needed by 'objects/hal/utils/halrmt.o'. Stop. The documented remedy for stale dependencies is exactly this target, and it did not work: the only way out was 'make clean' and a full rebuild. Hit in practice on a run-in-place tree carried across the halrmt.c -> halrmt.cc rename and the src/libnml/posemath -> src/libposemath move; eight dependency files pointed at sources that no longer existed. Removing the files costs no recompilation -- nothing has a .d as a prerequisite, and UNREAD_DEPS is computed but never used -- so this only gives up header-dependency tracking until each object is next rebuilt, which is what asking for depclean means. Verified by planting a dependency file naming a since-renamed source, reproducing the failure verbatim, and confirming that depclean did not clear it before this change and does after, with the build then completing normally. The comment above modclean is corrected as well: 'clean' does remove the userspace dependency files today, because genclean deletes objects/ wholesale. --- src/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 03d5d76cd2f..713a1b6bb9b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -526,8 +526,8 @@ endif # These rules clean things up. 'modclean' cleans files generated by 'modules' # (except that it doesn't remove the modules that were copied to rtlib) -# 'clean' cleans everything but dependency files, and 'depclean' cleans them -# too. +# 'clean' removes the build products (including, via 'objects', the userspace +# dependency files), and 'depclean' removes the dependency files alone. modclean: find -name '.*.cmd' -or -name '*.ko' -or -name '*.mod.c' -or -name '*.mod.o' | xargs rm -f -rm -rf .tmp_versions @@ -535,8 +535,15 @@ modclean: -rm -f ../rtlib/*.ko -rm -f ../rtlib/*.so +# Realtime dependency files live in 'depends'; userspace ones sit next to +# their objects as objects/**/*.d, so both have to go. Dropping them forces +# no recompilation (nothing depends on a .d existing), but it does clear +# stale prerequisites -- a dependency file naming a source that has since +# been renamed or moved otherwise aborts the build with "No rule to make +# target", and there is no way out of that short of a full 'make clean'. depclean: -rm -rf depends + -find objects -name '*.d' -print0 2>/dev/null | xargs -0 -r rm -f clean: genclean depclean modclean genclean: