All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] kbuild: refactor silent mode detection
@ 2022-12-22 16:25 Masahiro Yamada
  2022-12-22 16:25 ` [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1 Masahiro Yamada
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

Factor out $(findstring s,...).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 25247f931872..e8ce3e2b30d6 100644
--- a/Makefile
+++ b/Makefile
@@ -100,12 +100,12 @@ endif
 # make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
 
 ifeq ($(filter 3.%,$(MAKE_VERSION)),)
-silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
+short-opts := $(firstword -$(MAKEFLAGS))
 else
-silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
+short-opts := $(filter-out --%,$(MAKEFLAGS))
 endif
 
-ifeq ($(silence),s)
+ifneq ($(findstring s,$(short-opts)),)
 quiet=silent_
 KBUILD_VERBOSE = 0
 endif
-- 
2.34.1


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

* [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
@ 2022-12-22 16:25 ` Masahiro Yamada
  2022-12-23 11:23   ` Nicolas Schier
  2022-12-22 16:25   ` Masahiro Yamada
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier

"make V=1" prints the whole command instead of the short log, but I
think it is nicer to print both so that you can easily spot the build
rule of your interest.

This commit changes V=1 to print the short log (the line starts with
'#'), followed by the full log.

In parallel builds, the short/full logs from the same build rule may
be interspersed. To avoid it, please add -Otarget along with the -j<N>
option. Kbuild will never set -Otarget by default because Make would
buffer the logs and lose the escape sequences. (Modern compilers print
warnings and errors in color, but only when they write to a terminal.)

This is also a preparation for supporting V=12 because V=2 appends the
reason for rebuilding to the short log.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile               | 18 +++++++-----------
 scripts/Kbuild.include | 26 +++++++++++++-------------
 2 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/Makefile b/Makefile
index e8ce3e2b30d6..ce98dfd8359a 100644
--- a/Makefile
+++ b/Makefile
@@ -56,22 +56,18 @@ unexport GREP_OPTIONS
 # Beautify output
 # ---------------------------------------------------------------------------
 #
-# Normally, we echo the whole command before executing it. By making
-# that echo $($(quiet)$(cmd)), we now have the possibility to set
-# $(quiet) to choose other forms of output instead, e.g.
+# Most of build commands in Kbuild start with "cmd_". You can optionally define
+# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from
+# that command is printed by default.
 #
-#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
-#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
-#
-# If $(quiet) is empty, the whole command will be printed.
-# If it is set to "quiet_", only the short version will be printed.
-# If it is set to "silent_", nothing will be printed at all, since
-# the variable $(silent_cmd_cc_o_c) doesn't exist.
+# e.g.)
+#    quiet_cmd_depmod = DEPMOD  $(MODLIB)
+#          cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)
 #
 # A simple variant is to prefix commands with $(Q) - that's useful
 # for commands that shall be hidden in non-verbose mode.
 #
-#	$(Q)ln $@ :<
+#    $(Q)$(MAKE) $(build)=scripts/basic
 #
 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 2f7356b2990b..faae3c7986b0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -125,15 +125,15 @@ dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
 # $(Q)$(MAKE) $(clean)=dir
 clean := -f $(srctree)/scripts/Makefile.clean obj
 
-# echo command.
-# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
-echo-cmd = $(if $($(quiet)cmd_$(1)),\
-	echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
-
-# sink stdout for 'make -s'
-       redirect :=
- quiet_redirect :=
-silent_redirect := exec >/dev/null;
+# pring log
+#
+# If quiet is "silent_", print nothing and sink stdout
+# If quiet is "quiet_", print short log
+# If quiet is empty, print short log and whole command
+silent_log_print = exec >/dev/null;
+ quiet_log_print = $(if $(quiet_cmd_$1), echo '  $(call escsq,$(quiet_cmd_$1)$(why))';)
+       log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@))'; \
+                   echo '  $(call escsq,$(cmd_$1))';
 
 # Delete the target on interruption
 #
@@ -156,8 +156,8 @@ delete-on-interrupt = \
 		$(foreach sig, HUP INT QUIT TERM PIPE, \
 			trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))
 
-# printing commands
-cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1))
+# print and execute commands
+cmd = @$(if $(cmd_$(1)),set -e; $($(quiet)log_print) $(delete-on-interrupt) $(cmd_$(1)),:)
 
 ###
 # if_changed      - execute command if any prerequisite is newer than
@@ -234,7 +234,7 @@ if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
 # (6) No dir/.target.cmd file and target not listed in $(targets)
 #     This is a good hint that there is a bug in the kbuild file
 ifeq ($(KBUILD_VERBOSE),2)
-why =                                                                        \
+_why =                                                                        \
     $(if $(filter $@, $(PHONY)),- due to target is PHONY,                    \
         $(if $(wildcard $@),                                                 \
             $(if $(newer-prereqs),- due to: $(newer-prereqs),                \
@@ -251,7 +251,7 @@ why =                                                                        \
          )                                                                   \
      )
 
-echo-why = $(call escsq, $(strip $(why)))
+why = $(space)$(strip $(_why))
 endif
 
 ###############################################################################
-- 
2.34.1


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

* [PATCH 3/5] kbuild: do not print extra logs for V=2
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
@ 2022-12-22 16:25   ` Masahiro Yamada
  2022-12-22 16:25   ` Masahiro Yamada
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Christophe Leroy, David Howells,
	David Woodhouse, Jonathan Corbet, Liam Howlett, Michael Ellerman,
	Nicholas Piggin, Zeng Heng, keyrings, linux-doc, linuxppc-dev

Some scripts increase the verbose level when V=1, but others when
not V=0.

I think the former is correct because V=2 is not a log level but
a switch to print the reason for rebuilding.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Documentation/Makefile                 | 2 +-
 arch/powerpc/kernel/prom_init_check.sh | 9 ++++-----
 certs/extract-cert.c                   | 9 ++++++---
 scripts/asn1_compiler.c                | 4 ++--
 scripts/kernel-doc                     | 4 ++--
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index bb73dcb5ed05..023fa658a0a8 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -28,7 +28,7 @@ BUILDDIR      = $(obj)/output
 PDFLATEX      = xelatex
 LATEXOPTS     = -interaction=batchmode -no-shell-escape
 
-ifeq ($(KBUILD_VERBOSE),0)
+ifeq ($(findstring 1, $(KBUILD_VERBOSE)),)
 SPHINXOPTS    += "-q"
 endif
 
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 311890d71c4c..5a319863f289 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -51,11 +51,10 @@ do
 	# a leading . on the name, so strip it off here.
 	UNDEF="${UNDEF#.}"
 
-	if [ $KBUILD_VERBOSE ]; then
-		if [ $KBUILD_VERBOSE -ne 0 ]; then
-			echo "Checking prom_init.o symbol '$UNDEF'"
-		fi
-	fi
+	case "$KBUILD_VERBOSE" in
+	*1*)
+		echo "Checking prom_init.o symbol '$UNDEF'" ;;
+	esac
 
 	OK=0
 	for WHITE in $WHITELIST
diff --git a/certs/extract-cert.c b/certs/extract-cert.c
index 8c1fb9a70d66..d3a0ff2867c0 100644
--- a/certs/extract-cert.c
+++ b/certs/extract-cert.c
@@ -78,7 +78,7 @@ static void drain_openssl_errors(void)
 static const char *key_pass;
 static BIO *wb;
 static char *cert_dst;
-static int kbuild_verbose;
+static bool verbose;
 
 static void write_cert(X509 *x509)
 {
@@ -90,19 +90,22 @@ static void write_cert(X509 *x509)
 	}
 	X509_NAME_oneline(X509_get_subject_name(x509), buf, sizeof(buf));
 	ERR(!i2d_X509_bio(wb, x509), "%s", cert_dst);
