Received: by 10.223.185.116 with SMTP id b49csp1043093wrg; Wed, 21 Feb 2018 11:05:22 -0800 (PST) X-Google-Smtp-Source: AH8x224Y4RO9vwZCvf6wOnBx9lQE3y1vIuBTAgFoyiDxThFHRwRtIX/FuxE7gBm3uKidN4F7PFMP X-Received: by 10.99.97.86 with SMTP id v83mr3478872pgb.138.1519239922708; Wed, 21 Feb 2018 11:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519239922; cv=none; d=google.com; s=arc-20160816; b=eflA3PTrQU7LhtRmP8U5EweBPgd6Hl0ju360JCt0wkxhe5fxcBgvYLWJf2eEpAtnw1 vxtqlG8AivtS0KHrb2KF6ikoeMZazclnT+XFVOPb+LF6dUKPXCfKcf8mH/x1vn3rkPxf XZzd+UyePk+srB7V+LANDFpu9vJ/Nu2aKx7CJ54n6600WpnQpXPRdNqLfQlJ8CRo2w/n BNMPjX7iPiZoY4wRlRgbL54qBjGQt0FR1HI8nX2rzjULk7ZPHvlp1t/Ijvw9bxbE1ANm HuivorDPH5efDP+HHHc9X5iRFEsojios/PMj+SIsxUd19NaPMwKynojt0EDZjgDtInDg 47bQ== 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=SagbDxZqFbGTvy7PvtODUojYkZCiQqHLmTZSDdnDfwk=; b=ZTZHblxHbRaX6r4Nq0HJz05sAJRvcKZyW57X3feRngqSfOFkdAdcIWrCcwu2W3SMeH 2kalsU/xYLqea+HSzWN2ERGQYCl4uHP1WRvEhxNlRUNQgtOsSKiBk0XbcMBjRgeb7Q8h 8WBhSBAcrdDGQzmlgj7bDxrWxjJxziYZj2nU0IFbTw5yOp55BS0JRSTM08JvT61qfcZK zPB7AM5ZS1KRUlKN1VqnsAPz5aprRCIF6nxurBdUXJqH1XgCltWMVGadY4c+S4bmw9nG Yl2GYuCV9k9Hx6TCBplbBxLYzSU/BZYzFEKcWFO5Qc4nHNRE3Nunzp3Q58dz0kwKIL5X q2/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=idDue3+0; 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 e6si280355pfg.279.2018.02.21.11.05.08; Wed, 21 Feb 2018 11:05:22 -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=idDue3+0; 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 S936846AbeBUQle (ORCPT + 99 others); Wed, 21 Feb 2018 11:41:34 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:47034 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbeBUQlc (ORCPT ); Wed, 21 Feb 2018 11:41:32 -0500 Received: by mail-lf0-f67.google.com with SMTP id r80so3247651lfe.13; Wed, 21 Feb 2018 08:41:31 -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=SagbDxZqFbGTvy7PvtODUojYkZCiQqHLmTZSDdnDfwk=; b=idDue3+0yajL/Kjld9ibxtu/Xn3phidfp++wwqWYPbT//Pukep2dkk2ZxPLk+hQ6b7 CB+TSmndLc2TUYur5p7585x2thNP9+UBssRkwaTVui3TsTmqyAu1XXseWgeXoYTiTPv7 fAIcWi10gjb13vlaC1LmK6S6GHhGSh4ATop7LQEYXYLQL+GFr+AaaUKCCOA0TpZgFigN BlJTiGbjSl3NJnUIBnq9p9g0iqgs8/r07/UngjRkygtEcsKdajx9dLICDyVtuwZWiIk9 4ez6mZrdtu6HR5Iuxg+vtXS48/p/KNguIfHIU6CpCPf85NHdy6FbaBJ5K8hASsD/sizi SNMQ== 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=SagbDxZqFbGTvy7PvtODUojYkZCiQqHLmTZSDdnDfwk=; b=XUnDGbmZ86+xudKMZn5W50FLAuN0ctESdFiIk9CD3G7RDBIWNixjJVBeGfwFTXZFk1 ysphM5fgQ7CXAHkLUeG21Bz0y9E0l6/9k7fnyTK8Y4vxLnQMz8k/n8UuXmG7zJiT4GcM IunQnhkhUKSsIEirScWdStm8RATbheU0NUXC76m4oZPIvZMgJu7SnR908atZV2jocuM6 +6AA0EbUdBb5FXjghKTzCZCYXTujPybZJJuJBNf5qNpjitZwJsxapEYwa37DUkhnWd3L l2jhLnor4AnU2QoZ8X8QpNtRZZ0kQt5Zj/aMJ6OexrB2sXx3rnWVV6KDPynlYoXDlO9m 1+gg== X-Gm-Message-State: APf1xPDvyiVc50yPD7rxnYx9F4cO5Ljsao7k5pNmmIm1oU5NV1PPLeF6 WKLUsqlswNBOdVQFD5+yuPo= X-Received: by 10.46.83.67 with SMTP id t3mr558227ljd.63.1519231290931; Wed, 21 Feb 2018 08:41:30 -0800 (PST) Received: from huvuddator (ua-213-113-106-221.cust.bredbandsbolaget.se. [213.113.106.221]) by smtp.gmail.com with ESMTPSA id o77sm1417249lja.43.2018.02.21.08.41.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2018 08:41:30 -0800 (PST) Date: Wed, 21 Feb 2018 17:41:18 +0100 From: Ulf Magnusson To: Masahiro Yamada Cc: Linus Torvalds , Linux Kbuild mailing list , Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Sam Ravnborg , Michal Marek , Linux Kernel Mailing List Subject: Re: [PATCH 11/23] kconfig: add 'shell-stdout' function Message-ID: <20180221164118.4jwjg6npbqt6xfms@huvuddator> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> <1518806331-7101-12-git-send-email-yamada.masahiro@socionext.com> <20180219044845.7cnqpgyiinn6hkyb@huvuddator> 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 Wed, Feb 21, 2018 at 01:59:59PM +0900, Masahiro Yamada wrote: > 2018-02-20 3:01 GMT+09:00 Linus Torvalds : > > On Mon, Feb 19, 2018 at 9:44 AM, Linus Torvalds > > wrote: > >> > >> I do like your "success"/"stdout" more than "shell"/"shell-stdout", > >> because with that naming I don't get the feeling that one should > >> subsume the other. > > > > Hmm. Thinking about it some more, I really would prefer just "$(shell > > ...)" everywhere. > > > > But it would be nice if perhaps the error handling would match the > > context somehow. > > > > I'm wondering if this might tie into the whole quoting discussion in > > the other thread. > > > > Because the rule could be: > > > > (a) unquoted $(shell ) is a bool, and failing is ok (and turns into > > y/n depending on whether successful or failing) > > > > So > > > > config CC_IS_GCC > > bool > > default $(shell $CC --version | grep -q gcc) > > > > works automatically. > > > > (b) but with quoting, $(shell ) is a string, and failing is an error > > > > So > > > > config GCC_VERSION > > int > > default "$(shell-stdout $srctree/scripts/gcc-version.sh $CC > > | sed 's/^0*//')" if CC_IS_GCC > > default 0 > > > > would need those quotes, and if the shell-script returns a failure, > > we'd _abort_. > > > GCC_VERSION is int type. > > Setting aside the Kconfig internal, I prefer 50700 to "50700" > > According to my common sense, I do not want to quote integers. Yeah, definitely looks a bit weird coming from other languages. "" just means constant (a literal value, implemented as a constant symbol, as opposed to a symbol reference). If I were to redesign things, something like this would be closer to what people intuitively expect: - n, m, y produces three predefined tristate symbols (they already do, through the n/m/y -> "n"/"m"/"y" shorthand) - "foo" produces a symbol of type string. Get rid of "n", "m", "y" (would require cleanup in Kconfig files). - 123 produces a symbol of type int - 0x123 produces a symbol of type hex - Everything else is a symbol reference A nice side effect would be making all undefined symbol references just that. I think that might come in handy. Some simple type checking could be added to expressions as well. You could also get rid of the obscure "undefined symbols produce their name as their string value" magic at that point if you wanted to. That's what makes 123 work currently. One thing that gets a bit icky is that Kconfig currently stores constant symbols in the symbol table, meaning "123" as a string might clash with 123 as an int, if you use the string value as the key (this would be a problem if you want to give them the proper type). I wonder if there's even any point to storing constant symbols in the symbol table though, as opposed to just having them appear in expressions. > IMO, I prefer to use different names for different purpose. > So, 'stdout' and 'success' look good to me. > > > > BTW, I noticed just one built-in function is enough > because 'success' can be derived from 'stdout'. > > > So, my plan is, implement $(shell ...) as a built-in function. > This returns the stdout from the command. > > > Then, implement 'success' as a textual shorthand > by using macro, like this: > > macro success $(shell ($(1) && echo y) || echo n) > > > macro can be expanded recursively, so cc-option > can be implemented based on 'success' macro. Was worried about the error handling for a second there, but this looks like it might work out pretty nicely. $(success) would never have non-0 exit status, so you could still warn for that in $(shell). There's also the question of shared Windows/Linux support in other projects that use Kconfig, though my feeling is kernel devs don't care. Might be pretty easy to work around anyway, by source'ing a different Kconfig file with macro definitions depending on the OS. Would need that for more complicated stuff anyway. Cheers, Ulf