Re: 13.2 BETA2: how do debug META_MODE?

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 24 Feb 2023 20:22:58 UTC
Simon J. Gerraty figured out what to do to allow
avoiding . . ./tmp/legacy/usr/sbin/<PROGRAM> leading
to "is newer than" and, so, causing various things
to rebuild. It required an addition to the
infrastructure ( share/mk/src.sys.obj.mk ) so that
the proper paths could be systematically formed for
the purpose.

The below is based on using that and some content in
a just-for-buildworld-buildkernel make.conf file that
I use (via env __MAKE_CONF= use). (The make.conf is not
the one in /etc/ .)

After installworld installkernel then a separate
-dM buildworld buildkernel , looking at the log from
the buildworld buildkernel :

# cat /usr/obj/BUILDs/main-amd64-nodbg-clang/sys-typescripts/typescript-make-amd64-nodbg-clang-amd64-host-2023-02-24:11:13:18 | grep "is newer than the target" | sed -
e "s@^.*: file '@file '@" | sort | uniq -c | sort -rn | less
1467 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/Scrt1.o' is newer than the target...
 515 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/crti.o' is newer than the target...
 236 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/crti.o' is newer than the target...
  70 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libgcc_s.so' is newer than the target...
  69 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libgcc_s.so' is newer than the target...
  68 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/crt1.o' is newer than the target...
   3 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/include/aio.h' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libssl.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libcxxrt.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libctf.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libcrypto.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libc.so.7' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/Scrt1.o' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libssl.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libcxxrt.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libctf.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libcrypto.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/lib/libc.so.7' is newer than the target...

Then, after doing another -dM buildworld buildkernel , looking
at that new log:

# cat /usr/obj/BUILDs/main-amd64-nodbg-clang/sys-typescripts/typescript-make-amd64-nodbg-clang-amd64-host-2023-02-24:11:20:54 | grep "is newer than the target" | sed -
e "s@^.*: file '@file '@" | sort | uniq -c | sort -rn | less
1467 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/Scrt1.o' is newer than the target...
 515 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/crti.o' is newer than the target...
 236 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/crti.o' is newer than the target...
  73 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libgcc_s.so' is newer than the target...
  71 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libgcc_s.so' is newer than the target...
  68 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/crt1.o' is newer than the target...
   3 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/include/aio.h' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libssl.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libcxxrt.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libcrypto.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/libc.so.7' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib32/Scrt1.o' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libssl.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libcxxrt.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libctf.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/usr/lib/libcrypto.so' is newer than the target...
   1 file '/usr/obj/BUILDs/main-amd64-nodbg-clang/usr/main-src/amd64.amd64/tmp/lib/libc.so.7' is newer than the target...

So the two end up very similar for what activity happens.

I've only tried this on the amd64 context that I have access
to. I'll set up the aarch64 context as well and see how it
goes over time. (That context builds for aarch64 and for
armv7 .) Similarly, I've only tried main but will be adding
the changes to my releng/13.0 , releng/13.1 , and stable/13
contexts and seeing how it goes. (Not that I'm likely to
rebuild releng/13.0 at this point.)

For now, I've no plans for investigations related to any of
the *.o , *.h , *.so* "is newer than" activity listed above.

For reference:

# git -C /usr/main-src/ diff share/mk/src.sys.obj.mk
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

(The change is not specific to main .)

The content for the special make.conf has the
following block of lines for having META MODE
avoid specific . . ./tmp/legacy/usr/sbin/*
programs (and 3 tmp/usr/bin/* ones) from
causing rebuild activity based on the dates
on the programs:

# _OBJROOT is an addition to share/mk/src.sys.obj.mk
# provided by Simon J. Gerraty for my experimentation
# with this avoidance of some unnecessary build
# activity in META MODE:
#
#  OBJROOT?=      ${_default_makeobjdirprefix}${SRCTOP}/
# +# save the value before we mess with it
# +_OBJROOT:= ${OBJROOT:tA}
# +.export _OBJROOT
#
# TARGET.TARGET_ARCH   for amd64 stays as  amd64.amd64 for obj-lib32 (correct for the purpose)
# MACHINE.MACHINE_ARCH for amd64 turns into i386.i386  for obj-lib32 (wrong   for the purpose)
#
IGNORELEGACY_NOSYMLINKPREFIX= ${_OBJROOT}/${TARGET}.${TARGET_ARCH}/tmp/legacy/usr
IGNOREOTHER_NOSYMLINKPREFIX=  ${_OBJROOT}/${TARGET}.${TARGET_ARCH}/tmp/usr/bin
#
.for ignore_legacy_tool in awk basename cap_mkdb cat chmod cmp cp crunchgen crunchide cut date dd dirname echo egrep env expr fgrep file2c find gencat grep gzip head hostname jot lex lb ln ls m4 make mkcsmapper mkdir mktemp mtree mv nawk patch realpath rm sed sh sort touch tr truncate uudecode uuencode wc xargs
.MAKE.META.IGNORE_PATHS+= ${IGNORELEGACY_NOSYMLINKPREFIX}/sbin/${ignore_legacy_tool}
.endfor
#
.for ignore_other_tool in ctfconvert objcopy nm
.MAKE.META.IGNORE_PATHS+= ${IGNOREOTHER_NOSYMLINKPREFIX}/${ignore_other_tool}
.endfor
#
.MAKE.META.IGNORE_PATHS:= ${.MAKE.META.IGNORE_PATHS}


The . . ./tmp/usr/bin/* ones ( ctfconvert objcopy nm )
may be more questionable than the
. . ./tmp/legacy/usr/sbin/* ones.

This likely will not prevent the likes of a system with
clang14 -> system with clang15 transition having clang15
rebuild itself once the clang15 system is running and
another buildworld is started.

===
Mark Millard
marklmi at yahoo.com