Received: by 10.213.65.68 with SMTP id h4csp864107imn; Tue, 27 Mar 2018 10:09:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/e2Tknx8pVKOOxAE1eCGwNY7h741Cr38Piav7ygCLurmVPXkLmAnozRJgVInSP29939qde X-Received: by 10.98.178.29 with SMTP id x29mr152413pfe.44.1522170592163; Tue, 27 Mar 2018 10:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522170592; cv=none; d=google.com; s=arc-20160816; b=GWw/2ibADsrt47GltaXC1QcCymh4yxEPx6he2A3cTvkUYbYlHSwI3A7x094ndUvLsD 0XSaCRRbrjGq/HbqiBEPi8UQOgLNwsMwoylj6VLCEhUvF/vlV4p/wOLNTo0BMUsElpkx cPNIUkUIo04ovWYEhXwRxWDQiLAXbeS0th01DxPLSopsRF2Iwi78LIET2BdCqK2AEGjz WanFn4gJwAY2ha2gTP9ETfmvUq5cYGEhg2VwIG/KPt9a57MwpFewEkXS4UpecJnk0lK/ IqQ2XT9MJResbPSdGyrp8+n+CNrwfhSGST65W9sjTXgfpSgfDutH8pF9JqostiFAPP3F Vq6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=uN5xiltM1nI3XEn4SrAVEbRPsKduyLYF2eSb69kg3PA=; b=s7793TnG2ueF0Gr10zer7iN/HIsujSb0Z/CiLxKhWat+NUe/vs21DsqnqBzBcuz2qm DiNGNzhlDN1MwkdetW41ffy2CjmQ2X7lHgclk4RM5WgO0n11NpzNXQikmsEKvstyyWPO FpTDaY5SMx99+ky7wLowCyph7E1lmhN05lBBHWgRkM+sxBSZEw/L8ALWhBvhOvS4SF+T UWpDQhPv3NzBHOMcInCS6jJY2uy8zIcFqo4896jygdbvVD2qSyAONbJZ1SntwXHKN6yR DciXNkovK/ZFYNcybyWMhKxDK87pr916kZ0SyeX8lOuQlJSlNGcBcOb1texYwscsfvFU s3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Iqlkfpm3; 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 t10-v6si1643284plh.231.2018.03.27.10.09.14; Tue, 27 Mar 2018 10:09:52 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=Iqlkfpm3; 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 S1753718AbeC0RHT (ORCPT + 99 others); Tue, 27 Mar 2018 13:07:19 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:29808 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755395AbeC0QkR (ORCPT ); Tue, 27 Mar 2018 12:40:17 -0400 Received: from mail-ua0-f174.google.com (mail-ua0-f174.google.com [209.85.217.174]) (authenticated) by conssluserg-05.nifty.com with ESMTP id w2RGdsNf009471; Wed, 28 Mar 2018 01:39:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com w2RGdsNf009471 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1522168795; bh=uN5xiltM1nI3XEn4SrAVEbRPsKduyLYF2eSb69kg3PA=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Iqlkfpm3FxUOIZmVYPi/31kh9kqjHS9DLeMaie1+hsgnmu7/Be5ntMG8Z6/6x+q4S a5hedRz5RkQZkaXrxrYdZ2JAmepge3VpHihG4vG2EynU/1JY+StqWCpCiZeTizLM53 w6jEcaRbgHFrSaM8btzQpHbLo++NWUC/dez7qKJGYPaK53ZBUwPHdRFg4ln7Fn6Orc HqgkE4n3souH1fuH3lsdOzeHLu0qIyI13KrqxeGgwgzgEG0FDrIBN+M57zutswUm05 F83oaUjXGHIjDPTWHvpue//T1FMeMmANAQfpkK5F6t7HoqLz1RJ1EyZd2VZ2JAIIy9 kcZAhMozXXbeA== X-Nifty-SrcIP: [209.85.217.174] Received: by mail-ua0-f174.google.com with SMTP id s92so14723898uas.11; Tue, 27 Mar 2018 09:39:54 -0700 (PDT) X-Gm-Message-State: ALQs6tDu/FJCfJBJjPFeVcWxHXXV2y0Ruu0V08ou32PDqhArg5I1VWzg dH5PoeR1j9tUch/Has+4dB15ZbUCCBHnUSbmD98= X-Received: by 10.176.49.19 with SMTP id e19mr30688ual.141.1522168793719; Tue, 27 Mar 2018 09:39:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.29.150 with HTTP; Tue, 27 Mar 2018 09:39:13 -0700 (PDT) In-Reply-To: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> References: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> From: Masahiro Yamada Date: Wed, 28 Mar 2018 01:39:13 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 00/21] kconfig: move compiler capability tests to Kconfig To: Linux Kbuild mailing list Cc: Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Ulf Magnusson , Kees Cook , Thomas Gleixner , Greg Kroah-Hartman , Randy Dunlap , "Luis R . Rodriguez" , Nicolas Pitre , Masahiro Yamada , Peter Oberparleiter , Kernel Hardening , Linux Kernel Mailing List , Ingo Molnar , Will Deacon , Catalin Marinas , Emese Revfy , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-27 14:29 GMT+09:00 Masahiro Yamada : > > Here is v2 to start to move compiler capability tests to Kconfig. > > V1: > https://lkml.org/lkml/2018/2/16/610 > > I brushed up the implementation even more. > > Major changes for v2: > [1] Environments and functions are expanded in the lexer (zconf.l) > The parser (zconf.y) receives expanded tokens. This simplifies > the implementation. > > [2] Implement only one built-in function 'shell'. This returns > stdout from the command. We need something to return 'y' or 'n'. > This is now implemented as a macro 'success'. > > [3] Macros (user-defined function) are defined by 'macro' keyword > instead of string type symbol. > > ex1) macro success $(shell ($(1) && echo y) || echo n) > ex2) macro cc-option $(success $CC -Werror $(1) -c -x c /dev/null -o /dev/null) > > My plan for v3 > -------------- > > The MW is approaching, but I'd like to make it more lovely if > I have some time. > > While I was writing these patches, I noticed a kind of similarity > between Makefile and Kconfig. > > Makefile can define variables and functions to do text processing > during the parse phase. After parsing, it builds up dependency > graph, and moves on to the execution phase. Then, it generates > objects as needed by checking time-stamps. > > [Makefile] > > OBJ := foo.o > SRC := foo.c > CC := gcc > > $(OBJ): $(SRC) > $(CC) -c -o $(OBJ) $(SRC) > > [Makefile after text processing] > > foo.o: foo.c > gcc -c -o foo.o foo.c > > Now, we are adding tools for text processing to Kconfig. Functions > are statically expanded by the lexer. After all source files are > parsed, Kconfig moves on to the evaluation phase. Then, users can > tweak symbol values from menus. > > So, we should be able to describe Kconfig like follows: > > [Kconfig] > > MY_SYMBOL := CC_STACKPROTECTOR > MY_PROMPT := "Stackprotector" > success = $(shell ($(1) && echo y) || echo n) > cc-option = $(success $CC -Werror $(1) -c -x c /dev/null -o /dev/null) > > config $(MY_SYMBOL) > bool $(MY_PROMPT) > depends on $(cc-option -fstack-protector) > > [Kconfig after text processing] > > config CC_STACKPROTECTOR > bool "Stackptector" > depends on y > > So, I think it is better to use '=' assignment for defining functions. > I will remove the 'macro' keyword. > Also, support variables. A variable is a function with no argument. > So, it will be easy to implement it as a sub-set of function feature. > It is better to support two flavors of assignments, '=' and ':=' as well. > > Masahiro Yamada (21): > kbuild: remove kbuild cache > kbuild: remove CONFIG_CROSS_COMPILE support > kconfig: move and rename sym_expand_string_value() > kconfig: reference environments directly and remove 'option env=' > syntax > kconfig: remove string expansion in file_lookup() > kconfig: remove string expansion for mainmenu after yyparse() > kconfig: add function support and implement 'shell' function > kconfig: replace $UNAME_RELEASE with function call > kconfig: add 'macro' keyword to support user-defined function > kconfig: add 'success' and 'cc-option' macros > stack-protector: test compiler capability in Kconfig and drop AUTO > mode > kconfig: show compiler version text in the top comment > kconfig: add CC_IS_GCC and GCC_VERSION > kconfig: add CC_IS_CLANG and CLANG_VERSION > gcov: remove CONFIG_GCOV_FORMAT_AUTODETECT > kcov: imply GCC_PLUGINS and GCC_PLUGIN_SANCOV instead of select'ing > them > gcc-plugins: always build plugins with C++ > gcc-plugins: move GCC version check for PowerPC to Kconfig > gcc-plugins: test GCC plugin support in Kconfig > gcc-plugins: enable GCC_PLUGINS for COMPILE_TEST > arm64: move GCC version check for ARCH_SUPPORTS_INT128 to Kconfig > > Documentation/kbuild/kconfig-language.txt | 8 -- > Kconfig | 4 +- > Makefile | 103 ++------------ > arch/Kconfig | 37 ++--- > arch/arm64/Kconfig | 1 + > arch/arm64/Makefile | 2 - > arch/powerpc/Kconfig | 2 +- > arch/sh/Kconfig | 4 +- > arch/sparc/Kconfig | 4 +- > arch/tile/Kconfig | 2 +- > arch/um/Kconfig.common | 4 - > arch/x86/Kconfig | 12 +- > arch/x86/um/Kconfig | 4 +- > init/Kconfig | 44 +++--- > kernel/gcov/Kconfig | 17 +-- > kernel/gcov/Makefile | 2 - > lib/Kconfig.debug | 7 +- > scripts/Kbuild.include | 101 ++------------ > scripts/Makefile.gcc-plugins | 95 ++++--------- > scripts/clang-version.sh | 24 ++-- > scripts/gcc-plugin.sh | 37 +---- > scripts/gcc-plugins/Makefile | 15 +- > scripts/gcc-x86_32-has-stack-protector.sh | 7 +- > scripts/gcc-x86_64-has-stack-protector.sh | 5 - > scripts/kconfig/confdata.c | 31 +--- > scripts/kconfig/env.c | 95 +++++++++++++ > scripts/kconfig/function.c | 225 ++++++++++++++++++++++++++++++ > scripts/kconfig/kconf_id.c | 1 - > scripts/kconfig/lkc.h | 9 +- > scripts/kconfig/lkc_proto.h | 7 +- > scripts/kconfig/menu.c | 3 - > scripts/kconfig/symbol.c | 109 --------------- > scripts/kconfig/util.c | 96 ++++++++++--- > scripts/kconfig/zconf.l | 51 ++++++- > scripts/kconfig/zconf.y | 35 ++--- > 35 files changed, 608 insertions(+), 595 deletions(-) > create mode 100644 scripts/kconfig/env.c > create mode 100644 scripts/kconfig/function.c > > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html For convenience, the whole of this series is available at the following branch. git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kconfig-shell-v2 -- Best Regards Masahiro Yamada