Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8768699imu; Thu, 15 Nov 2018 17:40:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eju7cTFg3o2Dhyglk13CdN+faXe5OCKnr1GZ75qZCsiX3ghfougYDSbtt5ZhHc6GUZMJ6b X-Received: by 2002:a63:bc02:: with SMTP id q2mr8189078pge.116.1542332436657; Thu, 15 Nov 2018 17:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542332436; cv=none; d=google.com; s=arc-20160816; b=tNrFCqYW2kup8eEiUFJdbiUEm5uSmh+7AEvpKdy1HggunLqs4MpPwkF5mkU2x51R78 sslbFXCijbMClGdiZ6QyHz4kHyiES4TQvYQFq29aNq2Ruhtvfq2ZL+o5r76yIGhUfPSg 3dGdITbJ1jqOpZ2LTIf9LvVwiFLIzb7gUPT4pNtGeEMoFtJKLNwiB3auVlRlkzOQqugu d0CKNNyzYVi36j8FL4AGSamvVLbkaeoYvBvXJUoGkRaSiKY1v6LHmEGXFq85jpTn+b05 tRgFs2zOdnyWKK0ZkgN70hX/OfW9IGLdG1psl472FxCWcsp8vbu8cQqhK44H7PStU0RF mUlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=1NdtcIOUsWj7ZpMaN0l2aGw6fT/KcTkkQjgoB2Ug0Sw=; b=SQPOSDpfOHuZiZWcZzXInqNjJ5P8AB/ohip4rfJQFY8WtiBUDp+0mUE7ZalSdhUYRB h9YqXA0rgWdfRrVVmw0obrkJjFU1GxM+As2LBdNKhy0qJ0gwvoK0pMnXWFgaDIAbilVa 2vKTm63OF0MCa0gERiQH0R1ExVOvKZzxjhFGEOCTgMwkVTBDZ1sx/aySNQJqc39sPvpT +dp0BL/GwF3plxi1JHg54HQsoHzArW/cKQdGHnlTEjqsYq32YqJPGKDQ7wqMB3wwoSRL 5iBx+zZh+C+s6EsecFDU3MgU0p2MP71CBGcim+bAlpI9HG6fdGqPoGZF3rA2s3wNE51O QQXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Y1cj+kmu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d66si1245243pfg.36.2018.11.15.17.40.21; Thu, 15 Nov 2018 17:40:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Y1cj+kmu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389114AbeKPLsZ (ORCPT + 99 others); Fri, 16 Nov 2018 06:48:25 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:37599 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbeKPLsZ (ORCPT ); Fri, 16 Nov 2018 06:48:25 -0500 Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (authenticated) by conssluserg-02.nifty.com with ESMTP id wAG1btOZ010604; Fri, 16 Nov 2018 10:37:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com wAG1btOZ010604 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542332276; bh=1NdtcIOUsWj7ZpMaN0l2aGw6fT/KcTkkQjgoB2Ug0Sw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Y1cj+kmuZHaG7NQq186NRb/WiWtXgNePv3okSNu0y4hJAdDBhFwwHLocFdqxwnglb jrnQY6PGu5+q4pv+76ZDxuizX9svyz5pl5Q66+9W20sfPikiBpQ58YtqmQC2xtmAhv 4d1CxU8tTpf5gqGT38M6M7BxG6nn7M0CyAYU9qPiPkGxURE7afSOp3474zJMU5kMpe gAxeywS6OuwTndEflFmHaGJy8e35aJ4nD1VLKI1ZU42yRKxwf8CScgQim1DgL4Dlu6 XszoWJt9UAPalSnFZxhViSjl72SzkFjT6EDA2OCHZ8B6VTHgUhU2+NNeVTKROUPXo8 LmWjLcBCcWlvw== X-Nifty-SrcIP: [209.85.217.48] Received: by mail-vs1-f48.google.com with SMTP id y27so12903389vsi.1; Thu, 15 Nov 2018 17:37:55 -0800 (PST) X-Gm-Message-State: AGRZ1gKIdc1w9pzUo5Ud2Zmt7Nb1bBZPWcyBTqXs9i7b3/bNgQluKdYZ AUH8Su7u9Ku8aH1t/NTfiIVYf3On8s9GY86lV0Q= X-Received: by 2002:a67:f1d6:: with SMTP id v22mr3631240vsm.181.1542332274614; Thu, 15 Nov 2018 17:37:54 -0800 (PST) MIME-Version: 1.0 References: <1542270435-11181-1-git-send-email-yamada.masahiro@socionext.com> <1542270435-11181-6-git-send-email-yamada.masahiro@socionext.com> <6ee62b52-5d6d-c540-5f01-f522b6986c4d@rasmusvillemoes.dk> In-Reply-To: <6ee62b52-5d6d-c540-5f01-f522b6986c4d@rasmusvillemoes.dk> From: Masahiro Yamada Date: Fri, 16 Nov 2018 10:37:18 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/8] kbuild: change if_changed_rule to accept multi-line recipe To: Rasmus Villemoes Cc: Linux Kbuild mailing list , Sam Ravnborg , Nicolas Pitre , Michal Marek , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 6:12 PM Rasmus Villemoes wrote: > > On 15/11/2018 09.27, Masahiro Yamada wrote: > > GNU Make supports 'define' ... 'endef' directive, which can describe > > a recipe that consists of multiple lines. > > > > endef > > > > This does not actually exploit the benefits of 'define' ... 'endef' > > form. All shell commands must be concatenated with '; \' so that it > > looks like a single command from the Makefile point of view. '@' can > > only appear before the first action. > > > > The root cause of this misfortune is the '@set -e;' in if_changed_rule. > > It is easily solvable by moving '@set -e' to the 'cmd' macro. > > > > The combo of $(call echo-cmd,*) $(cmd_*) in rule_cc_o_c and rule_as_o_S > > were replaced with $(call cmd,*). The tailing back-slashes went away. > > > > Signed-off-by: Masahiro Yamada > > --- > > > > define rule_cc_o_c > > - $(call echo-cmd,checksrc) $(cmd_checksrc) \ > > - $(call cmd_and_fixdep,cc_o_c) \ > > - $(cmd_gen_ksymdeps) \ > > - $(cmd_checkdoc) \ > > - $(call echo-cmd,objtool) $(cmd_objtool) \ > > - $(cmd_modversions_c) \ > > - $(call echo-cmd,record_mcount) $(cmd_record_mcount) > > + $(call cmd,checksrc) > > + @$(call cmd_and_fixdep,cc_o_c) > > + $(call cmd,gen_ksymdeps) > > + $(call cmd,checkdoc) > > + $(call cmd,objtool) > > + $(call cmd,modversions_c) > > + $(call cmd,record_mcount) > > endef > > Does this mean that Make now spawns a new shell for each of these > commands, Yes and No. Basically, each line is run in an independent sub-shell, but things are a little bit complex. GNU Make, if possible, runs the command directly instead of forking a shell process. That is what I understood according to the following document: http://wanderinghorse.net/computing/make/book/ManagingProjectsWithGNUMake-3.1.3.pdf See "chapter 7: commands" ---------->8---------- Commands are essentially one-line shell scripts. In effect, make grabs each line and passes it to a subshell for execution. In fact, make can optimize this (relatively) expensive fork/exec algorithm if it can guarantee that omitting the shell will not change the behavior of the program. It checks this by scanning each command line for shell special characters, such as wildcard characters and i/o redirection. If none are found, make directly executes the command without passing it to a subshell. ---------->8---------- > and if so, what's the performance impact? Or am I just > misreading things? If this does change the semantics (one shell instance > versus many), I think that's worth mentioning explicitly in the > changelog, regardless of whether there's no measuarable performance impact. Last night, I checked 'perf stat' of x86 defconfig build, which enables cmd_objtool. Without this commit: Performance counter stats for 'make -j8' (10 runs): 125.499068713 seconds time elapsed ( +- 0.10% ) With this commit: Performance counter stats for 'make -j8' (10 runs): 125.618321667 seconds time elapsed ( +- 0.24% ) I did not get noticeable performance regression. -- Best Regards Masahiro Yamada