Page MenuHomeFreeBSD

cleankernel: A target to delete the kernel compile file
ClosedPublic

Authored by imp on Nov 12 2021, 10:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 19, 4:59 AM
Unknown Object (File)
Fri, Apr 19, 4:59 AM
Unknown Object (File)
Fri, Apr 19, 4:59 AM
Unknown Object (File)
Fri, Apr 19, 4:59 AM
Unknown Object (File)
Fri, Apr 19, 4:59 AM
Unknown Object (File)
Thu, Apr 18, 11:59 PM
Unknown Object (File)
Tue, Apr 16, 9:15 PM
Unknown Object (File)
Tue, Apr 16, 9:15 PM

Details

Summary

With the meta-build, it's always a NO_CLEAN build. However, there's time
you want to blow away the build and try again. 'cleankernel' will delete
the kernel and modules object directories.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Nov 12 2021, 10:44 PM

Looks ok to me. Is this intended to be an internal target, or should cleankernel be documented with other targets at the beginning of the top-level Makefile? I see that cleanworld isn't documented either.

This revision is now accepted and ready to land.Nov 15 2021, 2:56 PM

Looks ok to me. Is this intended to be an internal target, or should cleankernel be documented with other targets at the beginning of the top-level Makefile? I see that cleanworld isn't documented either.

I'm unsure. I followed the 'cleanworld' lead for that. I'm not sure why that's not documented at the top either. I think it should be both or neither. It's a developer target, but there's a lot of developer targets documented.

In D32978#744976, @imp wrote:

Looks ok to me. Is this intended to be an internal target, or should cleankernel be documented with other targets at the beginning of the top-level Makefile? I see that cleanworld isn't documented either.

I'm unsure. I followed the 'cleanworld' lead for that. I'm not sure why that's not documented at the top either. I think it should be both or neither. It's a developer target, but there's a lot of developer targets documented.

Hmm, cleanworld is documented in build.7 though, so perhaps that's a better place to document this anyway. (And a follow-up could just replace the makefile comment with a pointer to build.7.)

Makefile.inc1
3434

Hmm, I think this is so that, say, /usr/obj/usr/src/amd64.amd64 stays around for clean world but all it's subdirs are deleted. Not sure if that behavior change might break some folks (e.g. I sometimes symlink /usr/obj to somewhere else rather than using MAKEOBJDIRPREFIX as that is less cumbersome, and if someone symlinks OBJTOP then this will now delete the symlink rather than what it points to).

If you wanted to avoid tangling with that bit of POLA you could just make cleankernel a separate target and perhaps make it honor KERNCONFS to delete multiple kernel configs while at it, something like:

cleankernel: .PHONY
.for kernel in ${KERNCONFS}
KERNEL_CANONICALOBJDIR:=${KRNLOBJDIR}/${kernel}
.if !empty(KERNEL_CANONICALOBJDIR) && exists(${KERNEL_CANONICALOBJDIR}) && \
   ${.CURDIR:tA} != ${KERNEL_CANONICALOBJDIR}
     -rm -rf ${KERNEL_CANONICALOBJDIR}
     -chflags ...
     -rm ...
.endif
.endfor
Makefile.inc1
3434

The whole reason I took the * out is that it produced a arg list to the shell that was too long. At the very least this warrants a comment explaining why...
And that's a really obscure (and IMHO stupid) M/O wrt OBJTOP... If you do weird stuff, you'll get weird behavior....

And KERNEL_CANONICALOBJDIR can never be empty... it will always have at least / in it... :)

Restore prior behavior w/o the super-long paths

This revision now requires review to proceed.Feb 10 2022, 11:13 PM

add docs in build(7) overlooked in last update

Fold in a quick pointer to build(7) as suggested in the review.

Makefile
4

About half of the following should move to build(7), but I don't have the energy to do that today.

Makefile.inc1
3434

I resorted to a shorter way to do the same thing.

Manual page change is grammatical and spelling looks good. Can't say more.

share/man/man7/build.7
220
222

Manual page change is grammatical and spelling looks good. Can't say more.

Still applies.

tweak man page per review

Makefile.inc1
3436

Out of paranoia this should perhaps be cd ${BW_CANONICALOBJDIR} && rm -rf *? cd might fail if someone's done something weird and removed permissions from the directory.

Makefile.inc1
3436

Both should be. Yes.

This revision is now accepted and ready to land.Feb 11 2022, 5:23 PM
debdrup added a subscriber: debdrup.

Looks good to me, though the summary (and thereby, the commit) should be "there's times". :)