Test case: % ls -ld foo drwxr-xr-x 2 jkim staff 512 May 20 19:43 foo % cat bin/foo #!/bin/sh echo This is ~/bin/foo. echo \$PATH is \'$PATH\'. % cat Makefile all: foo Expected behavior (before GNU make 4.3): % env PATH=.:$PATH gmake foo This is /home/jkim/bin/foo. $PATH is '.:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/jkim/bin'. Current behavior (after GNU make 4.3): % env PATH=.:$PATH gmake foo gmake: foo: Permission denied gmake: *** [Makefile:2: all] Error 127 Note GNU make 4.3 uses posix_spawn(3) instead of fork()/exec(). http://git.savannah.gnu.org/cgit/make.git/commit/?id=749a54d7a458dc6779936138caf40ce600a80052 Now they implemented a built-in PATH search. http://git.savannah.gnu.org/cgit/make.git/commit/?id=60905a8afb012aa38ac6d56cee24754cc678947c This new find_in_given_path() function seems to be the culprit. A workaround is using "--diasable-posix-spawn" configure option.
(In reply to Jung-uk Kim from comment #0) I meant "--disable-posix-spawn". Sorry for the typo.
Created attachment 214701 [details] Work around PATH search bug
Interestingly, gnulib has added this check to findprog.c recently but not to findprog_in.c. http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4c1009ec93e12ee34acd27f6d7e25442bedc16f2
I found the upstream PR: https://savannah.gnu.org/bugs/index.php?57962
Created attachment 214702 [details] Add an upstream patch This upstream patch works, too.
A commit references this bug: Author: tijl Date: Thu May 21 09:50:37 UTC 2020 New revision: 536096 URL: https://svnweb.freebsd.org/changeset/ports/536096 Log: Add backport of gnulib git commit 4c1009ec93e12ee34acd27f6d7e25442bedc16f2. When the file found in a PATH element is a directory, continue searching. PR: 246615 Submitted by: jkim Obtained from: https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=4c1009ec93e12ee34acd27f6d7e25442bedc16f2 Changes: head/devel/gmake/Makefile head/devel/gmake/files/patch-10-4c1009ec
(In reply to commit-hook from comment #6) Note it is not exactly "backport". The attached patch was initial submission and the committer modified the logic to "reject directories" rather than "only accept regular files". IMHO, it is wrong, though. Also. the initial patch was just for findprog_in.c and the commit just fixed findprog.c and progreloc.c.
(In reply to Jung-uk Kim from comment #7) Thanks, I've notified upstream about findprog vs findprog-in. The patch I committed has !S_ISDIR like the gnulib commit.
(In reply to Tijl Coosemans from comment #8) Fixed in https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=6e6abd0cdfe4bb96f6412aebc511f10bf254a820.
(In reply to Tijl Coosemans from comment #9) Cool! Can you please import this version?
(In reply to commit-hook from comment #6) Actually, it didn't work for me and I found this patch is slightly broken. # patch < ../../files/patch-10-4c1009ec Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Backport of gnulib git commit 4c1009ec93e12ee34acd27f6d7e25442bedc16f2. | |When the file found in a PATH element is a directory, continue searching. | |--- lib/findprog-in.c.orig 2020-01-19 20:34:01 UTC |+++ lib/findprog-in.c -------------------------- Patching file lib/findprog-in.c using Plan A... Hunk #1 succeeded at 26. Hunk #2 succeeded at 191. Hmm... Ignoring the trailing garbage. done That's because '@' is missing, i.e., --- patch-10-4c1009ec.orig +++ patch-10-4c1009ec @@ -20,7 +20,7 @@ for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++) { const char *suffix = suffixes[i]; -@ -208,7 +210,8 @@ find_in_given_path (const char *progname, const char * +@@ -208,7 +210,8 @@ find_in_given_path (const char *progname, const char * use it. On other systems, let's hope that this program is not installed setuid or setgid, so that it is ok to call access() despite its design flaw. */
A commit references this bug: Author: tijl Date: Wed Jun 10 10:54:25 UTC 2020 New revision: 538386 URL: https://svnweb.freebsd.org/changeset/ports/538386 Log: Fix broken patch (missing @) by using the upstream version now that it's available. PR: 246615 Reported by: jkim Obtained from: https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=6e6abd0cdfe4bb96f6412aebc511f10bf254a820 Changes: head/devel/gmake/Makefile head/devel/gmake/files/patch-10-4c1009ec head/devel/gmake/files/patch-10-6e6abd0c
Apologies for the breakage. No idea how that happened. Must have been manually editing your patch.