[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNARr1bHkub1kOaa1ep72Tth8HJocr5dS0TFx7+L7VyFH6A@mail.gmail.com>
Date: Fri, 13 Apr 2018 14:32:20 +0900
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
To: Kees Cook <keescook@...omium.org>
Cc: linux-kbuild <linux-kbuild@...r.kernel.org>,
Sam Ravnborg <sam@...nborg.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
Ulf Magnusson <ulfalizer@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Randy Dunlap <rdunlap@...radead.org>,
"Luis R . Rodriguez" <mcgrof@...nel.org>,
Nicolas Pitre <nico@...aro.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 07/21] kconfig: add function support and implement
'shell' function
2018-03-28 12:41 GMT+09:00 Kees Cook <keescook@...omium.org>:
> On Mon, Mar 26, 2018 at 10:29 PM, Masahiro Yamada
> <yamada.masahiro@...ionext.com> wrote:
>> This commit adds a new concept 'function' to do more text processing
>> in Kconfig.
>>
>> A function call looks like this:
>>
>> $(function arg1, arg2, arg3, ...)
>>
>> (Actually, this syntax was inspired by make.)
>>
>> Real examples will look like this:
>>
>> $(shell echo hello world)
>> $(cc-option -fstackprotector)
>>
>> This commit adds the basic infrastructure to add, delete, evaluate
>> functions, and also the first built-in function $(shell ...). This
>> accepts a single command to execute. It returns the standard output
>> from it.
>>
>> [Example code]
>>
>> config HELLO
>> string
>> default "$(shell echo hello world)"
>>
>> config Y
>> def_bool $(shell echo y)
>>
>> [Result]
>>
>> $ make -s alldefconfig && tail -n 2 .config
>> CONFIG_HELLO="hello world"
>> CONFIG_Y=y
>>
>> Caveat:
>> Like environments, functions are expanded in the lexer. You cannot
>> pass symbols to function arguments. This is a limitation to simplify
>> the implementation. I want to avoid the dynamic function evaluation,
>> which would introduce much more complexity.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
>> ---
>>
>> Reminder for myself:
>> Update Documentation/kbuild/kconfig-language.txt
>
> Yeah, this needs to be included here, especially given the "cannot
> pass symbols" aspect which might surprise people.
>
>> [...]
>> +/* built-in functions */
>> +static char *do_shell(struct function *f, int argc, char *argv[])
>> +{
>> + static const char *pre = "(";
>> + static const char *post = ") 2>/dev/null";
>
> Right now the search and help screens in menuconfig just show the line
> a config is defined and nothing more. I think it would be extremely
> handy to include shell output here in some way.
The current implementation cannot do this.
The $(shell ...) has already expanded
before the parser receives tokens.
There is no way to know whether a token came from a source file as-is,
or it was derived from textual substitution.
> Especially when trying
> to answer questions like "why aren't GCC plugins available?" it's got
> quite a bit harder to debug.
> Could we capture the output (especially stderr) for these kinds of hints?
For example, it would be possible to dump the result of $(shell ...)
evaluation into the console in debug mode.
> Beyond that, looks good!
>
> -Kees
>
> --
> Kees Cook
> Pixel Security
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists