LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: jeyu@kernel.org, masahiroy@kernel.org
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
	arnd@arndb.de, eugene.loh@oracle.com, kris.van.hees@oracle.com
Subject: [PATCH v5 1/7] kbuild: bring back tristate.conf
Date: Wed, 29 Sep 2021 22:51:48 +0100	[thread overview]
Message-ID: <20210929215154.300692-2-nick.alcock@oracle.com> (raw)
In-Reply-To: <20210929215154.300692-1-nick.alcock@oracle.com>

tristate.conf was dropped because it is not needed to build a
modules.builtin (although dropping it introduces a few false positives
into modules.builtin support), and doing so avoids one round of
recursion through the build tree to build it.  But kallmodsyms support
requires building a mapping from object file name to built-in module
name for all builtin modules: this seems to me impossible to accomplish
without parsing all makefiles under the influence of tristate.conf,
since the makefiles are the only place this mapping is recorded.

So bring it back for this purpose.

This partially reverts commit 8b41fc4454e36fbfdbb23f940d023d4dece2de29.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
---
 Makefile                   |  2 +-
 scripts/kconfig/confdata.c | 41 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 437ccc66a1c2..77062b44a4b5 100644
--- a/Makefile
+++ b/Makefile
@@ -724,7 +724,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: $(KCONFIG_CONFIG)
+%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/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 cf72680cd769..8f4f1b373dd6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -725,6 +725,25 @@ static struct conf_printer header_printer_cb =
 	.print_comment = header_print_comment,
 };
 
+/*
+ * Tristate printer
+ *
+ * This printer is used when generating the `include/config/tristate.conf' file.
+ */
+static void
+tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+       if (sym->type == S_TRISTATE && *value != 'n')
+	       fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
+}
+
+static struct conf_printer tristate_printer_cb =
+{
+       .print_symbol = tristate_print_symbol,
+       .print_comment = kconfig_print_comment,
+};
+
 static void conf_write_symbol(FILE *fp, struct symbol *sym,
 			      struct conf_printer *printer, void *printer_arg)
 {
@@ -1058,7 +1077,7 @@ int conf_write_autoconf(int overwrite)
 	struct symbol *sym;
 	const char *name;
 	const char *autoconf_name = conf_get_autoconfig_name();
-	FILE *out, *out_h;
+	FILE *out, *tristate, *out_h;
 	int i;
 
 	if (!overwrite && is_present(autoconf_name))
@@ -1073,6 +1092,13 @@ int conf_write_autoconf(int overwrite)
 	if (!out)
 		return 1;
 
+	tristate = fopen(".tmpconfig_tristate", "w");
+	if (!tristate) {
+		fclose(out);
+		fclose(tristate);
+		return 1;
+	}
+
 	out_h = fopen(".tmpconfig.h", "w");
 	if (!out_h) {
 		fclose(out);
@@ -1080,6 +1106,7 @@ int conf_write_autoconf(int overwrite)
 	}
 
 	conf_write_heading(out, &kconfig_printer_cb, NULL);
+	conf_write_heading(tristate, &tristate_printer_cb, NULL);
 	conf_write_heading(out_h, &header_printer_cb, NULL);
 
 	for_all_symbols(i, sym) {
@@ -1087,11 +1114,13 @@ int conf_write_autoconf(int overwrite)
 		if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
 			continue;
 
-		/* write symbols to auto.conf and autoconf.h */
+		/* write symbols to auto.conf, tristate and autoconf.h */
 		conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
+		conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
 		conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
 	}
 	fclose(out);
+	fclose(tristate);
 	fclose(out_h);
 
 	name = getenv("KCONFIG_AUTOHEADER");
@@ -1102,6 +1131,14 @@ int conf_write_autoconf(int overwrite)
 	if (rename(".tmpconfig.h", name))
 		return 1;
 
+	name = getenv("KCONFIG_TRISTATE");
+	if (!name)
+		name = "include/config/tristate.conf";
+	if (make_parent_dir(name))
+		return 1;
+	if (rename(".tmpconfig_tristate", name))
+		return 1;
+
 	if (make_parent_dir(autoconf_name))
 		return 1;
 	/*
-- 
2.33.0.256.gb827f06fa9


  reply	other threads:[~2021-09-29 21:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 21:51 [PATCH v5] kallsyms: new /proc/kallmodsyms with builtin modules Nick Alcock
2021-09-29 21:51 ` Nick Alcock [this message]
2021-09-29 21:51 ` [PATCH v5 2/7] kbuild: add modules_thick.builtin Nick Alcock
2021-09-29 21:51 ` [PATCH v5 3/7] kbuild: generate an address ranges map at vmlinux link time Nick Alcock
2021-09-29 21:51 ` [PATCH v5 4/7] kallsyms: introduce sections needed to map symbols to built-in modules Nick Alcock
2021-09-29 21:51 ` [PATCH v5 5/7] kallsyms: optimize .kallsyms_modules* Nick Alcock
2021-09-29 21:51 ` [PATCH v5 6/7] kallsyms: add /proc/kallmodsyms Nick Alcock
2021-09-29 21:51 ` [PATCH v5 7/7] kallsyms: add reliable symbol size info Nick Alcock
2021-09-29 23:34 ` [PATCH v5] kallsyms: new /proc/kallmodsyms with builtin modules Kees Cook
2021-09-30 17:19   ` Nick Alcock
2021-09-30 17:53     ` Kees Cook
2021-10-27 17:46 ` [PING PATCH " Nick Alcock
2021-10-27 17:47   ` [PATCH v5 1/7] kbuild: bring back tristate.conf Nick Alcock
2021-10-27 17:47   ` [PATCH v5 2/7] kbuild: add modules_thick.builtin Nick Alcock
2021-10-27 17:47   ` [PATCH v5 3/7] kbuild: generate an address ranges map at vmlinux link time Nick Alcock
2021-10-30 16:49     ` kernel test robot
2021-10-27 17:47   ` [PATCH v5 4/7] kallsyms: introduce sections needed to map symbols to built-in modules Nick Alcock
2021-10-27 17:47   ` [PATCH v5 5/7] kallsyms: optimize .kallsyms_modules* Nick Alcock
2021-10-27 17:47   ` [PATCH v5 6/7] kallsyms: add /proc/kallmodsyms Nick Alcock
2021-10-28 11:36     ` kernel test robot
2021-10-28 21:52       ` Nick Alcock
2021-10-27 17:47   ` [PATCH v5 7/7] kallsyms: add reliable symbol size info 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=20210929215154.300692-2-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=arnd@arndb.de \
    --cc=eugene.loh@oracle.com \
    --cc=jeyu@kernel.org \
    --cc=kris.van.hees@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --subject='Re: [PATCH v5 1/7] kbuild: bring back tristate.conf' \
    /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

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).