Package: bmake
Version: 20200710-17
X-Debbugs-Cc: [email protected]

This *might* be related to #1078772, but is not the same; for one,
that bugreport was under qemu-user while this one is on bare metal.

Reproducer: an otherwise empty directory with two files:

$ cat BSDmakefile 
PROG=   facopy
SRCS=   poc.c
NOMAN=  Yes
 
.include <bsd.prog.mk>
$ cat poc.c 
#include <stdio.h>
 
int
main(int argc, char *argv[])
{
        printf("Hello, World!\n");
        return (0);
}

All the usual targets… just do nothing?! Except install, which
does something entirely unexpected:

$ pmake obj
$ pmake depend
$ pmake
$ pmake install
install   -c   -o root  -g root  -m 444  bsd.README /usr/share/mk/bsd.README
install: cannot stat 'bsd.README': No such file or directory
*** Error code 1
 
Stop.
bmake: stopped in «cwd»
$ fgrep -r bsd.README /usr/share/mk
/usr/share/mk/README:#  $NetBSD: bsd.README,v 1.18 1997/01/13 00:54:23 mark Exp 
$
/usr/share/mk/README:#  @(#)bsd.README  5.1 (Berkeley) 5/11/90
$ fgrep -r bsd.README /usr/share/bmake/mk-netbsd/
/usr/share/bmake/mk-netbsd/Makefile:FILES=      bsd.README bsd.doc.mk 
bsd.dep.mk bsd.files.mk bsd.inc.mk bsd.info.mk \
/usr/share/bmake/mk-netbsd/bsd.README:# $NetBSD: bsd.README,v 1.2 2009/12/30 
20:46:22 abs Exp $
/usr/share/bmake/mk-netbsd/bsd.README:# @(#)bsd.README  8.2 (Berkeley) 4/2/94


It looks as if it included /usr/share/bmake/mk-netbsd/Makefile
for some reason?

(“ls -la” confirms that obj/depend/all have not done anything.)

Now it’s not the wrapper:

$ bmake -m /usr/share/bmake/mk-netbsd obj

… also does nothing.

An strace however indicates that my hunch with it (mistakenly)
including a file it is not supposed to might be true and perhaps
at least part of the bug:

$ strace -e file bmake -m /usr/share/bmake/mk-netbsd obj
execve("/usr/bin/bmake", ["bmake", "-m", "/usr/share/bmake/mk-netbsd", "obj"], 
0x7fff69fd6188 /* 50 vars */) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
getcwd("«cwd»", 4096) = 28
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd", 
O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "«cwd»", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
chdir("«cwd»")    = 0
openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»/obj.x86_64-amd64", 0x7ffc73763830, 0) = -1 ENOENT 
(No such file or directory)
newfstatat(AT_FDCWD, "«cwd»/obj.x86_64", 0x7ffc73763830, 0) = -1 ENOENT (No 
such file or directory)
newfstatat(AT_FDCWD, "«cwd»/obj", 0x7ffc73763830, 0) = -1 ENOENT (No such file 
or directory)
newfstatat(AT_FDCWD, "/usr/obj«cwd»", 0x7ffc73763830, 0) = -1 ENOENT (No such 
file or directory)
openat(AT_FDCWD, "/usr/share/mk", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/sys.mk", O_RDONLY) = 3
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27034, si_uid=1000, 
si_status=0, si_utime=0, si_stime=0} ---
openat(AT_FDCWD, "makefile", O_RDONLY)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "Makefile", O_RDONLY)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/Makefile", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
newfstatat(AT_FDCWD, "/etc/mk.conf", 0x7ffc73765680, 0) = -1 ENOENT (No such 
file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.prog.mk", O_RDONLY) = 3
newfstatat(AT_FDCWD, "«cwd»/../Makefile.inc", 0x7ffc73765680, 0) = -1 ENOENT 
(No such file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.obj.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.depall.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.man.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.nls.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.files.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.inc.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.links.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.dep.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.sys.mk", O_RDONLY) = 3
openat(AT_FDCWD, ".depend", O_RDONLY)   = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc737658a0, 0) = -1 ENOENT (No such file or 
directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc73765880, 0) = -1 ENOENT (No such file or 
directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc73765890, 0) = -1 ENOENT (No such file or 
directory)
+++ exited with 0 +++

A bit of analysis of that:

Stuff until here looks normal:

>openat(AT_FDCWD, "/usr/share/mk", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 
>3

Looking at an unfiltered strace, the only thing it does between that and
the next line is:

openat(AT_FDCWD, "/usr/share/mk", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(3, 0x55a0cc05c190 /* 77 entries */, 32768) = 2552
getdents64(3, 0x55a0cc05c190 /* 0 entries */, 32768) = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/sys.mk", O_RDONLY) = 3

So, it lists the directory, but that should do no harm.

The SIGCHLD is from <sys.mk> calling uname(1) to report “Linux”.

Then, for some reason, after trying "makefile" and "Makefile",
instead of continuing to "BSDmakefile" it tries
"/usr/share/bmake/mk-netbsd/Makefile" first, finds it and uses it.
This then causes havoc.

Looking at actual BSD systems shows that /usr/src/share/mk/Makefile
is not installed into /usr/share/mk, so src:bmake should follow.

$ sudo rm /usr/share/bmake/mk-netbsd/Makefile 
$ pmake obj
bmake: don't know how to make obj. Stop
 
bmake: stopped in «cwd»

… huh. But at least a better error.

…

…

…

$ mv BSDmakefile Makefile
$ pmake obj
making «cwd»/obj

…

… ah, so it does not use BSDmakefile at all, and the presence
of /usr/share/bmake/mk-netbsd/Makefile merely hid that.

I’m wondering whether you can pstch BSDmakefile support in,
that’ll be your choice as maintainer, also coordinating with
upstream, I suppose. (Is the omission a Linux thing?)

But IMHO /usr/share/bmake/mk-netbsd/Makefile has to go (and
/usr/share/bmake/mk-bmake does not have a Makefile in it).

*edits Subject*



-- System Information:
Debian Release: 13.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.90+deb13.1-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages bmake depends on:
ii  libc6  2.41-12+deb13u3

bmake recommends no packages.

bmake suggests no packages.

-- no debconf information

Reply via email to