Received: by 10.192.165.156 with SMTP id m28csp165416imm; Tue, 17 Apr 2018 08:10:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Y9jxyHPIpDf3M7RhJwsmgVl9dUkTe+rcwVqCcbQP7JC/DdylLZDOfrsPH7fJL3TsFjopa X-Received: by 10.98.72.205 with SMTP id q74mr2356974pfi.70.1523977830246; Tue, 17 Apr 2018 08:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523977830; cv=none; d=google.com; s=arc-20160816; b=HXjvVLgLHUNHxEWeM1CvSZqyzuWlwtxnfjLVJAB7uFWwiPWmwtii2ntK5UmyoF+nBV vKAlQEpPd7X9Z6BVGd4UIrjGMYeMrXH/zbadUJPKFNhEi9NMxZlZLgwvltz6N3qxZfRr 6gGbcOnDfjKNxlMOyQPqI4gFNl46Z57vD4wvv/r8rizSuhAfAbxwbAZuZSyYrebnj5gN ZvF02e1+44IEU0FKicNMe9zt+uccTa6KhV3/DMsn1c1/0ieZR9xa568T7Ljn3McQNQFk eyStDtwxIm252KhLkjPte3K4vGd2yR1eIx06J3BkBwJk7KR0nQZ4R6uwiIez/Id6HxVI 0YDA== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=LKc7qEOUag0TC13CSkOhf3H+6Z5yaLzM9pKjahARitw=; b=KkzHi8n5JNrnEhF0yb4Hweck3X193KWxt/pzFkbTkL6Olyd2rJFgJ6jjo0YHmDEwMd a8BiKfs4ao4Ya261z4jQn1oCaYvFbI8bFRrkAt9+kws2HdN+/VdO2QG2tg0IQp15FKob c+2Aka4u+8j5zfPoXxDoNoYxgKy1y8JXHn+RBTrQ2b+5XBVnITvUWZkhiAr1AE7Q+VI0 HiwANQoSAOmJBTZiFHadCF4YyHfbBYnX/p9RTrwxJfR2yAPOW9H6X8KT2QpTUN5mc8ci pAFss/e43MZzQhvyzBsfSGr9DEAFr97CNzPyCHnCUtHfX7+dSxOJc72ZoZYkRHmtSP7N h1Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=dHx8Gr90; 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 d81si13120597pfd.210.2018.04.17.08.10.15; Tue, 17 Apr 2018 08:10:30 -0700 (PDT) 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=dHx8Gr90; 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 S1752757AbeDQPIl (ORCPT + 99 others); Tue, 17 Apr 2018 11:08:41 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:18108 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeDQPIj (ORCPT ); Tue, 17 Apr 2018 11:08:39 -0400 Received: from mail-ua0-f182.google.com (mail-ua0-f182.google.com [209.85.217.182]) (authenticated) by conssluserg-03.nifty.com with ESMTP id w3HF8Ipt006008; Wed, 18 Apr 2018 00:08:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com w3HF8Ipt006008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1523977699; bh=LKc7qEOUag0TC13CSkOhf3H+6Z5yaLzM9pKjahARitw=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=dHx8Gr903IJTgMD4Z6MIbh9GD2TEyCU3dF1x2xKDTHGc8hGbVIa9z4FNNlVXLSB66 2tM8uL+xEHOr7MkhKyOn3FPhaOxDdXf6urWSMm9IKp6KdXTjEAnuHCpu83e80M6qoA nHIaNEkYEy9RiSaKt/xZUIyVcjPfrKv7hFzPCWrLWk+aWLc9ITmYvHO9SOkXVR1LKr B5+6M7LgZ/sewMcOL450aEAOY7qxXTsQ1dn5JBXnH/wMsMia/ZWnJ4ZbTFqhTlNRuR 1afZvvlt8t9r9+wxMclOrp8TnCfOIErcf9BZvUuPb8+GN1PJMt1EIh8xD2lVUI+peq N+pkJ0IkYIC/A== X-Nifty-SrcIP: [209.85.217.182] Received: by mail-ua0-f182.google.com with SMTP id t9so12768380uac.8; Tue, 17 Apr 2018 08:08:19 -0700 (PDT) X-Gm-Message-State: ALQs6tDwPcRTtp770jsseKAxY1oWenEU4NAV4vGjdhEkFmWFR0kItq2e dfNBTOBKgZ/KqfeJYxyfTNjexB2vvv9zxDhg5Qw= X-Received: by 10.176.19.3 with SMTP id g3mr1748989uae.140.1523977698114; Tue, 17 Apr 2018 08:08:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.85.216 with HTTP; Tue, 17 Apr 2018 08:07:37 -0700 (PDT) In-Reply-To: References: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> <1523595999-27433-18-git-send-email-yamada.masahiro@socionext.com> From: Masahiro Yamada Date: Wed, 18 Apr 2018 00:07:37 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 17/30] Documentation: kconfig: document a new Kconfig macro language To: Ulf Magnusson Cc: Linux Kbuild mailing list , Linus Torvalds , Sam Ravnborg , Nicholas Piggin , Kees Cook , Emese Revfy , X86 ML , 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 2018-04-15 17:08 GMT+09:00 Ulf Magnusson : > On Fri, Apr 13, 2018 at 7:06 AM, Masahiro Yamada > wrote: >> Add a document for the macro language introduced to Kconfig. >> >> The motivation of this work is to move the compiler option tests to >> Kconfig from Makefile. A number of kernel features require the >> compiler support. Enabling such features blindly in Kconfig ends up >> with a lot of nasty build-time testing in Makefiles. If a chosen >> feature turns out unsupported by the compiler, what the build system >> can do is either to disable it (silently!) or to forcibly break the >> build, despite Kconfig has let the user to enable it. >> >> This change was strongly prompted by Linus Torvalds. You can find >> his suggestions [1] [2] in ML. The original idea was to add a new >> 'option', but I found generalized text expansion would make Kconfig >> more powerful and lovely. While polishing up the implementation, I >> noticed sort of similarity between Make and Kconfig. This might be >> too immature to be called 'language', but anyway here it is. All >> ideas are from Make (you can even say it is addicted), so people >> will easily understand how it works. >> >> [1]: https://lkml.org/lkml/2016/12/9/577 >> [2]: https://lkml.org/lkml/2018/2/7/527 >> >> Signed-off-by: Masahiro Yamada >> --- >> >> Changes in v3: None >> Changes in v2: None >> >> Documentation/kbuild/kconfig-macro-language.txt | 179 ++++++++++++++++++++++++ >> MAINTAINERS | 2 +- >> 2 files changed, 180 insertions(+), 1 deletion(-) >> create mode 100644 Documentation/kbuild/kconfig-macro-language.txt >> >> diff --git a/Documentation/kbuild/kconfig-macro-language.txt b/Documentation/kbuild/kconfig-macro-language.txt >> new file mode 100644 >> index 0000000..1f6281b >> --- /dev/null >> +++ b/Documentation/kbuild/kconfig-macro-language.txt >> @@ -0,0 +1,179 @@ >> +Concept >> +------- >> + >> +The basic idea was inspired by Make. When we look at Make, we notice sort of >> +two languages in one. One language describes dependency graphs consisting of >> +targets and prerequisites. The other is a macro language for performing textual >> +substitution. >> + >> +There is clear distinction between the two language stages. For example, you >> +can write a makefile like follows: >> + >> + APP := foo >> + SRC := foo.c >> + CC := gcc >> + >> + $(APP): $(SRC) >> + $(CC) -o $(APP) $(SRC) >> + >> +The macro language replaces the variable references with their expanded form, >> +and handles as if the source file were input like follows: >> + >> + foo: foo.c >> + gcc -o foo foo.c >> + >> +Then, Make analyzes the dependency graph and determines the targets to be >> +updated. >> + >> +The idea is quite similar in Kconfig - it is possible to describe a Kconfig >> +file like this: >> + >> + CC := gcc >> + >> + config CC_HAS_FOO >> + def_bool $(shell $(srctree)/scripts/gcc-check-foo.sh $(CC)) >> + >> +The macro language in Kconfig processes the source file into the following >> +intermediate: >> + >> + config CC_HAS_FOO >> + def_bool y >> + >> +Then, Kconfig moves onto the evaluation stage to resolve inter-symbol >> +dependency, which is explained in kconfig-language.txt. >> + >> + >> +Variables >> +--------- >> + >> +Like in Make, a variable in Kconfig works as a macro variable. A macro >> +variable is expanded "in place" to yield a text string that may then expanded >> +further. To get the value of a variable, enclose the variable name in $( ). >> +As a special case, single-letter variable names can omit the parentheses and is >> +simply referenced like $X. Unlike Make, Kconfig does not support curly braces >> +as in ${CC}. > > Do we need single-letter variable names for anything? It looks like > we're deviating > a bit from Make behavior already. > > I suspect they're just a side effect of Make having automatic variables like $@. > The Make manual discourages them otherwise: > > "A dollar sign followed by a character other than a dollar sign, > open-parenthesis or > open-brace treats that single character as the variable name. Thus, you could > reference the variable x with `$x'. However, this practice is strongly > discouraged, > except in the case of the automatic variables (see section Automatic > Variables)." > OK. We do not need two ways to do the same thing. I will consider it although supporting single-letter variable is not costly. -- Best Regards Masahiro Yamada