Re: FYI: Why META_MODE rebuilds so much for building again after installworld (no source changes)

From: Simon J. Gerraty <sjg_at_juniper.net>
Date: Fri, 24 Feb 2023 07:33:54 UTC
Mark Millard <marklmi@yahoo.com> wrote:
> > Perhaps you want to be using
> >
> > .MAKE.META.IGNORE_PATHS+= ${MAKEOBJDIRPREFIX}/tmp/legacy/usr
> > or is that ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}/tmp/legacy/usr
> >
> 
> I had started with trying to use MAKEOBJDIRPREFIX but it
> appeared to end up with an empty expansion in something
> I'd looked at, making the addition to
> .MAKE.META.IGNORE_PATHS ineffective.
> 
> But with the .info lines in place, I should probably
> recheck an example with ${MAKEOBJDIRPREFIX} in it.
> (Expecting .MAKE.META.IGNORE_PATHS to not work but
> showing what happens for the MAKEOBJDIRPREFIX use.)
> This turns out to be different for "modules" vs.
> "pure kernel". I start with a "modules" example
> below.

Yes, if the value of MAKEOBJDIRPREFIX isn't consistent that's going to
cause problems (I'd call it a bug). If so don't use MAKEOBJDIRPREFIX
directly, set some other variable and export that.
Hmm src.sys.obj.mk plays games with MAKEOBJDIRPREFIX so that's
probably not a good option.
Perhaps:

diff --git a/share/mk/src.sys.obj.mk b/share/mk/src.sys.obj.mk
index 3b48fc3c5514..3c7e570dbdbd 100644
--- a/share/mk/src.sys.obj.mk
+++ b/share/mk/src.sys.obj.mk
@@ -67,6 +67,9 @@ SB_OBJROOT?=	${SB}/obj/
 OBJROOT?=	${SB_OBJROOT}
 .endif
 OBJROOT?=	${_default_makeobjdirprefix}${SRCTOP}/
+# save the value before we mess with it
+_OBJROOT:= ${OBJROOT:tA}
+.export _OBJROOT
 .if ${OBJROOT:M*/} != ""
 OBJROOT:=	${OBJROOT:H:tA}/
 .else

and then something like?

.MAKE.META.IGNORE_PATHS +=
${_OBJROOT}/${MACHINE}.${MACHINE_ARCH}/tmp/legacy/usr

> and still not right (MAKEOBJDIRPREFIX expanded
> to empty).

See above

> I still do not know notation to make .MAKE.META.IGNORE_PATHS
> effective for the specific list of tmp/legacy/usr/sbin/*
> examples in question.
> 
> Effectively, it appears that the coverage of
> .MAKE.META.IGNORE_PATHS is just incomplete (via the
> notational constraints it is used within).

No, your problem has nothing to do with .MAKE.META.IGNORE_PATHS
but with the build's lack of a consistent definition of OBJTOP or
OBJROOT or whatever you want to call it.

You could I guess take note of .OBJDIR when setting
.MAKE.META.IGNORE_PATHS and if it match */sys/compile* and tweak
things accordingly so you actually get the value you want.

The messing about with MAKEOBJDIRPREFIX has been around so long I don't
know how you could go about fixing it at this point.

FWIW in our build we make a clear distinction between things build for
the "host" (all the tools you care about are actually host tools not
target tools I think), and those built for a target.
Everything built for host is found under ${HOST_OBJTOP}
and everything for the targets is under ${OBJTOP} which we define
consistently

mk -V OBJTOP -V HOST_OBJTOP:tA
/var/obj/FreeBSD/main/obj/amd64.amd64
/var/obj/FreeBSD/main/obj/freebsd13-amd64

(the :tA is needed there so you can see the relationship - HOST_OBJTOP
comes from environment)

mk -n buildworld -V OBJTOP
Setting legacy build env...
/var/obj/FreeBSD/main/obj/h/sjg/work/FreeBSD/main/src/amd64.amd64

and as you know, that value does not remain consistent thoughout the
tree which makes it of questionable value.

--sjg