public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [v3] kbuild: Port silent mode detection to future gnu make.
@ 2022-12-05 21:48 Dmitry Goncharov
  2022-12-06  1:49 ` Masahiro Yamada
  2022-12-07 19:56 ` Nicolas Schier
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Goncharov @ 2022-12-05 21:48 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild; +Cc: dgoncharov

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.


Signed-off-by: Dmitry Goncharov <dgoncharov@users.sf.net>
Reported-by: Jan Palus <jpalus+gnu@fastmail.com>
Link: https://lists.gnu.org/archive/html/bug-make/2022-11/msg00190.html

diff --git a/Makefile b/Makefile
index 6f846b1f2618..fbd9ff4a61e7 100644
--- a/Makefile
+++ b/Makefile
@@ -93,10 +93,17 @@ 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_
-  KBUILD_VERBOSE = 0
+ifeq ($(filter 3.%,$(MAKE_VERSION)),)
+silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
+else
+silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
+endif
+
+ifeq ($(silence),s)
+quiet=silent_
+KBUILD_VERBOSE = 0
 endif

 export quiet Q KBUILD_VERBOSE


regards, Dmitry

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

* Re: [v3] kbuild: Port silent mode detection to future gnu make.
  2022-12-05 21:48 [v3] kbuild: Port silent mode detection to future gnu make Dmitry Goncharov
@ 2022-12-06  1:49 ` Masahiro Yamada
  2022-12-07 19:56 ` Nicolas Schier
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2022-12-06  1:49 UTC (permalink / raw)
  To: Dmitry Goncharov; +Cc: linux-kbuild

On Tue, Dec 6, 2022 at 6:48 AM Dmitry Goncharov <dgoncharov@users.sf.net> 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
> 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.
>
>
> Signed-off-by: Dmitry Goncharov <dgoncharov@users.sf.net>
> Reported-by: Jan Palus <jpalus+gnu@fastmail.com>
> Link: https://lists.gnu.org/archive/html/bug-make/2022-11/msg00190.html
>



Applied to linux-kbuild. Thanks.



> diff --git a/Makefile b/Makefile
> index 6f846b1f2618..fbd9ff4a61e7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -93,10 +93,17 @@ 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_
> -  KBUILD_VERBOSE = 0
> +ifeq ($(filter 3.%,$(MAKE_VERSION)),)
> +silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
> +else
> +silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
> +endif
> +
> +ifeq ($(silence),s)
> +quiet=silent_
> +KBUILD_VERBOSE = 0
>  endif
>
>  export quiet Q KBUILD_VERBOSE
>
>
> regards, Dmitry



-- 
Best Regards
Masahiro Yamada

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

* Re: [v3] kbuild: Port silent mode detection to future gnu make.
  2022-12-05 21:48 [v3] kbuild: Port silent mode detection to future gnu make Dmitry Goncharov
  2022-12-06  1:49 ` Masahiro Yamada
@ 2022-12-07 19:56 ` Nicolas Schier
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Schier @ 2022-12-07 19:56 UTC (permalink / raw)
  To: Dmitry Goncharov; +Cc: Masahiro Yamada, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 2774 bytes --]

On Mon, Dec 05, 2022 at 04:48:19PM -0500 Dmitry Goncharov 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
> 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.
> 
> 
> Signed-off-by: Dmitry Goncharov <dgoncharov@users.sf.net>
> Reported-by: Jan Palus <jpalus+gnu@fastmail.com>
> Link: https://lists.gnu.org/archive/html/bug-make/2022-11/msg00190.html
> 
> diff --git a/Makefile b/Makefile
> index 6f846b1f2618..fbd9ff4a61e7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -93,10 +93,17 @@ 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_
> -  KBUILD_VERBOSE = 0
> +ifeq ($(filter 3.%,$(MAKE_VERSION)),)
> +silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
> +else
> +silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
> +endif
> +
> +ifeq ($(silence),s)
> +quiet=silent_
> +KBUILD_VERBOSE = 0

Thanks for that patch.  Following its development was quite interesting!

Are there some (possibly unwritten) style recommendations for Linux
Makefiles/Kbuilds, e.g. regarding spaces around assignment operators and after
commas?

Personally, I would have liked to see those spaces here as I think it would be
better for style consistency.

Kind regards,
Nicolas


-- 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-12-07 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-05 21:48 [v3] kbuild: Port silent mode detection to future gnu make Dmitry Goncharov
2022-12-06  1:49 ` Masahiro Yamada
2022-12-07 19:56 ` Nicolas Schier

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