[Bug 263880] make clean, cleandir doesn't clean /usr/obj

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 09 May 2022 13:48:54 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263880

            Bug ID: 263880
           Summary: make clean, cleandir doesn't clean /usr/obj
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: jon@xyinn.org

Hello,

Apologies if this is not a bug and just a lack of understanding on my part, but
looking at build(7), the description for 'clean' says:

"Remove any files created during the build process."

and the description for 'cleandir' mentions removing the 'canonical object
directory if it exists or perform actions equivalent to 'make clean
cleandepend'.

In my testing, I noticed that if I do a 'make clean' or 'make cleandir' (even
if I run cleandir twice), it doesn't actually clean up my /usr/obj directory.
Only a 'make cleanworld' cleans it:

root@leslie:/usr/src # find /usr/obj
/usr/obj
/usr/obj/usr
/usr/obj/usr/src
/usr/obj/usr/src/amd64.amd64

A quick test I did was the following:

-- I originally did the touch on /usr/obj but I noticed that the cleanworld
command only cleans up stuff under the particular architecture rather than a
flat out nuking of /usr/obj. I'm guessing this is possibly to support a cross
building workflow.

root@leslie:/usr/src # touch /usr/obj/usr/src/amd64.amd64/lol
root@leslie:/usr/src # ls -l /usr/obj/usr/src/amd64.amd64/
total 1
-rw-r--r--  1 root  wheel  0 May  9 09:43 lol

root@leslie:/usr/src # make cleanworld
(cd /usr/obj/usr/src/amd64.amd64/ && rm -rf *)
chflags -R 0 /usr/obj/usr/src/amd64.amd64/
(cd /usr/obj/usr/src/amd64.amd64/ && rm -rf *)

root@leslie:/usr/src # ls -l /usr/obj/usr/src/amd64.amd64/
total 0

----

My expectation for a 'make clean' in /usr/src would be that all of the build
files created are cleaned up (including /usr/obj).

root@leslie:/usr/src # touch /usr/obj/usr/src/amd64.amd64/lol
root@leslie:/usr/src # ls -l /usr/obj/usr/src/amd64.amd64/
total 1
-rw-r--r--  1 root  wheel  0 May  9 09:44 lol

root@leslie:/usr/src # make cleandir

...

root@leslie:/usr/src # ls -l /usr/obj/usr/src/amd64.amd64/
total 1
-rw-r--r--  1 root  wheel  0 May  9 09:44 lol

---

Another related note (which I'll need confirmation for) is if /usr/obj is even
re-used during subsequent builds. The handbook mentions that /usr/obj can speed
up subsequent builds, but I've noticed that the first thing a build does is
pretty much to cleanworld before rebuilding. That kinda defeats the purpose of
re-using those objects. There's this old link (seems forked by someone) where
in the past it mentioned /usr/obj is not used afterwards so it could be
deleted, but I'm not sure if behavior in FreeBSD changed from that time of that
post:

https://people.freebsd.org/~rodrigc/doc/handbook/makeworld.html

-- 
You are receiving this mail because:
You are the assignee for the bug.