[bug #57674] regression in make 4.3 with makefile from stdin

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #57674] regression in make 4.3 with makefile from stdin

anonymous
URL:
  <https://savannah.gnu.org/bugs/?57674>

                 Summary: regression in make 4.3 with makefile from stdin
                 Project: make
            Submitted by: ncopa
            Submitted on: Mon 27 Jan 2020 11:41:55 AM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.3
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

(I tried to send this to [hidden email] but is seems to have been redirected
to /dev/null by some spam filter or similar)

Hi,

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
all:
        @echo \$(CC)
$ make -sf Makefile
cc
$ 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 -`

https://cvsweb.bsd.lv/mandoc/configure?rev=1.71&content-type=text/x-cvsweb-markup


Downstream bug report:
https://gitlab.alpinelinux.org/alpine/aports/issues/11163

Thanks!

-nc





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57674>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #57674] regression in make 4.3 with makefile from stdin

anonymous
Follow-up Comment #1, bug #57674 (project make):

This may not be a bug in make. `env -i` will unset $PATH so I guess this is
expected behavior.

I guess this can be closed.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57674>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #57674] regression in make 4.3 with makefile from stdin

anonymous
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
> "/bin:/usr/bin")

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.

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57674>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #57674] GNU make doesn't use default path if PATH not set

anonymous
Update of bug #57674 (project make):

                 Summary: regression in make 4.3 with makefile from stdin =>
GNU make doesn't use default path if PATH not set


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57674>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

Re: [bug #57674] regression in make 4.3 with makefile from stdin

Bob Proulx
In reply to this post by anonymous
Natanael Copa wrote:
>   <https://savannah.gnu.org/bugs/?57674>
> (I tried to send this to [hidden email] but is seems to have been redirected
> to /dev/null by some spam filter or similar)

Your other messages came through okay.  So I don't know why you would
have been lost messages.

In the future if you suspect mailing list email problems you may send
a request to have us look to [hidden email] and the team there will
look for a problem.

Bob
"With my mailing list admin hat on"

Reply | Threaded
Open this post in threaded view
|

[bug #57674] GNU make doesn't use default path if PATH not set

anonymous
In reply to this post by anonymous
Update of bug #57674 (project make):

                  Status:                    None => Fixed                  
             Open/Closed:                    Open => Closed                
           Fixed Release:                    None => SCM                    

    _______________________________________________________

Follow-up Comment #3:

I pushed a fix for this.  Thanks for reporting!

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57674>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

Re: [bug #57674] regression in make 4.3 with makefile from stdin

Andreas Schwab
In reply to this post by anonymous
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.

Andreas.

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

Reply | Threaded
Open this post in threaded view
|

Re: [bug #57674] regression in make 4.3 with makefile from stdin

Paul Smith-20
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.