linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: mcgrof@kernel.org, masahiroy@kernel.org
Cc: linux-modules@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com,
	kris.van.hees@oracle.com,
	Victor Erminpour <victor.erminpour@oracle.com>
Subject: [PATCH v10 02/13] kbuild: bring back tristate.conf
Date: Mon,  5 Dec 2022 16:31:46 +0000	[thread overview]
Message-ID: <20221205163157.269335-3-nick.alcock@oracle.com> (raw)
In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com>

tristate.conf was dropped because it is not needed to build
modules.builtin any more, and doing so avoids one round of recursion
through the build tree to build it.  But it has one property that can be
obtained in no other way in the current tree: it provides a
machine-readable record of whether a module is tristate or not.
(modules.builtin.objs, just added, uses modinfo, which is recorded in
the source files themselves, but it is Kconfig that actually controls
whether something can be built as a module.)

So bring it back for this purpose.  (Thanks to the refactoring in
the 5.16 timeframe, this is basically a reimplementation of commit
8b41fc4454e36fbfdbb23f940d023d4dece2de29 rather than a simple
reversion.)

A verifier that uses it will be added in the next commit.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Victor Erminpour <victor.erminpour@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
---

Notes:
    v7: rewrite in terms of the new confdata refactoring
    v8: adjust for changes in 5.17 merge window
    v10: commit log revised

 Documentation/kbuild/kconfig.rst |  5 ++++
 Makefile                         |  2 +-
 scripts/kconfig/confdata.c       | 41 +++++++++++++++++++++++++++-----
 3 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/Documentation/kbuild/kconfig.rst b/Documentation/kbuild/kconfig.rst
index 5967c79c3baa..e2c78760d442 100644
--- a/Documentation/kbuild/kconfig.rst
+++ b/Documentation/kbuild/kconfig.rst
@@ -162,6 +162,11 @@ KCONFIG_AUTOCONFIG
 This environment variable can be set to specify the path & name of the
 "auto.conf" file.  Its default value is "include/config/auto.conf".
 
+KCONFIG_TRISTATE
+----------------
+This environment variable can be set to specify the path & name of the
+"tristate.conf" file.  Its default value is "include/config/tristate.conf".
+
 KCONFIG_AUTOHEADER
 ------------------
 This environment variable can be set to specify the path & name of the
diff --git a/Makefile b/Makefile
index 93bfaae45396..248f780cb75b 100644
--- a/Makefile
+++ b/Makefile
@@ -793,7 +793,7 @@ $(KCONFIG_CONFIG):
 #
 # Do not use $(call cmd,...) here. That would suppress prompts from syncconfig,
 # so you cannot notice that Kconfig is waiting for the user input.
-%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg: $(KCONFIG_CONFIG)
+%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg %/tristate.conf: $(KCONFIG_CONFIG)
 	$(Q)$(kecho) "  SYNC    $@"
 	$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
 else # !may-sync-config
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b7c9f1dd5e42..160d12b69957 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -223,6 +223,13 @@ static const char *conf_get_rustccfg_name(void)
 	return name ? name : "include/generated/rustc_cfg";
 }
 
+static const char *conf_get_tristate_name(void)
+{
+	char *name = getenv("KCONFIG_TRISTATE");
+
+	return name ? name : "include/config/tristate.conf";
+}
+
 static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
 {
 	char *p2;
@@ -670,8 +677,12 @@ static char *escape_string_value(const char *in)
 
 enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
 
+#define PRINT_ESCAPE		0x01
+#define PRINT_UPCASE		0x02
+#define PRINT_TRISTATE_ONLY	0x04
+
 static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
-			   bool escape_string)
+			   int flags)
 {
 	const char *val;
 	char *escaped = NULL;
@@ -679,6 +690,9 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 	if (sym->type == S_UNKNOWN)
 		return;
 
+	if (flags & PRINT_TRISTATE_ONLY && sym->type != S_TRISTATE)
+		return;
+
 	val = sym_get_string_value(sym);
 
 	if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) &&
@@ -688,29 +702,38 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 		return;
 	}
 
-	if (sym->type == S_STRING && escape_string) {
+	if (sym->type == S_STRING && flags & PRINT_ESCAPE) {
 		escaped = escape_string_value(val);
 		val = escaped;
 	}
 
-	fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val);
+	if (flags & PRINT_UPCASE)
+		fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*val));
+	else
+		fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val);
 
 	free(escaped);
 }
 
 static void print_symbol_for_dotconfig(FILE *fp, struct symbol *sym)
 {
-	__print_symbol(fp, sym, OUTPUT_N_AS_UNSET, true);
+	__print_symbol(fp, sym, OUTPUT_N_AS_UNSET, PRINT_ESCAPE);
 }
 
 static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
 {
-	__print_symbol(fp, sym, OUTPUT_N_NONE, false);
+	__print_symbol(fp, sym, OUTPUT_N_NONE, 0);
+}
+
+static void print_symbol_for_tristate(FILE *fp, struct symbol *sym)
+{
+	__print_symbol(fp, sym, OUTPUT_N_NONE, PRINT_ESCAPE | PRINT_UPCASE |
+		       PRINT_TRISTATE_ONLY);
 }
 
 void print_symbol_for_listconfig(struct symbol *sym)
 {
-	__print_symbol(stdout, sym, OUTPUT_N, true);
+	__print_symbol(stdout, sym, OUTPUT_N, PRINT_ESCAPE);
 }
 
 static void print_symbol_for_c(FILE *fp, struct symbol *sym)
