git: 62f243acea24 - main - tools/build/make.py: Make --with-default-sys-path mirror usr.bin/bmake

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Wed, 23 Aug 2023 17:01:26 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=62f243acea24f52c6420720db615535045489c50

commit 62f243acea24f52c6420720db615535045489c50
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-08-23 16:56:56 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-08-23 16:56:56 +0000

    tools/build/make.py: Make --with-default-sys-path mirror usr.bin/bmake
    
    The top-level Makefile passes -m to its sub-makes in order to ensure
    they use the in-tree mk files in share/mk, but the top-level make itself
    has to rely on whatever environment the bmake used has. For FreeBSD, we
    configure the system bmake with .../share/mk:/usr/share/mk, which means
    it will pick up src's share/mk whenever run from within the src tree,
    but currently for non-FreeBSD we configure our bootstrap bmake only with
    bmake's own mk files. This is mostly compatible, with two exceptions:
    
    1. "targets" runs at the top level, but needs TARGET_MACHINE_LIST and
       the corresponding MACHINE_ARCH_LIST_${target}, otherwise it will just
       print an empty list.
    
    2. "universe" and "universe-toolchain", when run at the top level (i.e.
       not via the various wrappers around universe like tinderbox), end up
       failing in universe-toolchain itself with:
    
         bmake[1]: "/path/to/freebsd/share/mk/src.sys.obj.mk" line 112: Cannot use MAKEOBJDIR=
         Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${.CURDIR:S,^${SRCTOP},${OBJTOP},}'
    
    By including .../share/mk in the default sys path like FreeBSD's system
    bmake we ensure that we get the in-tree mk files for the top-level make,
    not just sub-makes, and avoid such issues.
    
    Note that we cannot (yet) stop using the installed mk files, since the
    MAKEOBJDIRPREFIX check in Makefile runs in the object directory and uses
    env -i, thereby losing the MAKESYSPATH exported by src.sys.env.mk. Other
    such issues may also exist, though are likely rare if so.
    
    Reviewed by:    sjg
    Differential Revision:  https://reviews.freebsd.org/D41544
---
 tools/build/make.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/build/make.py b/tools/build/make.py
index e25922c9a70d..5c483e8b45be 100755
--- a/tools/build/make.py
+++ b/tools/build/make.py
@@ -100,7 +100,8 @@ def bootstrap_bmake(source_root, objdir_prefix):
                   bmake_installed_version + "', treating as not present")
 
     configure_args = [
-        "--with-default-sys-path=" + str(bmake_install_dir / "share/mk"),
+        "--with-default-sys-path=.../share/mk:" +
+        str(bmake_install_dir / "share/mk"),
         "--with-machine=amd64",  # TODO? "--with-machine-arch=amd64",
         "--without-filemon", "--prefix=" + str(bmake_install_dir)]