Bug 294436 - bmake: Linux cross-build fails, MAKEOBJDIR issue
Summary: bmake: Linux cross-build fails, MAKEOBJDIR issue
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 16.0-CURRENT
Hardware: powerpc Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-04-12 12:40 UTC by Lexi Winter
Modified: 2026-04-13 18:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lexi Winter freebsd_committer freebsd_triage 2026-04-12 12:40:02 UTC
building main 82ff1c334b97 on Alpine Linux v3.23, the build fails due to ${MAKEOBJDIR} apparently being set wrong:

% MAKEOBJDIRPREFIX=/obj/test tools/build/make.py --cross-bindir /usr/bin --cross-compiler-type clang -j24 TARGET=powerpc TARGET_ARCH=powerpc64le buildworld
bmake: /src/bsd/main/share/mk/src.sys.obj.mk:117: Cannot use MAKEOBJDIR=${.CURDIR:S,^${SRCTOP},${OBJTOP},}
Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${.CURDIR:S,^${SRCTOP},${OBJTOP},}'
        in /src/bsd/main/share/mk/src.sys.env.mk:95
        in /src/bsd/main/share/mk/local.sys.env.mk:63
        in /src/bsd/main/share/mk/sys.mk:46

bmake: stopped making "buildworld" in /src/bsd/main

this seems to be caused by the bmake-20260313 import; reverting to src c5961b6fcfe0 (the last commit prior to the import) fixes the problem.
Comment 1 Simon J. Gerraty freebsd_committer freebsd_triage 2026-04-12 22:35:29 UTC
bmake itself builds on Linux (and just about anything else) just fine.
That you got as far as `buildworld` suggests it built ok via make.py too.

There should be no functional change in this version of bmake, it is just more efficient about when to set OP_SUBMAKE, which doesn't matter much on FreeBSD since the job pool descriptors are passed to all children anyway.

src.sys.obj.mk is fatally flawed, at least in conjunction with the current top-level build - it both needs to export OBJTOP, but at the same time cannot without breaking.  We've tried "fixing" it both ways - neither works.

This is the cause of all the warnings about /lib permission denied etc.

You might find it useful to put the following in share/mk/site.sys.env.mk
though in your case it may get included too late (you could reverse the order of includes in local.sys.env.mk if so

```
# site.sys.env.mk
MAKE_PRINT_VAR_ON_ERROR += \
        .CURDIR \
        .OBJDIR \
        SRCTOP \
        OBJTOP \
        MAKEOBJDIR \

```
Comment 2 Lexi Winter freebsd_committer freebsd_triage 2026-04-12 23:21:33 UTC
> There should be no functional change in this version of bmake.

well, something changed. :-)  c5961b6fcfe0 works, and 34a3834eadd doesn't, and the only change between those two commits is the bmake import.  (the older commit does eventually hit a different error, but it's not bmake-related.)

> You might find it useful to put the following in share/mk/site.sys.env.mk

% MAKEOBJDIRPREFIX=/obj/test tools/build/make.py --cross-bindir /usr/bin --cross-compiler-type clang -j36 TARGET=powerpc TARGET_ARCH=powerpc64le buildworld
bmake: /src/bsd/main/share/mk/src.sys.obj.mk:117: Cannot use MAKEOBJDIR=${.CURDIR:S,^${SRCTOP},${OBJTOP},}
Unset MAKEOBJDIR to get default:  MAKEOBJDIR='${.CURDIR:S,^${SRCTOP},${OBJTOP},}'
        in /src/bsd/main/share/mk/src.sys.env.mk:95
        in /src/bsd/main/share/mk/local.sys.env.mk:64
        in /src/bsd/main/share/mk/sys.mk:46

bmake: stopped making "buildworld" in /src/bsd/main
.CURDIR='/src/bsd/main'
.OBJDIR='/src/bsd/main'
SRCTOP='/src/bsd/main'
OBJTOP='/obj/test/src/bsd/main/powerpc.powerpc64le'
MAKEOBJDIR='${.CURDIR:S,^${SRCTOP},${OBJTOP},}'
%
Comment 3 Lexi Winter freebsd_committer freebsd_triage 2026-04-12 23:44:21 UTC
this seems to be related to .MAKE.SAVE_DOLLARS.  this patch works around the problem:

diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index ace5c729be51..15b028a65241 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1315,7 +1315,7 @@ ReadFirstDefaultMakefile(void)
 }

 #ifndef MAKE_SAVE_DOLLARS_DEFAULT
-# define MAKE_SAVE_DOLLARS_DEFAULT "yes"
+# define MAKE_SAVE_DOLLARS_DEFAULT "no"
 #endif
Comment 4 Simon J. Gerraty freebsd_committer freebsd_triage 2026-04-13 17:32:40 UTC
(In reply to Lexi Winter from comment #3)

You are right of course.  The default in main.c is what NetBSD uses,
I override that in bmake's Makefile but forgot to make similar arrangement for when using boot-strap.  For now, changing the ifdef in main.c makes sense.
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-04-13 17:39:51 UTC
A commit in branch main references this bug:

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

commit e272f4a61e78037ec8477ba9e9afcbe3ae2cd8e3
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2026-04-13 17:38:50 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2026-04-13 17:38:50 +0000

    Fix default for .MAKE.SAVE_DOLLARS

    NetBSD make defaults this to "yes",
    bmake defauts it to "no" to retain the traditional behavior.

    The default is dealt with in bmake's Makefile but that does not
    address boot-strap.

    For now, just change the ifdef in main.

    PR: 294436

 contrib/bmake/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 Simon J. Gerraty freebsd_committer freebsd_triage 2026-04-13 18:14:32 UTC
In next bmake version the default for .MAKE.SAVE_DOLLARS is configurable, and defaults to "no".