Summary: regression in make 4.3 with makefile from stdin
Submitted by: ncopa
Submitted on: Mon 27 Jan 2020 11:41:55 AM UTC
Severity: 3 - Normal
Item Group: Bug
Assigned to: None
Discussion Lock: Any
Component Version: 4.3
Operating System: POSIX-Based
Fixed Release: None
Triage Status: None
(I tried to send this to [hidden email] but is seems to have been redirected
to /dev/null by some spam filter or similar)
I believe there is a regression in make 4.3. To reproduce:
$ make -v
GNU Make 4.3
Built for x86_64-alpine-linux-musl
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ cat Makefile
$ make -sf Makefile
$ cat Makefile | env -i make -sf -
make: echo: No such file or directory
make: *** [/tmp/GmOCOMgl:2: all] Error 127
Problem was found in the configure script of mandoc (mdocml).
CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -`
[bug #57674] regression in make 4.3 with makefile from stdin
Follow-up Comment #2, bug #57674 (project make):
I know why this happens.
In GNU make prior to 4.3 we used the execvp() system call to invoke commands.
This call behaves like this (from the man page):
> The file is sought in the colon-separated list of directory pathnames
> specified in the PATH environment variable. If this variable isn't
> defined, the path list defaults to a list that includes the directories
> returned by confstr(_CS_PATH) (which typically returns the value
In GNU make 4.3, for performance reasons we choose to use posix_spawn() if
it's available on the system. posix_spawn() doesn't do any path search, so we
do it ourselves and we don't have this backup default PATH lookup that
While it could be argued either way, I think this is probably something we
should fix in GNU make so I'm going to leave this open.
> In GNU make 4.3, for performance reasons we choose to use posix_spawn() if
> it's available on the system. posix_spawn() doesn't do any path search, so we
> do it ourselves and we don't have this backup default PATH lookup that
> execvp() does.
There is also posix_spawnp.
Andreas Schwab, SUSE Labs, [hidden email] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Re: [bug #57674] regression in make 4.3 with makefile from stdin
On Wed, 2020-04-01 at 14:14 +0200, Andreas Schwab wrote:
> On Mär 31 2020, Paul D. Smith wrote:
> > In GNU make 4.3, for performance reasons we choose to use
> > posix_spawn() if it's available on the system. posix_spawn()
> > doesn't do any path search, so we do it ourselves and we don't have
> > this backup default PATH lookup that execvp() does.
> There is also posix_spawnp.
Unfortunately it's hard to use for us.
The fork/exec code worked by first forking, then installing the child's
environment, then running execvp. This ensured that the PATH lookup
happened with the child's environment.
posix_spawnp obviously does not do the fork, which means that it will
do the path lookup with the parent's environment, which is wrong (for
us at least).
The only option would be to setenv the child's PATH before invoking
posix_spawnp() then set it back again afterward.