Premature use of "legacy" binaries during buildworld

From: Peter Jeremy <peterj_at_freebsd.org>
Date: Sun, 17 Aug 2025 11:19:26 UTC
TL;DR: "make -jN buildworld" can look for executables in
  /usr/obj/usr/src/.../tmp/legacy/bin before it populates that tree.

Since this just bit me and I haven't seen in mentioned here:  I was
trying to run "make -j4 buildworld" and it was consistently dying with:
*** [_cleanworldtmp] Error code 6
But, things seemed to get beyond that when I skipped the "-j4".

With the aid of "ktrace", I tracked it down to
/usr/obj/usr/src/arm64.aarch64/tmp/legacy/bin/sort complaining about a
missing libmd.so.6 (only libmd.so.7 was present).  After blowing away
that "tmp" tree, the buildworld is working as expected.

I haven't tried to dig into the buildworld logic but it seems that there's
some dependency checking missing so "-jN" can result in the "legacy"
binaries being executed before it has been wiped/updated.

In case it matters: I'm building at 20f0996700a8 on a "diskless" Pine H64
(4-core Cortex-A53) (root on NFS, /usr/src read-only NFS) with filemon.

-- 
Peter Jeremy