All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Ulf Magnusson <ulfalizer@gmail.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	Nicholas Piggin <npiggin@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Emese Revfy <re.emese@gmail.com>, X86 ML <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 17/30] Documentation: kconfig: document a new Kconfig macro language
Date: Wed, 18 Apr 2018 00:07:37 +0900	[thread overview]
Message-ID: <CAK7LNAQxxNddpr2PiOR=izKuH5tQhFKP91XFzdY8i6HJ_H3Fgw@mail.gmail.com> (raw)
In-Reply-To: <CAFkk2KQu-GUcocDpRO=VZrjSXaZe8Bo-1feJwABX5PXhsYu+XA@mail.gmail.com>

2018-04-15 17:08 GMT+09:00 Ulf Magnusson <ulfalizer@gmail.com>:
> On Fri, Apr 13, 2018 at 7:06 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> 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 <yamada.masahiro@socionext.com>
>> ---
>>
>> 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

  reply	other threads:[~2018-04-17 15:08 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13  5:06 [PATCH 00/30] kconfig: move compiler capability tests to Kconfig Masahiro Yamada
2018-04-13  5:06 ` [PATCH 01/30] gcc-plugins: fix build condition of SANCOV plugin Masahiro Yamada
2018-05-04 14:21   ` Masahiro Yamada
2018-05-04 16:21     ` Kees Cook
2018-05-05  1:35       ` Masahiro Yamada
2018-04-13  5:06 ` [PATCH 02/30] kbuild: remove kbuild cache Masahiro Yamada
2018-04-13  5:06 ` [PATCH 03/30] kbuild: remove CONFIG_CROSS_COMPILE support Masahiro Yamada
2018-04-13  5:06 ` [PATCH 04/30] kconfig: reference environment variables directly and remove 'option env=' Masahiro Yamada
2018-04-13  5:06 ` [PATCH 05/30] kconfig: remove string expansion in file_lookup() Masahiro Yamada
2018-04-13  5:06 ` [PATCH 06/30] kconfig: remove string expansion for mainmenu after yyparse() Masahiro Yamada
2018-04-13  5:06 ` [PATCH 07/30] kconfig: remove sym_expand_string_value() Masahiro Yamada
2018-04-13  5:06 ` [PATCH 08/30] kconfig: add built-in function support Masahiro Yamada
2018-04-15  7:57   ` Ulf Magnusson
2018-04-15 15:12     ` Masahiro Yamada
2018-04-13  5:06 ` [PATCH 09/30] kconfig: add 'shell' built-in function Masahiro Yamada
2018-04-13  5:06 ` [PATCH 10/30] kconfig: replace $(UNAME_RELEASE) with function call Masahiro Yamada
2018-04-13  5:06 ` [PATCH 11/30] kconfig: begin PARAM state only when seeing a command keyword Masahiro Yamada
2018-04-13  5:06 ` [PATCH 12/30] kconfig: support variable and user-defined function Masahiro Yamada
2018-04-13  5:06 ` [PATCH 13/30] kconfig: support simply expanded variable Masahiro Yamada
2018-04-13  5:06 ` [PATCH 14/30] kconfig: support append assignment operator Masahiro Yamada
2018-04-13  5:06 ` [PATCH 15/30] kconfig: expand lefthand side of assignment statement Masahiro Yamada
2018-04-13  5:06 ` [PATCH 16/30] kconfig: add 'info' and 'warning' built-in functions Masahiro Yamada
2018-04-13  5:06 ` [PATCH 17/30] Documentation: kconfig: document a new Kconfig macro language Masahiro Yamada
2018-04-14 23:33   ` Randy Dunlap
2018-04-17 15:05     ` Masahiro Yamada
2018-04-15  8:08   ` Ulf Magnusson
2018-04-17 15:07     ` Masahiro Yamada [this message]
2018-04-18  8:33       ` Ulf Magnusson
2018-04-13  5:06 ` [PATCH 18/30] kconfig: test: test text expansion Masahiro Yamada
2018-04-13  5:06 ` [PATCH 19/30] kconfig: show compiler version text in the top comment Masahiro Yamada
2018-04-13  5:06 ` [PATCH 20/30] kconfig: add basic helper macros to scripts/Kconfig.include Masahiro Yamada
2018-04-15  7:41   ` Ulf Magnusson
2018-04-15 15:02     ` Masahiro Yamada
2018-04-13  5:06 ` [PATCH 21/30] stack-protector: test compiler capability in Kconfig and drop AUTO mode Masahiro Yamada
2018-04-13 16:41   ` Kees Cook
2018-04-13 18:11     ` Linus Torvalds
2018-04-13 20:41       ` Kees Cook
2018-04-15 13:28       ` Masahiro Yamada
2018-04-15 16:04         ` Kees Cook
2018-04-15  9:40     ` Masahiro Yamada
2018-04-13  5:06 ` [PATCH 22/30] kconfig: add CC_IS_GCC and GCC_VERSION Masahiro Yamada
2018-04-13  5:06 ` [PATCH 23/30] kconfig: add CC_IS_CLANG and CLANG_VERSION Masahiro Yamada
2018-04-13  5:06 ` [PATCH 24/30] gcov: remove CONFIG_GCOV_FORMAT_AUTODETECT Masahiro Yamada
2018-04-13  5:06 ` [PATCH 25/30] kcov: test compiler capability in Kconfig and correct dependency Masahiro Yamada
2018-04-13  5:06 ` [PATCH 26/30] gcc-plugins: move GCC version check for PowerPC to Kconfig Masahiro Yamada
2018-04-13  5:06 ` [PATCH 27/30] gcc-plugins: test plugin support in Kconfig and clean up Makefile Masahiro Yamada
2018-04-13  5:06 ` [PATCH 28/30] gcc-plugins: allow to enable GCC_PLUGINS for COMPILE_TEST Masahiro Yamada
2018-04-13  5:06 ` [PATCH 29/30] arm64: move GCC version check for ARCH_SUPPORTS_INT128 to Kconfig Masahiro Yamada
2018-04-13  5:06 ` [PATCH 30/30] kbuild: test dead code/data elimination support in Kconfig Masahiro Yamada
2018-04-13  5:17 ` [PATCH 00/30] kconfig: move compiler capability tests to Kconfig Masahiro Yamada
2018-04-13  5:52 ` Kees Cook
2018-04-13 12:21   ` Masahiro Yamada
2018-04-13 13:55     ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7LNAQxxNddpr2PiOR=izKuH5tQhFKP91XFzdY8i6HJ_H3Fgw@mail.gmail.com' \
    --to=yamada.masahiro@socionext.com \
    --cc=keescook@chromium.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=re.emese@gmail.com \
    --cc=sam@ravnborg.org \
    --cc=torvalds@linux-foundation.org \
    --cc=ulfalizer@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.