Received: by 10.223.185.116 with SMTP id b49csp1262202wrg; Fri, 16 Feb 2018 15:52:55 -0800 (PST) X-Google-Smtp-Source: AH8x225MvVARwkVVqer9zcyjQyeawtiBbUKXSWvCP1CHd2/0Vlud4fqD5thGvdXkMKw18ww7tYCX X-Received: by 2002:a17:902:7042:: with SMTP id h2-v6mr7337091plt.217.1518825175290; Fri, 16 Feb 2018 15:52:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518825175; cv=none; d=google.com; s=arc-20160816; b=Use1nMZoTBq2LTt/tS0FzCD8eXVHrgAMMqHGndko4ur3RAXHD8Xe2U54QP6vd1XZD7 0HbvUBfdGA8yi4x8Wdc9KYzgBZyrGOwLGEY3KdIMLn+gBy1wSpcwrFstI93ic56ngZw+ zpFlUWmwhbj7KG3yRF1LZpFt0SpNyBLjonCYS9SywqnE6zHN+FwExHkaevTFsBxkSwvh OaFY9mxeTkFJnZWT6Nn71kor3k71Asik/uNsMzunO22qTwau72z2G9m5lsWCvE4LiRrm 3QzZGBgFhJoTvpMNdhfy0MAw/LX9Zu9Rm/UvWYMdTR2SE0BLhfgiUFhlsHOoel7TU+uI kz+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=mYMah6JIv7PpClB4G+rqbgOej+tPCuvOjOa/pPkncRU=; b=wjQY7qJo8/Qwiq0yt3ZGpVpRkUUoZw3wlfWZ6nWt6MeD8XNjUs/UOI0uh/bh0Bukh4 29wC9tePVCZhYlQno5UyPszn07P/CMl6bb/5YBh2MdFm7/psLra3A5nPukURniRmHvv3 /df8CStiQL6AIO6wPt0AK1MU4qgsbWImM+PPDYLsSrt0/Vqs+To66SkEva3GRDYgoBnJ E+ZNn0i/U975wGMLqn+ztEgels8tCkNzYhUsRya+y3G9AIYfhumZ5R/Q0YWmL/xUlOE4 +zxlFuuuD9AU1l9pIkO2e/98hdnbyVBOGv9He3YVBJgNIu1xZyYoJ4/m3iVKARqILQA6 0ncw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Oav4AF7B; 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 k194si1523798pgc.662.2018.02.16.15.52.40; Fri, 16 Feb 2018 15:52:55 -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=@gmail.com header.s=20161025 header.b=Oav4AF7B; 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 S1751102AbeBPXvv (ORCPT + 99 others); Fri, 16 Feb 2018 18:51:51 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36461 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbeBPXvt (ORCPT ); Fri, 16 Feb 2018 18:51:49 -0500 Received: by mail-lf0-f68.google.com with SMTP id t79so6189798lfe.3; Fri, 16 Feb 2018 15:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mYMah6JIv7PpClB4G+rqbgOej+tPCuvOjOa/pPkncRU=; b=Oav4AF7BNqFyOb6IcTt+p9r27lD1VJmyjGZYdXvG1lxl2NXI2MRbCngFPXzLaxCyoV 6FI+4qDxcrMsd4F3ZF+sbllnvMzkYzZDwu+19QUvHOKucIJFjSzxchcpATAgC0jDzxZo 2zKvW4qCsgxEeEh0V2qVZGrTdH5CBjXe63/+aVTpsYmvC0igqmY7wIZzj4NbbA5bAikv Er3UxgpKZpE3vlw/CnacSnEiVEwPcJy1RbU18ERSsz9pRtfo5leXQCj4o6yLAAIDzrSD kMmffmniaBIsWDvMyeBgpgtfdiUfJ5OsIkvYOpo01qlnq4L6HMTbKd4onAitK8VSPk4G BVQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mYMah6JIv7PpClB4G+rqbgOej+tPCuvOjOa/pPkncRU=; b=hIjTlDsHt3jbIG3k1retk24pDeDPnZK7cx6LoHakQUL3dYzx+gMPPem1qYO0cGlikx OKZSS9FFd9Mr8BcKKvFJ/8r3/JLhMIiSRKsOLPT3+GPG712NNRgp2wbx3aU4XBjn+q72 178FsvBfYriN0EYrN/l0QlOYU62DLnGfoGovtzTaci/CP8qqmJVfuR+3hxDs+LDuWa1u GqvDGdGLUQgcCko2zSBqAldSQUrMio2YTwJH1yfC0YiKu//7GqOY2doeQWRqixizlEKY RMDOamK0t78tVOVQWsC5b3FD9mjNWHOED6pdLOjxPKpfIbjoLAc2V1F9pgqPbNeYf6tb Q0lw== X-Gm-Message-State: APf1xPCX8x7U12CM0RyrS1M5SV+zmlS5ZshOw0+YfsqktTRtSV3ATNDK 9GETaxkbKpkB3wz+a7mFW0Q= X-Received: by 10.46.15.26 with SMTP id 26mr5409809ljp.52.1518825108092; Fri, 16 Feb 2018 15:51:48 -0800 (PST) Received: from huvuddator (ua-213-113-106-221.cust.bredbandsbolaget.se. [213.113.106.221]) by smtp.gmail.com with ESMTPSA id m202sm1170416lfg.37.2018.02.16.15.51.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Feb 2018 15:51:47 -0800 (PST) Date: Sat, 17 Feb 2018 00:51:38 +0100 From: Ulf Magnusson To: Nicolas Pitre 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 Message-ID: <20180216235138.b4p6q62auvnzb2sy@huvuddator> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> <1518806331-7101-9-git-send-email-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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. You could then always just expand $() as a string, and maybe spit out "n" and "y" in the cases Linus suggested for $(shell ...). The existing logic for constant symbols should then take care of converting that into a tristate value where appropriate. If you go with that and want to support $() outside quotes, then $(foo) would just be a shorthand for "$(foo)" Are there any cases where something more advanced than that might be warranted (e.g., macros that expand to complete expressions)? It seems pretty nice and nonmagical otherwise. Cheers, Ulf