Received: by 10.192.165.156 with SMTP id m28csp2459589imm; Sun, 15 Apr 2018 01:10:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Jj4oQzK57QWhrTAjcn7HAGRkfbLHhPfjCtqZYA6nk2lsy7pRM7lQFq6wlJLdd+a2AX6R4 X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr455718pla.287.1523779852994; Sun, 15 Apr 2018 01:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523779852; cv=none; d=google.com; s=arc-20160816; b=rjf/iLN7EC7FqDi9Nc3M1jQtIggy7jPjSWjgHeFg8ZWv75S9sDsgjJh/jikr7fBmbs b6vHrnTalC9mfXrhwUCyVEMZCBgT8yFeEhAZVJrLTj4TTKFY/t7V8e03LJU3i+19cikp B34gGgKBEvSSD2YFoNSi/nXdglCUXR+GQFUAvi6/F/zL1uEarCkHGSrNbdb3TbKvAWi2 TmJGlozJeGwEgc2pQo6U+9W/e9jF/iB7w0Vf/LLbCr54SCHmXV4ZiZ04DCrK+uwWMdIY Bzu97XDtNuLGwy5ngKmaEw/YjjZKKGHcS+J6gn5DfiYBGwdnXxwpMiSuPcvByL/yeEml 4Rmw== 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 :arc-authentication-results; bh=Y3YxQg/MKVXHAreoONFiswrkpKCHMQi7byyWYPE7NBw=; b=A9fB1siBw7OAxxH89BKZSXDFebQdXUe2wKsXmZlJ6onb7m39iAEoYlhGuW6gyRXlsM aoVsI/H/X2uqfypnO+KH80LzBYpLveJxLfF/l5xdtUUmz6DjEwkFPUio0aaMmz+pezgR FqSioAjrYKbai8Yfwh+sA9X+3rJNwnpeNwkPPnsgVC1L2CZ6oloy1jvbRogBGe4fskN1 XBgx45G56AS8VD41Pzk1XA0Q/0DlCeLqLdl386d2mXz2rCx/HCJoECTODufZY78CTewB Rt2Pdt+Hc7033ttSxN5ky+1fQ9fdCkujCcvTXHJW56QO9oBA6An2gD07BGiGS4FDNWHv Sy+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oAODZG/v; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14-v6si9723837plr.314.2018.04.15.01.10.28; Sun, 15 Apr 2018 01:10:52 -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=@gmail.com header.s=20161025 header.b=oAODZG/v; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbeDOIIZ (ORCPT + 99 others); Sun, 15 Apr 2018 04:08:25 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:44161 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbeDOIIV (ORCPT ); Sun, 15 Apr 2018 04:08:21 -0400 Received: by mail-ua0-f195.google.com with SMTP id r16so8236354uak.11; Sun, 15 Apr 2018 01:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Y3YxQg/MKVXHAreoONFiswrkpKCHMQi7byyWYPE7NBw=; b=oAODZG/vflVgagR9sqDUQM7HEhKjpfdDHsIzZpf+cYKCOsvoPo3s7tbnzMTi1g3zMv KzlBqtzcI0T6kJ6SJLVCqukIiN+h/9GyAMwvCb9cYsQz8HuYhp3ydiddow9hpFlFwqIb mUpLrFxIH5stk0h+djB0lh8eU0ICldwWl36E/z3EBRWtH/ASWo3fPt9hOHm0lzzwqTdF UmAL5TNOECMLfzNon2U6XJqWUoWQttIbGwvfk5bBXsmXWt+7aA4J1MbCZOWztJj3TJ7D CcZnP5TJk+TQQomr5qmlzh82w3xChVaJ7SK9+ftzxPwviTNtU9suWGgHYgy7RsKy2/CD XnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Y3YxQg/MKVXHAreoONFiswrkpKCHMQi7byyWYPE7NBw=; b=psIe9YqTHgyQUOeCtCA7iYpINsnsk3EKdDy2kJD7JhqfGV886ti71a4cqgv/oqcAis mW/9vcwLnYBbSo2aVCUqtONO91bxrmw99rGQJ/4Nofn95tswZF15g67aVHT2TduGT9aF waDT+Cx/+z7jW6E1T6TwmzfCtwxtx0O1emjsPLAtpwL1rtOr99snt0sBQu8Uai3+Q8B1 MH5NJaH/vTReDBxJSuH+1URMV79N68gN4n2zwko3wihjFlEsRriKFFEJN8lhcJ8kSIOz 2grsRdPNCMwhm+ELRksxtJgGr2/Yc+wrc7XIx13isMnFZxvh9MCtp5z8grQLgmkWRSEL hJng== X-Gm-Message-State: ALQs6tCnUccmEYtnEzJgx2bWOUNVmubJpU4DmGWCteuHW+T+mSMOgu1c ZhSswwVNi7E5dLhchq7qQEbPDF0OK//euVlJXt4= X-Received: by 10.176.82.130 with SMTP id v2mr8239877uav.143.1523779700586; Sun, 15 Apr 2018 01:08:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.222.15 with HTTP; Sun, 15 Apr 2018 01:08:20 -0700 (PDT) In-Reply-To: <1523595999-27433-18-git-send-email-yamada.masahiro@socionext.com> References: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> <1523595999-27433-18-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Sun, 15 Apr 2018 10:08:20 +0200 Message-ID: Subject: Re: [PATCH 17/30] Documentation: kconfig: document a new Kconfig macro language To: Masahiro Yamada 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 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)." Cheers, Ulf