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@xxxxxxxxxx> --- 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