Received: by 10.223.185.116 with SMTP id b49csp1442095wrg; Fri, 16 Feb 2018 20:45:32 -0800 (PST) X-Google-Smtp-Source: AH8x225v+61ljTvQxBX+VAPKOYbLIp7zp4JUDkODyp1QUEMiVTTFXjVz4lFJv0tHq517u8WOoWmj X-Received: by 10.101.74.208 with SMTP id c16mr6959503pgu.116.1518842732719; Fri, 16 Feb 2018 20:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518842732; cv=none; d=google.com; s=arc-20160816; b=eBpAADDWsLg+SFPmzqU2KG/TI1yd+o+qQ6Hu9jUNsuzhUJydaNoGYhx8Qpu1p4M0I5 cMWxZHPbTzljPeWvA1MJoiosyF7ZxyPaa3QexU75iMJHNuxNGIyE+2g9kBuBHTkhKXo5 6KCQSNlC7dIoJsspM4BBDzuBV6aRivwltDCvvqGfgd5a0+mBIuPSSqZwe+/dsmReOOrQ 7rKoaPfL03Vs6ev0HcuVbUT3BGp7Mz6FQ55hiHD+OjRBJDMDe1PBot7GhUGgwp6+1VKw hWLwv/SWBACE3eo1xw6fjR4A/khYGr68I7QN/VXBMfqUbi598lo0ROmXJAfcRiPkV2jp p6XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature:arc-authentication-results; bh=BE5bnyh/VfbGjmbiCgf5cy8EmJCtJYHexC0IdEJlgUk=; b=rsha5QZ/YOYLGGAGC0K0M90Kt5gNPAmdN/0fP8i96XWzOZAcpWzjlFt1B+I43Rr16B ZE7r+TbLupmMU0hL445KtQosV47hA7fkQv56QYTvjW5PpJ//EcREpdvWDUcP4SZhGEV3 jK+XZPayPKVuk0/uDNo9JuLsTiyYQpoawJp+wyHFyH8sAZ4Gn9cCSbLtrB+rDoFGCMNY RqsEFyOyI5i7V59L3REs24Oh8qMuViW30OfxSHLZ1Ngm3e2qwoGGoAchc1+nEajNev+c GTkiLi79Ue9Y27Pro7eQTYFYE9kqIzbcdTOFXEIScTUgxILNvM60sPbfxHgJMubQDu4d OyOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=U06yWAFo; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=wW49z+Ix; 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 d9-v6si4185224pln.115.2018.02.16.20.45.18; Fri, 16 Feb 2018 20:45:32 -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=@pobox.com header.s=sasl header.b=U06yWAFo; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=wW49z+Ix; 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 S1751088AbeBQEo3 (ORCPT + 99 others); Fri, 16 Feb 2018 23:44:29 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:57721 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeBQEo2 (ORCPT ); Fri, 16 Feb 2018 23:44:28 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id C4014D1DE2; Fri, 16 Feb 2018 23:44:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=aPkfZI/PssrIH3DUDEwGKuVWrVQ=; b=U06yWA Fo0QT8eeBBd7Qc9cPj5oZKqHGLt6x84EVhPq6DIo8i3MTiezE/S2hsQFiodmy6wf AStqS8KxkumirK7CS8mVBxQN6KN8RAv/dsLhRBvqV4z6hboAKGYnIYtckStizK/k MWZgJqbhknf30MuLPe/EZDky05TSWVqFYUk7c= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id BA938D1DE1; Fri, 16 Feb 2018 23:44:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=0lH6IeJN8bN7dC3mqwWTr5SjaP/HO0MHbOYq9idVaqE=; b=wW49z+IxstuPGIwnVtmQxtIEwBx5Jhf9ljfsc5GuANrJ5nRj3BRsinSspw7GZNczF6aXzuSOAgA/vtfNcGofn+jvOvJKqLtBjBCV7AeqpVYFghMLQt3zL7uC4bZXfCjzpoXmpALDCj3D1V6azx5AYgbpufSpneWZfw7snnF6qi0= Received: from yoda.home (unknown [70.82.104.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 3F134D1DE0; Fri, 16 Feb 2018 23:44:26 -0500 (EST) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 4F39E2DA0419; Fri, 16 Feb 2018 23:44:25 -0500 (EST) Date: Fri, 16 Feb 2018 23:44:25 -0500 (EST) From: Nicolas Pitre To: Ulf Magnusson cc: Masahiro Yamada , Linux Kbuild mailing list , Linus Torvalds , Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Sam Ravnborg , Michal Marek , Linux Kernel Mailing List Subject: Re: [PATCH 08/23] kconfig: add 'macro' keyword to support user-defined function In-Reply-To: Message-ID: References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> <1518806331-7101-9-git-send-email-yamada.masahiro@socionext.com> <20180216235138.b4p6q62auvnzb2sy@huvuddator> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: 3B6FABFA-139D-11E8-9FAB-692D1A68708C-78420484!pb-smtp1.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 17 Feb 2018, Ulf Magnusson wrote: > On Sat, Feb 17, 2018 at 3:30 AM, Nicolas Pitre wrote: > > On Sat, 17 Feb 2018, Ulf Magnusson wrote: > > > >> On Fri, Feb 16, 2018 at 02:49:31PM -0500, Nicolas Pitre wrote: > >> > On Sat, 17 Feb 2018, Masahiro Yamada wrote: > >> > > >> > > Now, we got a basic ability to test compiler capability in Kconfig. > >> > > > >> > > config CC_HAS_STACKPROTECTOR > >> > > bool > >> > > default $(shell $CC -Werror -fstack-protector -c -x c /dev/null -o /dev/null) > >> > > > >> > > This works, but it is ugly to repeat this long boilerplate. > >> > > > >> > > We want to describe like this: > >> > > > >> > > config CC_HAS_STACKPROTECTOR > >> > > bool > >> > > default $(cc-option -fstack-protector) > >> > > > >> > > It is straight-forward to implement a new function, but I do not like > >> > > to hard-code specialized functions like this. Hence, here is another > >> > > feature to add functions from Kconfig files. > >> > > > >> > > A user-defined function can be defined as a string type symbol with > >> > > a special keyword 'macro'. It can be referenced in the same way as > >> > > built-in functions. This feature was also inspired by Makefile where > >> > > user-defined functions are referenced by $(call func-name, args...), > >> > > but I omitted the 'call' to makes it shorter. > >> > > > >> > > The macro definition can contain $(1), $(2), ... which will be replaced > >> > > with arguments from the caller. > >> > > > >> > > Example code: > >> > > > >> > > config cc-option > >> > > string > >> > > macro $(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null) > >> > > >> > I think this syntax for defining a macro shouldn't start with the > >> > "config" keyword, unless you want it to be part of the config symbol > >> > space and land it in .config. And typing it as a "string" while it > >> > actually returns y/n (hence a bool) is also strange. > >> > > >> > What about this instead: > >> > > >> > macro cc-option > >> > bool $(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null) > >> > > >> > This makes it easier to extend as well if need be. > >> > > >> > > >> > Nicolas > >> > >> I haven't gone over the patchset in detail yet and might be missing > >> something here, but if this is just meant to be a textual shorthand, > >> then why give it a type at all? > > > > It is meant to be like a user-defined function. > > > >> Do you think a simpler syntax like this would make sense? > >> > >> macro cc-option "$(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null)" > >> > >> That's the most general version, where you could use it for other stuff > >> besides $(shell ...) as well, just to keep parity. > > > > This is not extendable. Let's imagine that you might want to implement > > some kind of conditionals some day e.g.: > > > > macro complex_test > > bool $(shell foo) if LOCKDEP_SUPPORT > > bool y if DEBUG_DRIVER > > bool n > > I still don't quite get the semantics here. How would the behavior > change if the type was changed to say string or int in some or all of > the lines? I admit this wouldn't make sense to have multiple different types. In this example, the bool keyword acts as syntactic sugar more than anything else. > Since the current model is to evaluate $() while the Kconfig files are > being parsed, would this require evaluating Kconfig expressions during > parsing? There is a relatively clean and (somewhat) easy to understand > parsing/evaluation separation at the moment, which I like. Agreed. Let's forget about the conditionals then. Nicolas