-	if (kbuild_verbose)
+	if (verbose)
 		fprintf(stderr, "Extracted cert: %s\n", buf);
 }
 
 int main(int argc, char **argv)
 {
 	char *cert_src;
+	char *kbuild_verbose;
 
 	OpenSSL_add_all_algorithms();
 	ERR_load_crypto_strings();
 	ERR_clear_error();
 
-	kbuild_verbose = atoi(getenv("KBUILD_VERBOSE")?:"0");
+	kbuild_verbose = getenv("KBUILD_VERBOSE");
+	if (kbuild_verbose && strchr(kbuild_verbose, '1'))
+		verbose = true;
 
         key_pass = getenv("KBUILD_SIGN_PIN");
 
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index 71d4a7c87900..7b6756a8c15d 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -567,8 +567,8 @@ int main(int argc, char **argv)
 	int fd;
 
 	kbuild_verbose = getenv("KBUILD_VERBOSE");
-	if (kbuild_verbose)
-		verbose_opt = atoi(kbuild_verbose);
+	if (kbuild_verbose && strchr(kbuild_verbose, '1'))
+		verbose_opt = true;
 
 	while (argc > 4) {
 		if (strcmp(argv[1], "-v") == 0)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 54b0893cae66..8ad0a7d68d9a 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -175,8 +175,8 @@ my $declaration_start_line;
 my ($type, $declaration_name, $return_type);
 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
 
-if (defined($ENV{'KBUILD_VERBOSE'})) {
-	$verbose = "$ENV{'KBUILD_VERBOSE'}";
+if (defined($ENV{'KBUILD_VERBOSE'}) && $ENV{'KBUILD_VERBOSE'} =~ '1') {
+	$verbose = 1;
 }
 
 if (defined($ENV{'KCFLAGS'})) {
-- 
2.34.1


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

* [PATCH 3/5] kbuild: do not print extra logs for V=2
@ 2022-12-22 16:25   ` Masahiro Yamada
  0 siblings, 0 replies; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Zeng Heng, linuxppc-dev, Jonathan Corbet, Masahiro Yamada,
	linux-doc, Nicholas Piggin, linux-kernel, David Howells,
	keyrings, Liam Howlett, David Woodhouse

Some scripts increase the verbose level when V=1, but others when
not V=0.

I think the former is correct because V=2 is not a log level but
a switch to print the reason for rebuilding.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Documentation/Makefile                 | 2 +-
 arch/powerpc/kernel/prom_init_check.sh | 9 ++++-----
 certs/extract-cert.c                   | 9 ++++++---
 scripts/asn1_compiler.c                | 4 ++--
 scripts/kernel-doc                     | 4 ++--
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index bb73dcb5ed05..023fa658a0a8 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -28,7 +28,7 @@ BUILDDIR      = $(obj)/output
 PDFLATEX      = xelatex
 LATEXOPTS     = -interaction=batchmode -no-shell-escape
 
-ifeq ($(KBUILD_VERBOSE),0)
+ifeq ($(findstring 1, $(KBUILD_VERBOSE)),)
 SPHINXOPTS    += "-q"
 endif
 
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 311890d71c4c..5a319863f289 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -51,11 +51,10 @@ do
 	# a leading . on the name, so strip it off here.
 	UNDEF="${UNDEF#.}"
 
-	if [ $KBUILD_VERBOSE ]; then
-		if [ $KBUILD_VERBOSE -ne 0 ]; then
-			echo "Checking prom_init.o symbol '$UNDEF'"
-		fi
-	fi
+	case "$KBUILD_VERBOSE" in
+	*1*)
+		echo "Checking prom_init.o symbol '$UNDEF'" ;;
+	esac
 
 	OK=0
 	for WHITE in $WHITELIST
diff --git a/certs/extract-cert.c b/certs/extract-cert.c
index 8c1fb9a70d66..d3a0ff2867c0 100644
--- a/certs/extract-cert.c
+++ b/certs/extract-cert.c
@@ -78,7 +78,7 @@ static void drain_openssl_errors(void)
 static const char *key_pass;
 static BIO *wb;
 static char *cert_dst;
-static int kbuild_verbose;
+static bool verbose;
 
 static void write_cert(X509 *x509)
 {
@@ -90,19 +90,22 @@ static void write_cert(X509 *x509)
 	}
 	X509_NAME_oneline(X509_get_subject_name(x509), buf, sizeof(buf));
 	ERR(!i2d_X509_bio(wb, x509), "%s", cert_dst);
-	if (kbuild_verbose)
+	if (verbose)
 		fprintf(stderr, "Extracted cert: %s\n", buf);
 }
 
 int main(int argc, char **argv)
 {
 	char *cert_src;
+	char *kbuild_verbose;
 
 	OpenSSL_add_all_algorithms();
 	ERR_load_crypto_strings();
 	ERR_clear_error();
 
-	kbuild_verbose = atoi(getenv("KBUILD_VERBOSE")?:"0");
+	kbuild_verbose = getenv("KBUILD_VERBOSE");
+	if (kbuild_verbose && strchr(kbuild_verbose, '1'))
+		verbose = true;
 
         key_pass = getenv("KBUILD_SIGN_PIN");
 
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index 71d4a7c87900..7b6756a8c15d 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -567,8 +567,8 @@ int main(int argc, char **argv)
 	int fd;
 
 	kbuild_verbose = getenv("KBUILD_VERBOSE");
-	if (kbuild_verbose)
-		verbose_opt = atoi(kbuild_verbose);
+	if (kbuild_verbose && strchr(kbuild_verbose, '1'))
+		verbose_opt = true;
 
 	while (argc > 4) {
 		if (strcmp(argv[1], "-v") == 0)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 54b0893cae66..8ad0a7d68d9a 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -175,8 +175,8 @@ my $declaration_start_line;
 my ($type, $declaration_name, $return_type);
 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
 
-if (defined($ENV{'KBUILD_VERBOSE'})) {
-	$verbose = "$ENV{'KBUILD_VERBOSE'}";
+if (defined($ENV{'KBUILD_VERBOSE'}) && $ENV{'KBUILD_VERBOSE'} =~ '1') {
+	$verbose = 1;
 }
 
 if (defined($ENV{'KCFLAGS'})) {
-- 
2.34.1


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

* [PATCH 4/5] kbuild: allow to combine multiple V= levels
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
  2022-12-22 16:25 ` [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1 Masahiro Yamada
  2022-12-22 16:25   ` Masahiro Yamada
@ 2022-12-22 16:25 ` Masahiro Yamada
  2022-12-23 11:23   ` Nicolas Schier
  2022-12-22 16:25 ` [PATCH 5/5] kbuild: drop V=0 support Masahiro Yamada
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Borislav Petkov,
	Cristian Ciocaltea, Dave Hansen, Greg Kroah-Hartman,
	H. Peter Anvin, Ingo Molnar, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Thomas Gleixner, Vipin Sharma, x86

Commit a6de553da01c ("kbuild: Allow to combine multiple W= levels")
supported W=123 to enable all the extra warning groups.

I think a similar idea is applicable to the V= option.

  V=1 echos the whole command
  V=2 prints the reason for rebuilding

These are orthogonal, and can be enabled at the same time.

This commit supports V=12 to enable both of them.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile                | 18 +++++++++---------
 arch/x86/tools/Makefile |  2 +-
 scripts/Kbuild.include  |  4 ++--
 scripts/tags.sh         |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index ce98dfd8359a..bd69bf73a256 100644
--- a/Makefile
+++ b/Makefile
@@ -69,9 +69,8 @@ unexport GREP_OPTIONS
 #
 #    $(Q)$(MAKE) $(build)=scripts/basic
 #
-# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
-# If KBUILD_VERBOSE equals 1 then the above command is displayed.
-# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
+# If KBUILD_VERBOSE contains 1, the whole command is echoed.
+# If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed.
 #
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
@@ -83,12 +82,12 @@ ifndef KBUILD_VERBOSE
   KBUILD_VERBOSE = 0
 endif
 
-ifeq ($(KBUILD_VERBOSE),1)
+quiet = quiet_
+Q = @
+
+ifneq ($(findstring 1, $(KBUILD_VERBOSE)),)
   quiet =
   Q =
-else
-  quiet=quiet_
-  Q = @
 endif
 
 # If the user is running make -s (silent mode), suppress echoing of
@@ -1762,8 +1761,9 @@ help:
 		printf "  %-16s - Show all of the above\\n" help-boards; \
 		echo '')
 
-	@echo  '  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
-	@echo  '  make V=2   [targets] 2 => give reason for rebuild of target'
+	@echo  '  make V=n   [targets] 0: quiet build (default), 1: verbose build'
+	@echo  '                       2: give reason for rebuild of target'
+	@echo  '                       V=1 and V=2 can be combined with V=12'
 	@echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
 	@echo  '  make C=1   [targets] Check re-compiled c source with $$CHECK'
 	@echo  '                       (sparse by default)'
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
index bddfc9a46645..90e820ac9771 100644
--- a/arch/x86/tools/Makefile
+++ b/arch/x86/tools/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 PHONY += posttest
 
-ifeq ($(KBUILD_VERBOSE),1)
+ifneq ($(findstring 1, $(KBUILD_VERBOSE)),)
   posttest_verbose = -v
 else
   posttest_verbose =
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index faae3c7986b0..10cf8d2d82ef 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -132,7 +132,7 @@ clean := -f $(srctree)/scripts/Makefile.clean obj
 # If quiet is empty, print short log and whole command
 silent_log_print = exec >/dev/null;
  quiet_log_print = $(if $(quiet_cmd_$1), echo '  $(call escsq,$(quiet_cmd_$1)$(why))';)
-       log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@))'; \
+       log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@)$(why))'; \
                    echo '  $(call escsq,$(cmd_$1))';
 
 # Delete the target on interruption
@@ -233,7 +233,7 @@ if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
 # (5) No dir/.target.cmd file (used to store command line)
 # (6) No dir/.target.cmd file and target not listed in $(targets)
 #     This is a good hint that there is a bug in the kbuild file
-ifeq ($(KBUILD_VERBOSE),2)
+ifneq ($(findstring 2, $(KBUILD_VERBOSE)),)
 _why =                                                                        \
     $(if $(filter $@, $(PHONY)),- due to target is PHONY,                    \
         $(if $(wildcard $@),                                                 \
diff --git a/scripts/tags.sh b/scripts/tags.sh
index e137cf15aae9..2e756bee1fa9 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -8,7 +8,7 @@
 # Uses the following environment variables:
 # SUBARCH, SRCARCH, srctree
 
-if [ "$KBUILD_VERBOSE" = "1" ]; then
+if [[ "$KBUILD_VERBOSE" =~ 1 ]]; then
 	set -x
 fi
 
-- 
2.34.1


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

* [PATCH 5/5] kbuild: drop V=0 support
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
                   ` (2 preceding siblings ...)
  2022-12-22 16:25 ` [PATCH 4/5] kbuild: allow to combine multiple V= levels Masahiro Yamada
@ 2022-12-22 16:25 ` Masahiro Yamada
  2022-12-23 11:24   ` Nicolas Schier
  2022-12-22 17:51 ` [PATCH 1/5] kbuild: refactor silent mode detection Nick Desaulniers
  2022-12-23 11:23 ` Nicolas Schier
  5 siblings, 1 reply; 13+ messages in thread
From: Masahiro Yamada @ 2022-12-22 16:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Jonathan Corbet,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier, linux-doc

The top Makefile sets KBUILD_VERBOSE to 0 by default, it looks weird
now because V=1 and V=2 can be OR'ed as V=12. The default should be
empty.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Documentation/kbuild/makefiles.rst | 4 ++--
 Makefile                           | 7 ++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index 6b7368d1f516..59085ffbe99a 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -523,7 +523,7 @@ more details, with real examples.
 			$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
 			@$(kecho) '  Kernel: $(boot)/$@ is ready'
 
-	When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand
+	When kbuild is executing with KBUILD_VERBOSE unset, then only a shorthand
 	of a command is normally displayed.
 	To enable this behaviour for custom commands kbuild requires
 	two variables to be set::
@@ -544,7 +544,7 @@ more details, with real examples.
 
 		  GEN     lib/crc32table.h
 
-	will be displayed with "make KBUILD_VERBOSE=0".
+	will be displayed with "make KBUILD_VERBOSE=".
 
 3.12 Command change detection
 -----------------------------
diff --git a/Makefile b/Makefile
index bd69bf73a256..99cb8c9de53a 100644
--- a/Makefile
+++ b/Makefile
@@ -78,9 +78,6 @@ unexport GREP_OPTIONS
 ifeq ("$(origin V)", "command line")
   KBUILD_VERBOSE = $(V)
 endif
-ifndef KBUILD_VERBOSE
-  KBUILD_VERBOSE = 0
-endif
 
 quiet = quiet_
 Q = @
@@ -102,7 +99,7 @@ endif
 
 ifneq ($(findstring s,$(short-opts)),)
 quiet=silent_
-KBUILD_VERBOSE = 0
+override KBUILD_VERBOSE :=
 endif
 
 export quiet Q KBUILD_VERBOSE
@@ -1761,7 +1758,7 @@ help:
 		printf "  %-16s - Show all of the above\\n" help-boards; \
 		echo '')
 
-	@echo  '  make V=n   [targets] 0: quiet build (default), 1: verbose build'
+	@echo  '  make V=n   [targets] 1: verbose build'
 	@echo  '                       2: give reason for rebuild of target'
 	@echo  '                       V=1 and V=2 can be combined with V=12'
 	@echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
-- 
2.34.1


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

* Re: [PATCH 1/5] kbuild: refactor silent mode detection
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
                   ` (3 preceding siblings ...)
  2022-12-22 16:25 ` [PATCH 5/5] kbuild: drop V=0 support Masahiro Yamada
@ 2022-12-22 17:51 ` Nick Desaulniers
  2022-12-23 11:23 ` Nicolas Schier
  5 siblings, 0 replies; 13+ messages in thread
From: Nick Desaulniers @ 2022-12-22 17:51 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nicolas Schier

On Thu, Dec 22, 2022 at 8:25 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Factor out $(findstring s,...).
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>
>  Makefile | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 25247f931872..e8ce3e2b30d6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -100,12 +100,12 @@ endif
>  # make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
>
>  ifeq ($(filter 3.%,$(MAKE_VERSION)),)
> -silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
> +short-opts := $(firstword -$(MAKEFLAGS))
>  else
> -silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
> +short-opts := $(filter-out --%,$(MAKEFLAGS))
>  endif
>
> -ifeq ($(silence),s)
> +ifneq ($(findstring s,$(short-opts)),)
>  quiet=silent_
>  KBUILD_VERBOSE = 0
>  endif
> --
> 2.34.1
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 1/5] kbuild: refactor silent mode detection
  2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
                   ` (4 preceding siblings ...)
  2022-12-22 17:51 ` [PATCH 1/5] kbuild: refactor silent mode detection Nick Desaulniers
@ 2022-12-23 11:23 ` Nicolas Schier
  5 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

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

On Fri 23 Dec 2022 01:25:31 GMT, Masahiro Yamada wrote:
> Factor out $(findstring s,...).
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

* Re: [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1
  2022-12-22 16:25 ` [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1 Masahiro Yamada
@ 2022-12-23 11:23   ` Nicolas Schier
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers

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

On Fri 23 Dec 2022 01:25:32 GMT, Masahiro Yamada wrote:
> "make V=1" prints the whole command instead of the short log, but I
> think it is nicer to print both so that you can easily spot the build
> rule of your interest.
> 
> This commit changes V=1 to print the short log (the line starts with
> '#'), followed by the full log.
> 
> In parallel builds, the short/full logs from the same build rule may
> be interspersed. To avoid it, please add -Otarget along with the -j<N>
> option. Kbuild will never set -Otarget by default because Make would
> buffer the logs and lose the escape sequences. (Modern compilers print
> warnings and errors in color, but only when they write to a terminal.)
> 
> This is also a preparation for supporting V=12 because V=2 appends the
> reason for rebuilding to the short log.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile               | 18 +++++++-----------
>  scripts/Kbuild.include | 26 +++++++++++++-------------
>  2 files changed, 20 insertions(+), 24 deletions(-)

I think this is really helpful,  thanks!

Tested-by: Nicolas Schier <nicolas@fjasle.eu>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

* Re: [PATCH 3/5] kbuild: do not print extra logs for V=2
  2022-12-22 16:25   ` Masahiro Yamada
@ 2022-12-23 11:23     ` Nicolas Schier
  -1 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Christophe Leroy, David Howells,
	David Woodhouse, Jonathan Corbet, Liam Howlett, Michael Ellerman,
	Nicholas Piggin, Zeng Heng, keyrings, linux-doc, linuxppc-dev

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

On Fri 23 Dec 2022 01:25:33 GMT, Masahiro Yamada wrote:
> Some scripts increase the verbose level when V=1, but others when
> not V=0.
> 
> I think the former is correct because V=2 is not a log level but
> a switch to print the reason for rebuilding.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Documentation/Makefile                 | 2 +-
>  arch/powerpc/kernel/prom_init_check.sh | 9 ++++-----
>  certs/extract-cert.c                   | 9 ++++++---
>  scripts/asn1_compiler.c                | 4 ++--
>  scripts/kernel-doc                     | 4 ++--
>  5 files changed, 15 insertions(+), 13 deletions(-)
> 

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

* Re: [PATCH 3/5] kbuild: do not print extra logs for V=2
@ 2022-12-23 11:23     ` Nicolas Schier
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Zeng Heng, linuxppc-dev, linux-doc, Jonathan Corbet,
	linux-kbuild, Nicholas Piggin, linux-kernel, David Howells,
	keyrings, Liam Howlett, David Woodhouse

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

On Fri 23 Dec 2022 01:25:33 GMT, Masahiro Yamada wrote:
> Some scripts increase the verbose level when V=1, but others when
> not V=0.
> 
> I think the former is correct because V=2 is not a log level but
> a switch to print the reason for rebuilding.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Documentation/Makefile                 | 2 +-
>  arch/powerpc/kernel/prom_init_check.sh | 9 ++++-----
>  certs/extract-cert.c                   | 9 ++++++---
>  scripts/asn1_compiler.c                | 4 ++--
>  scripts/kernel-doc                     | 4 ++--
>  5 files changed, 15 insertions(+), 13 deletions(-)
> 

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

* Re: [PATCH 4/5] kbuild: allow to combine multiple V= levels
  2022-12-22 16:25 ` [PATCH 4/5] kbuild: allow to combine multiple V= levels Masahiro Yamada
@ 2022-12-23 11:23   ` Nicolas Schier
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:23 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Borislav Petkov, Cristian Ciocaltea,
	Dave Hansen, Greg Kroah-Hartman, H. Peter Anvin, Ingo Molnar,
	Nathan Chancellor, Nick Desaulniers, Thomas Gleixner,
	Vipin Sharma, x86

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

On Fri 23 Dec 2022 01:25:34 GMT, Masahiro Yamada wrote:
> Commit a6de553da01c ("kbuild: Allow to combine multiple W= levels")
> supported W=123 to enable all the extra warning groups.
> 
> I think a similar idea is applicable to the V= option.
> 
>   V=1 echos the whole command
>   V=2 prints the reason for rebuilding
> 
> These are orthogonal, and can be enabled at the same time.
> 
> This commit supports V=12 to enable both of them.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile                | 18 +++++++++---------
>  arch/x86/tools/Makefile |  2 +-
>  scripts/Kbuild.include  |  4 ++--
>  scripts/tags.sh         |  2 +-
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 

Tested-by: Nicolas Schier <nicolas@fjasle.eu>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

* Re: [PATCH 5/5] kbuild: drop V=0 support
  2022-12-22 16:25 ` [PATCH 5/5] kbuild: drop V=0 support Masahiro Yamada
@ 2022-12-23 11:24   ` Nicolas Schier
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Schier @ 2022-12-23 11:24 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Jonathan Corbet, Nathan Chancellor,
	Nick Desaulniers, linux-doc

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

On Fri 23 Dec 2022 01:25:35 GMT, Masahiro Yamada wrote:
> The top Makefile sets KBUILD_VERBOSE to 0 by default, it looks weird
> now because V=1 and V=2 can be OR'ed as V=12. The default should be
> empty.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Documentation/kbuild/makefiles.rst | 4 ++--
>  Makefile                           | 7 ++-----
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

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

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

end of thread, other threads:[~2022-12-23 11:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 16:25 [PATCH 1/5] kbuild: refactor silent mode detection Masahiro Yamada
2022-12-22 16:25 ` [PATCH 2/5] kbuild: print short log in addition to the whole command with V=1 Masahiro Yamada
2022-12-23 11:23   ` Nicolas Schier
2022-12-22 16:25 ` [PATCH 3/5] kbuild: do not print extra logs for V=2 Masahiro Yamada
2022-12-22 16:25   ` Masahiro Yamada
2022-12-23 11:23   ` Nicolas Schier
2022-12-23 11:23     ` Nicolas Schier
2022-12-22 16:25 ` [PATCH 4/5] kbuild: allow to combine multiple V= levels Masahiro Yamada
2022-12-23 11:23   ` Nicolas Schier
2022-12-22 16:25 ` [PATCH 5/5] kbuild: drop V=0 support Masahiro Yamada
2022-12-23 11:24   ` Nicolas Schier
2022-12-22 17:51 ` [PATCH 1/5] kbuild: refactor silent mode detection Nick Desaulniers
2022-12-23 11:23 ` Nicolas Schier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.