lkml.org 
[lkml]   [2021]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v7 1/7] kbuild: bring back tristate.conf
Date
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
\
 
 \ /
  Last update: 2021-12-16 21:20    [W:0.284 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site