* [PATCH] kbuild: honor '-s' option for tools/*
@ 2016-10-10 12:36 Arnd Bergmann
2016-10-10 13:31 ` Joe Perches
2016-10-10 19:49 ` Josh Poimboeuf
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-10-10 12:36 UTC (permalink / raw)
To: Michal Marek
Cc: Josh Poimboeuf, Arnd Bergmann, Arnaldo Carvalho de Melo,
Masahiro Yamada, Jiri Olsa, linux-kbuild, linux-kernel
When building with 'make -s' on x86, we always see the output for descending into
the tools/objtool directory when CONFIG_STACK_VALIDATION is set, but we should not
see any output. There are three related problems causing this:
* we override the MAKEFLAGS variable when entering tools, keeping only
the -j and --j% options around when we should also propagate the -s
flag (for some make versions) as well as the 's' character in the first
word of the variable.
* The build system in tools/build/Makefile.build that is used for some
parts of the build process of objtool implements the same
logic as the normal kbuild, using 'quiet_$(cmd)' to indicate the
string that should be printed, but lacks the logic to skip that
when building with 'make -s'.
* The /other/ build system in tools/scripts/Makefile.include that is also
used for building objtool checks for the 's' flag in the beginning of
the first word of Makeflags, which works for GNU make 3.x, but not for
GNU make 4.x, which has it in the end of that word.
This changes all three of the above to behave just like Kbuild does,
and print no output with 'make -s' regardless of the version of that
tool, but otherwise behaves as before. In case of
tools/scripts/Makefile.include, I decided to use an identical
conditional block to set the $(quiet) variable for consistency,
even though it is not used in the same way.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Makefile | 5 +++--
tools/build/Makefile.build | 10 ++++++++++
tools/scripts/Makefile.include | 12 +++++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index d5289117360b..3638bb27ba2c 100644
--- a/Makefile
+++ b/Makefile
@@ -1612,11 +1612,12 @@ image_name:
# Clear a bunch of variables before executing the submake
tools/: FORCE
$(Q)mkdir -p $(objtree)/tools
- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/
+ echo MAKEFLAGS=\""$(MAKEFLAGS)"\"
+ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(findstring s,$(firstword -$(MAKEFLAGS))) $(filter --j% -j -s,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/
tools/%: FORCE
$(Q)mkdir -p $(objtree)/tools
- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $*
+ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(findstring s,$(firstword -$(MAKEFLAGS))) $(filter --j% -j -s,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $*
# Single targets
# ---------------------------------------------------------------------------
diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
index 99c0ccd2f176..e279a71c650d 100644
--- a/tools/build/Makefile.build
+++ b/tools/build/Makefile.build
@@ -19,6 +19,16 @@ else
Q=@
endif
+ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
+ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
+ quiet=silent_
+endif
+else # make-3.8x
+ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
+ quiet=silent_
+endif
+endif
+
build-dir := $(srctree)/tools/build
# Define $(fixdep) for dep-cmd function
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 8abbef164b4e..aa6c3c9261e4 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -58,7 +58,17 @@ descend = \
QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
QUIET_SUBDIR1 =
-ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
+ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
+ quiet=silent_
+endif
+else # make-3.8x
+ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
+ quiet=silent_
+endif
+endif
+
+ifneq ($(quiet),silent_)
ifneq ($(V),1)
QUIET_CC = @echo ' CC '$@;
QUIET_CC_FPIC = @echo ' CC FPIC '$@;
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: honor '-s' option for tools/*
2016-10-10 12:36 [PATCH] kbuild: honor '-s' option for tools/* Arnd Bergmann
@ 2016-10-10 13:31 ` Joe Perches
2016-10-10 19:49 ` Josh Poimboeuf
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-10-10 13:31 UTC (permalink / raw)
To: Arnd Bergmann, Michal Marek
Cc: Josh Poimboeuf, Arnaldo Carvalho de Melo, Masahiro Yamada,
Jiri Olsa, linux-kbuild, linux-kernel
On Mon, 2016-10-10 at 14:36 +0200, Arnd Bergmann wrote:
> This changes all three of the above to behave just like Kbuild does,
> and print no output with 'make -s' regardless of the version of that
> tool, but otherwise behaves as before. In case of
> tools/scripts/Makefile.include, I decided to use an identical
> conditional block to set the $(quiet) variable for consistency,
> even though it is not used in the same way.
trivial notes:
> diff --git a/Makefile b/Makefile
[]
> @@ -1612,11 +1612,12 @@ image_name:
> # Clear a bunch of variables before executing the submake
> tools/: FORCE
> $(Q)mkdir -p $(objtree)/tools
> - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/
> + echo MAKEFLAGS=\""$(MAKEFLAGS)"\"
> + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(findstring s,$(firstword -$(MAKEFLAGS))) $(filter --j% -j -s,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/
Perhaps this is complicated enough to warrant some additional comments.
> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
[]
> @@ -19,6 +19,16 @@ else
> Q=@
> endif
>
> +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
> +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
> + quiet=silent_
> +endif
> +else # make-3.8x
> +ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
> + quiet=silent_
> +endif
> +endif
And perhaps the tests should be reversed for make version 3 so when
make version 5 comes out and it likely has the same behavior as
version 4, this doesn't need rewrite.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: honor '-s' option for tools/*
2016-10-10 12:36 [PATCH] kbuild: honor '-s' option for tools/* Arnd Bergmann
2016-10-10 13:31 ` Joe Perches
@ 2016-10-10 19:49 ` Josh Poimboeuf
1 sibling, 0 replies; 3+ messages in thread
From: Josh Poimboeuf @ 2016-10-10 19:49 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Michal Marek, Arnaldo Carvalho de Melo, Masahiro Yamada,
Jiri Olsa, linux-kbuild, linux-kernel
On Mon, Oct 10, 2016 at 02:36:37PM +0200, Arnd Bergmann wrote:
> When building with 'make -s' on x86, we always see the output for descending into
> the tools/objtool directory when CONFIG_STACK_VALIDATION is set, but we should not
> see any output. There are three related problems causing this:
>
> * we override the MAKEFLAGS variable when entering tools, keeping only
> the -j and --j% options around when we should also propagate the -s
> flag (for some make versions) as well as the 's' character in the first
> word of the variable.
>
> * The build system in tools/build/Makefile.build that is used for some
> parts of the build process of objtool implements the same
> logic as the normal kbuild, using 'quiet_$(cmd)' to indicate the
> string that should be printed, but lacks the logic to skip that
> when building with 'make -s'.
>
> * The /other/ build system in tools/scripts/Makefile.include that is also
> used for building objtool checks for the 's' flag in the beginning of
> the first word of Makeflags, which works for GNU make 3.x, but not for
> GNU make 4.x, which has it in the end of that word.
>
> This changes all three of the above to behave just like Kbuild does,
> and print no output with 'make -s' regardless of the version of that
> tool, but otherwise behaves as before. In case of
> tools/scripts/Makefile.include, I decided to use an identical
> conditional block to set the $(quiet) variable for consistency,
> even though it is not used in the same way.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Makefile | 5 +++--
> tools/build/Makefile.build | 10 ++++++++++
> tools/scripts/Makefile.include | 12 +++++++++++-
> 3 files changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d5289117360b..3638bb27ba2c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1612,11 +1612,12 @@ image_name:
> # Clear a bunch of variables before executing the submake
> tools/: FORCE
> $(Q)mkdir -p $(objtree)/tools
> - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/
> + echo MAKEFLAGS=\""$(MAKEFLAGS)"\"
I think this echo wasn't meant to be left in?
Otherwise it seems to work for me.
--
Josh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-10 19:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-10 12:36 [PATCH] kbuild: honor '-s' option for tools/* Arnd Bergmann
2016-10-10 13:31 ` Joe Perches
2016-10-10 19:49 ` Josh Poimboeuf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).