Page MenuHomeFreeBSD

tools/build/make.py: Make --with-default-sys-path mirror usr.bin/bmake
ClosedPublic

Authored by jrtc27 on Aug 22 2023, 2:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 2, 8:12 PM
Unknown Object (File)
Mon, Oct 21, 1:04 PM
Unknown Object (File)
Sep 27 2024, 8:07 AM
Unknown Object (File)
Sep 27 2024, 8:07 AM
Unknown Object (File)
Sep 27 2024, 8:07 AM
Unknown Object (File)
Sep 24 2024, 9:07 AM
Unknown Object (File)
Sep 24 2024, 8:42 AM
Unknown Object (File)
Sep 22 2024, 7:42 PM
Subscribers
None

Details

Summary

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.
  1. "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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jrtc27 created this revision.

The premise of this change sounds wrong. /usr/bin/make is built with a default syspath of .../share/mk:/usr/share/mk so you should get share/mk/sys.mk et al
from the src tree:

`/usr/bin/make -V '${.MAKE.MAKEFILES:M*sys.mk}'
/homes/sjg/work/FreeBSD/main/src/share/mk/sys.mk /homes/sjg/work/FreeBSD/main/src/share/mk/local.sys.mk /homes/sjg/work/FreeBSD/main/src/share/mk/src.sys.mk`

Are you seeing this with a bmake built with some other default?

jrtc27 retitled this revision from Makefile: Fix universe-like targets with bmake's mk files as on non-FreeBSD to tools/build/make.py: Make --with-default-sys-path mirror usr.bin/bmake.Aug 22 2023, 5:58 PM
jrtc27 edited the summary of this revision. (Show Details)

You could probably drop /usr/share/mk

and as for "MAKEOBJDIRPREFIX check in Makefile runs in the object directory and uses env -i", probably no reason it could not do
env -i MAKESYSPATH=${MAKESYSPATH} ?

This revision is now accepted and ready to land.Aug 22 2023, 8:32 PM