@@ -1207,6 +1230,12 @@ int conf_write_autoconf(int overwrite)
 	if (ret)
 		return ret;
 
+	ret = __conf_write_autoconf(conf_get_tristate_name(),
+				    print_symbol_for_tristate,
+				    &comment_style_pound);
+	if (ret)
+		return ret;
+
 	/*
 	 * Create include/config/auto.conf. This must be the last step because
 	 * Kbuild has a dependency on auto.conf and this marks the successful
-- 
2.38.0.266.g481848f278


  parent reply	other threads:[~2022-12-05 16:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 16:31 [PATCH modules-next v10 00/13] kallsyms: reliable symbol->address lookup with /proc/kallmodsyms Nick Alcock
2022-12-05 16:31 ` [PATCH v10 01/13] kbuild: add modules.builtin.objs Nick Alcock
2022-12-05 16:31 ` Nick Alcock [this message]
2023-03-05  8:10   ` [PATCH v10 02/13] kbuild: bring back tristate.conf Masahiro Yamada
2022-12-05 16:31 ` [PATCH v10 03/13] kbuild: add tristate checker Nick Alcock
2023-03-05 15:10   ` Masahiro Yamada
2022-12-05 16:31 ` [PATCH v10 04/13] kbuild: fix up substitutions in makefiles to allow for " Nick Alcock
2023-03-05 15:11   ` Masahiro Yamada
2022-12-05 16:31 ` [PATCH v10 05/13] kbuild: remove MODULE_LICENSE/AUTHOR/DESCRIPTION in non-modules Nick Alcock
2022-12-06  9:11   ` Geert Uytterhoeven
2022-12-06 20:03     ` Nick Alcock
2022-12-06 21:02       ` Arnd Bergmann
2022-12-07  5:03         ` Luis Chamberlain
2022-12-07  5:10           ` Luis Chamberlain
2022-12-07  8:21           ` Christoph Hellwig
2023-03-05  8:09           ` Masahiro Yamada
2022-12-05 16:31 ` [PATCH v10 06/13] build: add a simple iterator over modules.builtin.objs Nick Alcock
2022-12-05 16:31 ` [PATCH v10 07/13] kbuild: generate an address ranges map at vmlinux link time Nick Alcock
2022-12-05 16:31 ` [PATCH v10 08/13] kbuild: make address ranges map work with IBT Nick Alcock
2022-12-05 16:31 ` [PATCH v10 09/13] kallsyms: introduce sections needed to map symbols to built-in modules Nick Alcock
2022-12-05 16:31 ` [PATCH v10 10/13] kallsyms: optimize .kallsyms_modules* Nick Alcock
2022-12-05 16:31 ` [PATCH v10 11/13] kallsyms: distinguish text symbols fully using object file names Nick Alcock
2022-12-05 16:31 ` [PATCH v10 12/13] kallsyms: add /proc/kallmodsyms for text symbol disambiguation Nick Alcock
2022-12-05 16:31 ` [PATCH v10 13/13] perf: proof-of-concept kallmodsyms support Nick Alcock
2022-12-16 15:21 ` [PING] [PATCH modules-next v10 00/13] kallsyms: reliable symbol->address lookup with /proc/kallmodsyms Nick Alcock
2023-01-17 19:51 ` Luis Chamberlain
2023-02-09 16:54   ` Nick Alcock
2023-02-09 23:53     ` Nick Alcock
2023-02-21 21:48       ` Luis Chamberlain
2023-02-22 12:08         ` Nick Alcock
2023-02-22 22:25           ` Luis Chamberlain
2023-04-07 23:21 ` Josh Poimboeuf
2023-04-10 13:08   ` Joe Lawrence
2023-04-24 19:47   ` Luis Chamberlain
2023-04-25  8:27     ` Petr Mladek
2023-05-08 22:06 ` Steven Rostedt
2023-05-19 15:50   ` Alexander Lobakin
2023-05-22 23:21     ` Luis Chamberlain
2023-05-24 15:02     ` Nick Alcock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221205163157.269335-3-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=eugene.loh@oracle.com \
    --cc=kris.van.hees@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=victor.erminpour@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).