From patchwork Fri Feb 23 11:49:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Magnusson X-Patchwork-Id: 10237481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B10C602A0 for ; Fri, 23 Feb 2018 11:49:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07EF12953E for ; Fri, 23 Feb 2018 11:49:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F06BF29541; Fri, 23 Feb 2018 11:49:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D79B2953E for ; Fri, 23 Feb 2018 11:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273AbeBWLtG (ORCPT ); Fri, 23 Feb 2018 06:49:06 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:39274 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbeBWLtF (ORCPT ); Fri, 23 Feb 2018 06:49:05 -0500 Received: by mail-lf0-f43.google.com with SMTP id f75so6951537lfg.6 for ; Fri, 23 Feb 2018 03:49:04 -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=5clejNAK3lbjV6yIv3VIVI5MIPMzvzt2c6Tl0WUW74g=; b=OCFIn2AvPW5mSNHS+qTd0ICs0hJZb1D/RISdn2Ly8AOf30uiRi6rAi4IKuUp8OJjbg p/CxQVCwuWWTe8LN9utg59bKbwwvcEhAXV9QyV/TvslX/dEWI1FDHL2+Oa8vKYFcANKz rVVwUSWClqJAbQgKLmocAc33mQUW29n3qqhFy167jXBpSw9y4Aqe2cy5DHCAD+rgUASa iHoBPcvF1RFpaK01wBfRaKY9nnQEBUEwXKyKlvFaTjoUrxJUGEXk+qcwwYr18xDwWb0z 9auBpHgusBZgLRmYskg5GYBycyGuu6ZTcekav/UBu2bjEYOZevl/Qbcc5+T4v35ksQdR V/mA== 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=5clejNAK3lbjV6yIv3VIVI5MIPMzvzt2c6Tl0WUW74g=; b=MBGBD5NSkjMCS5CryYbuhkU6tFwLzmN8k2+R1Ig7uxDZ+T5g7d23DNe5cKD6/2coL4 vb/C8G9U+yPjbeARpdnjNKLjMf6l6NGjI4YfD/eWA/pLgEQe6awA35dgk48OSwkmSPYs nLpoO/OPlcyT9S8GOyOnZN//KDaVe/STaLkrf3q1MoBzasaZWqOnZxwz1WkTdS+2H554 FEl2/nNdR0LFZyB16wUOhVHcVUooh4KjPeNdUqXfM6WKsrYI+rRV96qiYsaL242Lkfu9 mXuzw92yOoPO45gJahoVjxBuWhnjM6ZEVfgLDEWDpjz0FEXeRQBgUzYkk8yQMZUqq4GN ahig== X-Gm-Message-State: APf1xPC8GsXczWm33Cnmz5bg8aq7hi4mV/CHnB/UWL4zuhNSl4vUe6qZ ElWzsjqMlzo+oF8EXU/i+Fc= X-Google-Smtp-Source: AG47ELsL3CzlQUPYtzsGqwu5odg701f7vUZRizO5tZo22308nV5QZPUGJOt6ADkxfrgWJpOdc1Ndbg== X-Received: by 10.25.141.147 with SMTP id p141mr1150410lfd.24.1519386544004; Fri, 23 Feb 2018 03:49:04 -0800 (PST) Received: from huvuddator (ua-213-113-106-221.cust.bredbandsbolaget.se. [213.113.106.221]) by smtp.gmail.com with ESMTPSA id 95sm447111lja.20.2018.02.23.03.49.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Feb 2018 03:49:03 -0800 (PST) Date: Fri, 23 Feb 2018 12:49:01 +0100 From: Ulf Magnusson To: Arnd Bergmann Cc: Linux Kbuild mailing list , Masahiro Yamada , Sam Ravnborg Subject: [PATCH v3] kconfig: only write '# CONFIG_FOO is not set' for visible symbols Message-ID: <20180223114901.lg5syy5zrf75mndd@huvuddator> References: <20180223060901.4052-1-ulfalizer@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP === Background === - Visible n-valued bool/tristate symbols generate a '# CONFIG_FOO is not set' line in the .config file. The idea is to remember the user selection without having to set a Makefile variable. Having n correspond to the variable being undefined in the Makefiles makes for easy CONFIG_* tests. - Invisible n-valued bool/tristate symbols normally do not generate a '# CONFIG_FOO is not set' line, because user values from .config files have no effect on invisible symbols anyway. Currently, there is one exception to this rule: Any bool/tristate symbol that gets the value n through a 'default' property generates a '# CONFIG_FOO is not set' line, even if the symbol is invisible. Note that this only applies to explicitly given defaults, and not when the symbol implicitly defaults to n (like bool/tristate symbols without 'default' properties do). This is inconsistent, and seems redundant: - As mentioned, the '# CONFIG_FOO is not set' won't affect the symbol once the .config is read back in. - Even if the symbol is invisible at first but becomes visible later, there shouldn't be any harm in recalculating the default value rather than viewing the '# CONFIG_FOO is not set' as a previous user value of n. === Changes === Change sym_calc_value() to only set SYMBOL_WRITE (write to .config) for non-n-valued 'default' properties. Note that SYMBOL_WRITE is always set for visible symbols regardless of whether they have 'default' properties or not, so this change only affects invisible symbols. This reduces the size of the x86 .config on my system by about 1% (due to removed '# CONFIG_FOO is not set' entries). One side effect of (and the main motivation for) this change is making the following two definitions behave exactly the same: config FOO bool config FOO bool default n With this change, neither of these will generate a '# CONFIG_FOO is not set' line (assuming FOO isn't selected/implied). That might make it clearer to people that a bare 'default n' is redundant. This change only affects generated .config files and not autoconf.h: autoconf.h only includes #defines for non-n bool/tristate symbols. === Testing === The following testing was done with the x86 Kconfigs: - .config files generated before and after the change were compared to verify that the only difference is some '# CONFIG_FOO is not set' entries disappearing. A couple of these were inspected manually, and most turned out to be from redundant 'default n/def_bool n' properties. - The generated include/generated/autoconf.h was compared before and after the change and verified to be identical. - As a sanity check, the same modification was done to Kconfiglib. The Kconfiglib test suite was then run to check for any mismatches against the output of the C implementation. Signed-off-by: Ulf Magnusson --- Changes in v3: Mention that SYMBOL_WRITE is always set for visible symbols. It might look like this change would affect those too otherwise. Changes in v2: Make it more explicit in the commit title and message that only invisible symbols are affected by the change. The previous commit title was "do not write 'n' defaults to .config". scripts/kconfig/symbol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index cca9663be5dd..02eb8b10a83c 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -403,9 +403,10 @@ void sym_calc_value(struct symbol *sym) if (!sym_is_choice(sym)) { prop = sym_get_default_prop(sym); if (prop) { - sym->flags |= SYMBOL_WRITE; newval.tri = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); + if (newval.tri != no) + sym->flags |= SYMBOL_WRITE; } if (sym->implied.tri != no) { sym->flags |= SYMBOL_WRITE;