Received: by 10.223.185.116 with SMTP id b49csp1364792wrg; Fri, 16 Feb 2018 18:31:44 -0800 (PST) X-Google-Smtp-Source: AH8x226mh+tZrdxKKmjuLVk3AP19vxX6eAP5CmGpYl8NgIOIdgbzLwIjXzy5N8dWHUI9NpgGqopO X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr7535038plr.243.1518834704175; Fri, 16 Feb 2018 18:31:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518834704; cv=none; d=google.com; s=arc-20160816; b=Ff0dZ7bZUC9PObwlFvnhTbUmvKr37m6ucjj4RlTpfMObIgLflMN9RW4+katA5ZlXrO Sc6Q76+n6RDPfrTCbUMzFJ6X4cqt8GYqESuPW8Lm9kpWKubVbv4Ou6qq7WD0hcmaAzVo FUGn7vpSCttF7fPsV1EUVSR5h4g93KHryoOzANTZ9ZzPySTg6Mf3VLV66yBwviurY6U4 Wkwx/eF+J8E4IzdvTiwvc4HZWitOOCJF7Ipu+M39U+PQ46SjkgLFWF5/On3XVJ8aMm2P uFwasdAzfnSa2GwZiBJbvRwNRzO5oGAGt2oMsGs7H7aRZT94ks0yPgZji2OKmEJztjQC NKTQ== 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=3f/XPqpDnuNubalyESIZDSlf8meTFzL09HSNd0pjPjA=; b=CSfwuiZKq3TMTqnQQZW79rj2UXwMtmP+tG2MbB/95mrLzJd/+g0AtaAaKs9i6TsDua LbsaolZQRLybIte57whYyRexwS2hyBhQw1VYF0tx2HCDGGbsR347mMC3penUoh/0MA0k xeyCbJGPb1yGvj4OcsMe4JT9CYOSG4KxDmr1GeaumC+/sT3xDwUBiO4xq7QuG8wnn8PF fLLoWGUKK8QkDnp7hsAbn0qN+eWpaTRSF1zmSIO6szV60+Gf8PUj427NTR2YyFbXUstR MQt+5hZD/t/MFMpi7EsAAlnCVy7uIG9Z8eTiYOw6uRjDZFHTT9lkozvTwC71UJtWh1z9 FfDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=ka4y8e2O; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=hKe6c8cP; 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 k3si4088667pff.157.2018.02.16.18.31.29; Fri, 16 Feb 2018 18:31:44 -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=ka4y8e2O; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=hKe6c8cP; 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 S1751096AbeBQCao (ORCPT + 99 others); Fri, 16 Feb 2018 21:30:44 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:54601 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751032AbeBQCam (ORCPT ); Fri, 16 Feb 2018 21:30:42 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id E4072D06AD; Fri, 16 Feb 2018 21:30:41 -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=WLu/3EU+MR6D5cIa/Q3xmS5V53w=; b=ka4y8e 2OvZYf2e+/JdUUEowydUp5LjhyolTQsA5vWA+MTHZvoVtL0wxM/BxrHZWk7aakbD YCRy1F4mdAQbcvzaa7BM6XdC8P4zm4aoSkUJuZkiM04oq5hjwd8GyMl6xf9Jholr 2GR/bp3jZVbuv+PPW9sk4SvSWXM/y19PxS6iU= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id D9FD9D06AC; Fri, 16 Feb 2018 21:30:41 -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=Hi0IFjr1PCi6jCryW/iU67tyUo/Q5pkxhSbgTK3+RxU=; b=hKe6c8cPnKob5J0LIHzA7lL38/bjZoWHopDnZj8J3NVxJq1vBcnzww/kBVGhmbr4DrkIIpUs6ISeqT2ZI3TIqkgh6pxcd9p7xFoTmMlgmUDMYoV0nmkeTxc+kJticl7UunnWTse1JqfHJ8zoUYwH13P0WUaN12jCwqbUIqdleE4= 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 649E7D06AB; Fri, 16 Feb 2018 21:30:41 -0500 (EST) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 8B4DF2DA0419; Fri, 16 Feb 2018 21:30:40 -0500 (EST) Date: Fri, 16 Feb 2018 21:30:38 -0500 (EST) From: Nicolas Pitre To: Ulf Magnusson cc: Masahiro Yamada , linux-kbuild@vger.kernel.org, Linus Torvalds , Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Sam Ravnborg , Michal Marek , linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/23] kconfig: add 'macro' keyword to support user-defined function In-Reply-To: <20180216235138.b4p6q62auvnzb2sy@huvuddator> 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: 8C40FE8E-138A-11E8-AE94-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 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 There is no real advantage to simplify the macro definition to its simplest expression, unlike its actual usage. > Are there any cases where something more advanced than that might be > warranted (e.g., macros that expand to complete expressions)? Maybe not now, but there is no need to close the door on the possibility either. Nicolas