From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C71B7C433EF for ; Mon, 27 Sep 2021 16:51:32 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D155A604DC for ; Mon, 27 Sep 2021 16:51:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D155A604DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EB76581761; Mon, 27 Sep 2021 18:51:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="Wv9/n0+w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1EDC81761; Mon, 27 Sep 2021 18:51:27 +0200 (CEST) Received: from conssluserg-01.nifty.com (conssluserg-01.nifty.com [210.131.2.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A4AE382952 for ; Mon, 27 Sep 2021 18:51:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masahiroy@kernel.org Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 18RGp75L024641 for ; Tue, 28 Sep 2021 01:51:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 18RGp75L024641 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1632761467; bh=UG5Nt27TYCIWtealq0+P57FA4ApyuTP8LDmMUXvpOuc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Wv9/n0+w6SH9/cYF6oFid9ScExS3qfgwUvkTV2MCPUjr/+UGCx7pm3kI4l6Ucvv/k 8gmEwmAw9Hnrb5QAC4SomQ2AOlnbK8+SIyGF/g082Cf3PJ1yM78LRT37xQ50E0FL6Q s/KluhV5rf7aSCwhmHEYPKJ6N2y/6YNtCtEAh1pjKGXI5sIOfv0La+48bunbdlJzzn UNypAIoI/ZsQR0CytlubaKd8VqkHxOW36rcQCNin4QYjZ7du7y3uFKccsRuLj5/6iW dMZVpuueDBlLFVu1sPthEETJv26e/Z2pL9t0xzX0FNsTFlBpwW/JPWl0BwlMLjalO0 5tBMYzT4XZQzQ== X-Nifty-SrcIP: [209.85.216.53] Received: by mail-pj1-f53.google.com with SMTP id il14-20020a17090b164e00b0019c7a7c362dso333018pjb.0 for ; Mon, 27 Sep 2021 09:51:07 -0700 (PDT) X-Gm-Message-State: AOAM5316SLliKsQk3BhdiSTuTrTrVeFeRzaet8MuBPXBooWpFR1DsgtP P3Pg1vXpjZnONqs5lg6UeA3leAUON7zDXdEEHlA= X-Google-Smtp-Source: ABdhPJysZyRS4hdG4t78znUN6oVQpap2EBl3i1C6BZbf/stQppKseWuwtAa4hdQ/SJogMysB6kzdwMrwfdbmqaTBNtA= X-Received: by 2002:a17:90a:4305:: with SMTP id q5mr46262pjg.119.1632761466327; Mon, 27 Sep 2021 09:51:06 -0700 (PDT) MIME-Version: 1.0 References: <20210926014342.127913-1-sjg@chromium.org> <20210926014342.127913-3-sjg@chromium.org> In-Reply-To: From: Masahiro Yamada Date: Tue, 28 Sep 2021 01:50:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 02/29] kconfig: Add tools support to CONFIG_IS_ENABLED() To: "Alex G." Cc: Simon Glass , U-Boot Mailing List , Andre Przywara , Rasmus Villemoes , Robert Marko , Tom Rini Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Sep 28, 2021 at 1:11 AM Alex G. wrote: > > > > On 9/25/21 8:43 PM, Simon Glass wrote: > > At present we must separately test for the host build for many options, > > since we force them to be enabled. For example, CONFIG_FIT is always > > enabled in the host tools, even if CONFIG_FIT is not enabled by the > > board itself. > > > > It would be more convenient if we could use, for example, > > CONFIG_IS_ENABLED(FIT) and get CONFIG_HOST_FIT, when building for the > > host. Add support for this. > > > > With this and the tools_build() function, we should be able to remove all > > the #ifdefs currently needed in code that is build by tools and targets. > > > > This will be even nicer when we move to using CONFIG(xxx) everywhere, > > since all the #ifdef and IS_ENABLED/CONFIG_IS_ENABLED stuff will go away. > > > > Signed-off-by: Simon Glass > > Suggested-by: Rasmus Villemoes # b4f73886 > > --- > > In my vision, the host tools are target-agostic. They always support the > same feature set: all features. From that point of view, it doesn't make > sense to have options which enable or disable tools features. Agree. Host tools should not depend on any CONFIG option. In Linux kernel, most host tools are target-agnostic. (It is true there are some exceptions such as objtool, modpost, etc. but in theory we can make all of them target-agnostic) In fact, U-Boot made much more tools target-dependent. They must be rebuilt every time you change the configuration. For example, mkimage in U-Boot supports many boards and depends on the configuration. It makes less sense to support all sort of board-specific firmware in a huge single host tool. In contrast, Barebox splits it into small programs, zynq_mkimage, socfpga_mkimage, etc., each of which is target-agnostic. [1] Makefile decides only whether each program should be built or not. [1] https://github.com/saschahauer/barebox/blob/v2021.07.0/scripts/Makefile#L22 > > I understand the motivation is to use CONFIG_IS_ENABLED(), which has the > appearance of making the code cleaner. We have to continue using #if > CONFIG_IS_ENABLED() -- is that an improvement over old-school #ifdefs? > > So I question whether this new direction makes sense for the long term, > as opposed to taking a deeper look at the underlying code. The polite > thing from me would be to propose alternatives, which I don't have the > bandwidth these days. I won't be adding opposition to this series other > than these final thoughts. We can fix the code later, and then remove > the HOST configs. > > Alex > > > > > Changes in v5: > > - Update commit message > > - Use TOOLS_ instead of HOST_ > > > > Changes in v2: > > - Correct comment about USE_HOSTCC being undefined in CONFIG_VAL() > > - Fix up comment to put an underscore after every CONFIG > > > > include/linux/kconfig.h | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h > > index d109ed3119e..a1d1a298426 100644 > > --- a/include/linux/kconfig.h > > +++ b/include/linux/kconfig.h > > @@ -31,11 +31,14 @@ > > (config_enabled(option)) > > > > /* > > - * U-Boot add-on: Helper macros to reference to different macros > > - * (CONFIG_ or CONFIG_SPL_ prefixed), depending on the build context. > > + * U-Boot add-on: Helper macros to reference to different macros (prefixed by > > + * CONFIG_, CONFIG_SPL_, CONFIG_TPL_ or CONFIG_TOOLS_), depending on the build > > + * context. > > */ > > > > -#if defined(CONFIG_TPL_BUILD) > > +#ifdef USE_HOSTCC > > +#define _CONFIG_PREFIX TOOLS_ > > +#elif defined(CONFIG_TPL_BUILD) > > #define _CONFIG_PREFIX TPL_ > > #elif defined(CONFIG_SPL_BUILD) > > #define _CONFIG_PREFIX SPL_ > > @@ -49,6 +52,7 @@ > > > > /* > > * CONFIG_VAL(FOO) evaluates to the value of > > + * CONFIG_TOOLS_FOO if USE_HOSTCC is defined, > > * CONFIG_FOO if CONFIG_SPL_BUILD is undefined, > > * CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. > > * CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined. > > @@ -76,18 +80,21 @@ > > > > /* > > * CONFIG_IS_ENABLED(FOO) expands to > > + * 1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', > > * 1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', > > * 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', > > * 1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', > > * 0 otherwise. > > * > > * CONFIG_IS_ENABLED(FOO, (abc)) expands to > > + * abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', > > * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', > > * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', > > * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', > > * nothing otherwise. > > * > > * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to > > + * abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', > > * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', > > * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', > > * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', > > -- Best Regards Masahiro Yamada