mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] kbuild: Port silent mode detection to future gnu make.
@ 2023-06-12 12:58 Ahmad Fatoum
  2023-06-13  7:59 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:58 UTC (permalink / raw)
  To: barebox; +Cc: Jan Palus, Ahmad Fatoum

Port silent mode detection to the future (post make-4.4) versions of gnu make.

Makefile contains the following piece of make code to detect if option -s is
specified on the command line.

ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)

This code is executed by make at parse time and assumes that MAKEFLAGS
does not contain command line variable definitions.
Currently if the user defines a=s on the command line, then at build only
time MAKEFLAGS contains " -- a=s".
However, starting with commit dc2d963989b96161472b2cd38cef5d1f4851ea34
MAKEFLAGS contains command line definitions at both parse time and
build time.

This '-s' detection code then confuses a command line variable
definition which contains letter 's' with option -s.

$ # old make
$ make net/wireless/ocb.o a=s
CALL    scripts/checksyscalls.sh
DESCEND objtool
$ # this a new make which defines makeflags at parse time
$ ~/src/gmake/make/l64/make net/wireless/ocb.o a=s
$

We can see here that the letter 's' from 'a=s' was confused with -s.

This patch checks for presence of -s using a method recommended by the
make manual here
https://www.gnu.org/software/make/manual/make.html#Testing-Flags.

Link: https://lists.gnu.org/archive/html/bug-make/2022-11/msg00190.html
Reported-by: Jan Palus <jpalus+gnu@fastmail.com>
Signed-off-by: Dmitry Goncharov <dgoncharov@users.sf.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
[ported from Linux commit 4bf73588165ba7d32131a043775557a54b6e1db5]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 Makefile | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index af5c1448b378..1262612675b3 100644
--- a/Makefile
+++ b/Makefile
@@ -90,9 +90,16 @@ endif
 
 # If the user is running make -s (silent mode), suppress echoing of
 # commands
+# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
 
-ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
-  quiet=silent_
+ifeq ($(filter 3.%,$(MAKE_VERSION)),)
+silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
+else
+silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
+endif
+
+ifeq ($(silence),s)
+quiet=silent_
 endif
 
 export quiet Q KBUILD_VERBOSE
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] kbuild: Port silent mode detection to future gnu make.
  2023-06-12 12:58 [PATCH master] kbuild: Port silent mode detection to future gnu make Ahmad Fatoum
@ 2023-06-13  7:59 ` Sascha Hauer
  2023-06-13  8:02   ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2023-06-13  7:59 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Jan Palus

On Mon, Jun 12, 2023 at 02:58:24PM +0200, Ahmad Fatoum wrote:
> Port silent mode detection to the future (post make-4.4) versions of gnu make.
> 
> Makefile contains the following piece of make code to detect if option -s is
> specified on the command line.
> 
> ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
> 
> This code is executed by make at parse time and assumes that MAKEFLAGS
> does not contain command line variable definitions.
> Currently if the user defines a=s on the command line, then at build only
> time MAKEFLAGS contains " -- a=s".
> However, starting with commit dc2d963989b96161472b2cd38cef5d1f4851ea34

To which repository does dc2d963989b96161472b2cd38cef5d1f4851ea34
belong?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] kbuild: Port silent mode detection to future gnu make.
  2023-06-13  7:59 ` Sascha Hauer
@ 2023-06-13  8:02   ` Ahmad Fatoum
  2023-06-13  8:35     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2023-06-13  8:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Jan Palus

On 13.06.23 09:59, Sascha Hauer wrote:
> On Mon, Jun 12, 2023 at 02:58:24PM +0200, Ahmad Fatoum wrote:
>> Port silent mode detection to the future (post make-4.4) versions of gnu make.
>>
>> Makefile contains the following piece of make code to detect if option -s is
>> specified on the command line.
>>
>> ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
>>
>> This code is executed by make at parse time and assumes that MAKEFLAGS
>> does not contain command line variable definitions.
>> Currently if the user defines a=s on the command line, then at build only
>> time MAKEFLAGS contains " -- a=s".
>> However, starting with commit dc2d963989b96161472b2cd38cef5d1f4851ea34
> 
> To which repository does dc2d963989b96161472b2cd38cef5d1f4851ea34
> belong?

https://git.savannah.gnu.org/cgit/make.git/commit/?id=dc2d963989b96161472b2cd38cef5d1f4851ea34


> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] kbuild: Port silent mode detection to future gnu make.
  2023-06-13  8:02   ` Ahmad Fatoum
@ 2023-06-13  8:35     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2023-06-13  8:35 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Jan Palus

On Tue, Jun 13, 2023 at 10:02:03AM +0200, Ahmad Fatoum wrote:
> On 13.06.23 09:59, Sascha Hauer wrote:
> > On Mon, Jun 12, 2023 at 02:58:24PM +0200, Ahmad Fatoum wrote:
> >> Port silent mode detection to the future (post make-4.4) versions of gnu make.
> >>
> >> Makefile contains the following piece of make code to detect if option -s is
> >> specified on the command line.
> >>
> >> ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
> >>
> >> This code is executed by make at parse time and assumes that MAKEFLAGS
> >> does not contain command line variable definitions.
> >> Currently if the user defines a=s on the command line, then at build only
> >> time MAKEFLAGS contains " -- a=s".
> >> However, starting with commit dc2d963989b96161472b2cd38cef5d1f4851ea34
> > 
> > To which repository does dc2d963989b96161472b2cd38cef5d1f4851ea34
> > belong?
> 
> https://git.savannah.gnu.org/cgit/make.git/commit/?id=dc2d963989b96161472b2cd38cef5d1f4851ea34

Ok. Reworded "commit dc2d963989b96161472b2cd38cef5d1f4851ea34" to:

GNU Make commit dc2d963989b9 ("Always add command line variable
assignments to MAKEFLAGS")

and applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-13  8:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 12:58 [PATCH master] kbuild: Port silent mode detection to future gnu make Ahmad Fatoum
2023-06-13  7:59 ` Sascha Hauer
2023-06-13  8:02   ` Ahmad Fatoum
2023-06-13  8:35     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox