All of 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, akpm@linux-foundation.org, eugene.loh@oracle.com,
	kris.van.hees@oracle.com
Subject: [PATCH v7 1/7] kbuild: bring back tristate.conf
Date: Thu, 16 Dec 2021 20:19:13 +0000	[thread overview]
Message-ID: <20211216201919.234994-2-nick.alcock@oracle.com> (raw)
In-Reply-To: <20211216201919.234994-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.  (Thanks to the refactoring in
the 5.16 timeframe, this is basically a reimplementation of commit
8b41fc4454e36fbfdbb23f940d023d4dece2de29 rather than a simple
reversion.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
---

Notes:
    v7: rewrite in terms of the new confdata refactoring

 Documentation/kbuild/kconfig.rst |  5 +++++
 Makefile                         |  2 +-
 scripts/kconfig/confdata.c       | 36 +++++++++++++++++++++++++++-----
 3 files changed, 37 insertions(+), 6 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 765115c99655..879066d1af4b 100644
--- a/Makefile
+++ b/Makefile
@@ -727,7 +727,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 42bc56ee238c..1d30faff6984 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -216,6 +216,13 @@ static const char *conf_get_autoheader_name(void)
 	return name ? name : "include/generated/autoconf.h";
 }
 
+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;
@@ -666,7 +673,8 @@ static char *escape_string_value(const char *in)
 enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
 
 static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
-			   bool escape_string)
+			   bool escape_string, bool upcase_string,
+			   bool tristate_only)
 {
 	const char *val;
 	char *escaped = NULL;
@@ -674,6 +682,9 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 	if (sym->type == S_UNKNOWN)
 		return;
 
+	if (sym->type != S_TRISTATE && tristate_only)
+		return;
+
 	val = sym_get_string_value(sym);
 
 	if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) &&
@@ -688,24 +699,32 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 		val = escaped;
 	}
 
-	fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val);
+	if (upcase_string)
+		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, true, false, false);
 }
 
 static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
 {
-	__print_symbol(fp, sym, OUTPUT_N_NONE, true);
+	__print_symbol(fp, sym, OUTPUT_N_NONE, true, false, false);
+}
+
+static void print_symbol_for_tristate(FILE *fp, struct symbol *sym)
+{
+	__print_symbol(fp, sym, OUTPUT_N_NONE, true, true, true);
 }
 
 void print_symbol_for_listconfig(struct symbol *sym)
 {
-	__print_symbol(stdout, sym, OUTPUT_N, true);
+	__print_symbol(stdout, sym, OUTPUT_N, true, false, false);
 }
 
 static void print_symbol_for_c(FILE *fp, struct symbol *sym)
@@ -1129,6 +1148,13 @@ 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.34.0.258.gc900572c39


  reply	other threads:[~2021-12-16 20:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 20:19 [PING PATCH v7] kallsyms: new /proc/kallmodsyms with builtin modules Nick Alcock
2021-12-16 20:19 ` Nick Alcock [this message]
2021-12-16 20:19 ` [PATCH v7 2/7] kbuild: add modules_thick.builtin Nick Alcock
2021-12-16 20:19 ` [PATCH v7 3/7] kbuild: generate an address ranges map at vmlinux link time Nick Alcock
2021-12-16 20:19 ` [PATCH v7 4/7] kallsyms: introduce sections needed to map symbols to built-in modules Nick Alcock
2021-12-16 20:19 ` [PATCH v7 5/7] kallsyms: optimize .kallsyms_modules* Nick Alcock
2021-12-16 20:19 ` [PATCH v7 6/7] kallsyms: add /proc/kallmodsyms Nick Alcock
2021-12-17 17:00   ` kernel test robot
2021-12-17 17:00     ` kernel test robot
2021-12-16 20:19 ` [PATCH v7 7/7] kallsyms: add reliable symbol size info Nick Alcock
2021-12-19 14:05   ` [kallsyms] a42fff4e29: leaking-addresses.proc.kallmodsyms.0T_stext kernel test robot
2021-12-19 14:05     ` kernel test robot
2022-01-12 16:30 ` [PING PATCH v7] kallsyms: new /proc/kallmodsyms with builtin modules Luis Chamberlain
2022-01-12 16:59   ` Nick Alcock
2022-02-02  3:09     ` Luis Chamberlain
2022-02-02  3:39       ` Kris Van Hees
2022-02-02 18:10       ` Daniel Xu
2022-02-03 14:11         ` Nick Alcock
2022-02-02 18:37       ` Jiri Olsa

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=20211216201919.234994-2-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=akpm@linux-foundation.org \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.