Page MenuHomeFreeBSD

cleankernel: A target to delete the kernel compile file
AcceptedPublic

Authored by imp on Nov 12 2021, 10:44 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
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 42771
Build 39659: arc lint + arc unit

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
3406

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
3406

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... :)