From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CEE3C47E56 for ; Wed, 14 Jul 2021 19:48:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D728613E8 for ; Wed, 14 Jul 2021 19:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240641AbhGNTt6 (ORCPT ); Wed, 14 Jul 2021 15:49:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:38740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236420AbhGNTo4 (ORCPT ); Wed, 14 Jul 2021 15:44:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 875F5613DB; Wed, 14 Jul 2021 19:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626291691; bh=r1v3JfXU/VBmSp8CWannxOEfm/T+yRC4PywBxuJXvUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHTLJte685uctfAx6iLXi2jsZDOS9TVL8UoUUDpF0PYbP2I6V6RTW/ymyG9VZUX0M IPrkB3QyMVDwszXPXln4VucxPqHMyU4sA2aPj2SHpIzzPTnV6pl18d3cLPvGgoJY6N uzLdMN3hHmUN3jrYBn6mYYb13833g+dgZ9bRz5MslLxMnSrcLtA9Lh8X9+n6Da5pd4 eQJCUtrjCdGuzh0oVPBhKs7xC6gS186wsgDWlaNHblPQwYTmNmi2ExvtrL+TF6fCTu +SQyh6fSrNiah5YanOMs+vG6dhjeCOCifzoDm6AVJnddROIfY5+NSke9I3EC8I7dYi yEUIZTU4NnRqQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masahiro Yamada , Sasha Levin , linux-kbuild@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 039/102] kbuild: sink stdout from cmd for silent build Date: Wed, 14 Jul 2021 15:39:32 -0400 Message-Id: <20210714194036.53141-39-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210714194036.53141-1-sashal@kernel.org> References: <20210714194036.53141-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 174a1dcc96429efce4ef7eb2f5c4506480da2182 ] When building with 'make -s', no output to stdout should be printed. As Arnd Bergmann reported [1], mkimage shows the detailed information of the generated images. I think this should be suppressed by the 'cmd' macro instead of by individual scripts. Insert 'exec >/dev/null;' in order to redirect stdout to /dev/null for silent builds. [Note about this implementation] 'exec >/dev/null;' may look somewhat tricky, but this has a reason. Appending '>/dev/null' at the end of command line is a common way for redirection, so I first tried this: cmd = @set -e; $(echo-cmd) $(cmd_$(1)) >/dev/null ... but it would not work if $(cmd_$(1)) itself contains a redirection. For example, cmd_wrap in scripts/Makefile.asm-generic redirects the output from the 'echo' command into the target file. It would be expanded into: echo "#include " > $@ >/dev/null Then, the target file gets empty because the string will go to /dev/null instead of $@. Next, I tried this: cmd = @set -e; $(echo-cmd) { $(cmd_$(1)); } >/dev/null The form above would be expanded into: { echo "#include " > $@; } >/dev/null This works as expected. However, it would be a syntax error if $(cmd_$(1)) is empty. When CONFIG_TRIM_UNUSED_KSYMS is disabled, $(call cmd,gen_ksymdeps) in scripts/Makefile.build would be expanded into: set -e; { ; } >/dev/null ..., which causes an syntax error. I also tried this: cmd = @set -e; $(echo-cmd) ( $(cmd_$(1)) ) >/dev/null ... but this causes a syntax error for the same reason. So, finally I adopted: cmd = @set -e; $(echo-cmd) exec >/dev/null; $(cmd_$(1)) [1]: https://lore.kernel.org/lkml/20210514135752.2910387-1-arnd@kernel.org/ Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/Kbuild.include | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 509e0856d653..f0b6dbd3c7fe 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -170,8 +170,13 @@ clean := -f $(srctree)/scripts/Makefile.clean obj 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; + # printing commands -cmd = @set -e; $(echo-cmd) $(cmd_$(1)) +cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(cmd_$(1)) ### # if_changed - execute command if any prerequisite is newer than -- 2.30.2