Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp691619pxv; Thu, 22 Jul 2021 09:49:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyurwuIc0jduzcf6Iw7T/b7FUzsVL9GG/IW/cX/A8TP/7mzHxYjhAumQbbUu9UbPxRoCg8Q X-Received: by 2002:a05:6638:1646:: with SMTP id a6mr415116jat.1.1626972587084; Thu, 22 Jul 2021 09:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972587; cv=none; d=google.com; s=arc-20160816; b=IttEWgUwRqWOHBdbvYEVmY1iezpgT88NUSOuTpWTeqxMfIVivd0/mKhVYNbCS1JygX 0gurWZYdQZeAm/nn5FnsZJ05MYJsEozR7e2S57ZLBMS4wC+cEeYxYvaaAl5AohIjfEFb 7LstA5fHFpFyiJZpddPGSXzoaJGpDxYk7CcFBBSdMrE+K8wDR4B8zO/NehFZ6NIMpSh7 vxwJxHoTmGlkFt2dJ945HsAY00njDfQdKamrM30AzUVIyvasqWd3AT06aVkiwKyJfdbi +SjXNzYhprL1z1eGcbbdF4YTz0bKaD0waJecycjv4Unl0P5ukythWKzDZeaRisvGrv47 MiHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nYGvBLTm1zJhxIMhoxTFW77F7W1ZKIvl0FKZQ5pm14s=; b=xxGQrX80M/bqjB8rgVwjNcJBUIcGrHZtTBDY2s5p2jh97hDQfSYMSpOOIZhQwyQWAR YGBbko/SZAbuvCeyOaJlCbS9LtH9dmm4zcU5wwAawqCGafA27E6nlGpydq970xwLYZNZ w4fi1REa2SoWESBSsOuI0G5vA+uJQrxbWG0bS2aBVcnRyDuIvve61A/0B0KPh02XTYP0 wB9IKN+s4GALxZEKScYEMuVxADcbTn7mUBWW0Pt8Lx9PQSzFIUTh4rL9ZbcFxk0TCok4 TdMvx5BmBwp5dOBE16nvwyp5cnI9UNGu47dSJcwai8lWKReNFXV3burwBv1U8SxeirJb 1X3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X0z0EJ9p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si18167329jam.109.2021.07.22.09.49.35; Thu, 22 Jul 2021 09:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X0z0EJ9p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233717AbhGVQIL (ORCPT + 99 others); Thu, 22 Jul 2021 12:08:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbhGVQE5 (ORCPT ); Thu, 22 Jul 2021 12:04:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D390060FE9; Thu, 22 Jul 2021 16:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972331; bh=p7QADGqyhrtfkCp/gEg7J+X9qhcFmVaqvBc+66MLyMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X0z0EJ9p4iYBe7BSWZVtB5IOjCWpJCtyeXG9WpnQdxlUhWZd+T8q0Qk52rSlq/qPI LsXOd1DtOqpYVU3HAuN87TvZDQ01ApE2GzjGFLcks3GLrN3mh3GvNj8IY4tFwFElAF HQd5672bpf4nSKS9814UvQHWewIYUpP8Qk4RZa1o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 5.13 037/156] kbuild: sink stdout from cmd for silent build Date: Thu, 22 Jul 2021 18:30:12 +0200 Message-Id: <20210722155629.615349940@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155628.371356843@linuxfoundation.org> References: <20210722155628.371356843@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 82dd1b65b7a8..f247e691562d 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -90,8 +90,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