Re: git: 22ca6db50f4e - main - config.mk: Add MK_VIMAGE knob

From: Warner Losh <imp_at_bsdimp.com>
Date: Sat, 13 Apr 2024 17:07:25 UTC
On Fri, Apr 12, 2024 at 1:29 PM Bjoern A. Zeeb <
bzeeb-lists@lists.zabbadoz.net> wrote:

> On Tue, 9 Apr 2024, Stephen J. Kiernan wrote:
>
> > The branch main has been updated by stevek:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=22ca6db50f4e6bd75a141f57cf953d8de6531a06
> >
> > commit 22ca6db50f4e6bd75a141f57cf953d8de6531a06
> > Author:     Stephen J. Kiernan <stevek@FreeBSD.org>
> > AuthorDate: 2024-04-09 17:04:24 +0000
> > Commit:     Stephen J. Kiernan <stevek@FreeBSD.org>
> > CommitDate: 2024-04-09 17:05:56 +0000
> >
> >    config.mk: Add MK_VIMAGE knob
> >
> >    Default to VIMAGE as yes.
> >    Add VIMAGE to __DEFAULT_DEPENDENT_OPTIONS (to define VIMAGE_SUPPORT)
> >
> >    Only output VIMAGE to opt_global.h when VIMAGE support is wanted.
> >
> >    Obtained from:  Juniper Networks, Inc.
> >    Differential Revision:  https://reviews.freebsd.org/D39636
> > ---
> > share/mk/src.opts.mk  | 2 ++
> > sys/conf/config.mk    | 2 ++
> > sys/conf/kern.opts.mk | 4 +++-
> > 3 files changed, 7 insertions(+), 1 deletion(-)
>
> I now see:
>
> cat: /usr/obj/usr/src/src.git/amd64.amd64/sys/FOO/opt_vimage.h: No such
> file or directory
>
> during builds.  I made sure I cleaned the sys/FOO obj tree.  Any ideas?
>

I see this too... :(

The problem is that VIMAGE is in opt_global.h, not in opt_vimage, so it was
improper to add it here:
for var in \
    INET \
    INET6 \
    VIMAGE
.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
MK_${var}_SUPPORT:= no
.else
.if defined(KERNBUILDDIR)       # See if there's an opt_foo.h


.if !defined(OPT_${var})
OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo <-----------------
opt_vimage.h isn't a thing, it lives in opt_global.h
.export OPT_${var}
.endif
.if ${OPT_${var}} == ""         # nothing -> no



MK_${var}_SUPPORT:= no
.else
MK_${var}_SUPPORT:= yes
.endif
.else                           # otherwise, yes



MK_${var}_SUPPORT:= yes
.endif
.endif
.endfor

So prior to this addition, this was abusing our build system somewhat, but
it worked. Now, it doesn't work and can only work with more abuse:

diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index 8b1151f3d624..99e4433ec3cf 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -188,9 +188,13 @@ OPT_${opt}:=       ${rep}
 .if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
 MK_${var}_SUPPORT:= no
 .else
-.if defined(KERNBUILDDIR)  # See if there's an opt_foo.h
+.if defined(KERNBUILDDIR)    # See if there's an opt_foo.h or opt_global.h
 .if !defined(OPT_${var})
+.if exists(${KERNBUILDDIR}/opt_${var:tl}.h)
 OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
+.else
+OPT_${var}!= cat ${KERNBUILDDIR}/opt_global.h; echo
+.endif
 .export OPT_${var}
 .endif
 .if ${OPT_${var}} == ""                # nothing -> no

which I think gets us past the present problem...

But I think that config(8) should be generating a canonical list of options
so we don't have to do this crazy gymnastics of kludgitude.

Warner

Warner