Makefile.inc1 sets MK_CLEAN to "no" under certain conditions when the clean step should be skipped, but it never sets MK_CLEAN to "yes". This causes the clean step to be skipped when it really should be executed. This seems to have been broken for >4 years, since git:75766799863334570acf7a65510361f470ce3b3e.
MK_CLEAN is set by share/mk/src.opts.mk and src.conf(5), and recently switched to avoid doing clean builds by default. See the 20240729 entry in UPDATING: 20240729: The build now defaults to WITHOUT_CLEAN - i.e., no automatic clean is performed at the beginning of buildworld or buildkernel. The WITH_CLEAN src.conf(5) knob can be used to restore the previous behaviour. If you encounter incremental build issues, please report them to the freebsd-current mailing list so that a special-case dependency can be added, if necessary.
OK, the make magic is why grepping the source tree didn't find MK_CLEAN getting set. Caution, contents under pressure, no user serviceable parts inside. The command line options section in Makefile.inc1 needs to be updated for the behavior change. I'm still puzzled why make -V doesn't show MK_CLEAN getting set: # pwd /usr/src # make -V MK_CLEAN # make -D WITH_CLEAN -V MK_CLEAN buildworld # make -D CLEAN -V MK_CLEAN buildworld #
I think -V isn't working because it isn't getting passed down into the sub-make that handles Makefile.inc1. In that case, I don't see how KERNCONF=blah on the command line gets passed down, either.
(In reply to Don Lewis from comment #3) I don't recall the exact details, but -V not working is indeed due to that kind of issue. You can use `make showconfig` to show all of the MK_* settings though, and looking at that target ought to provide some insight on the -V issue.