]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
kconfig: allow all config targets to write auto.conf if missing
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 20 Jul 2018 07:46:31 +0000 (16:46 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 25 Jul 2018 14:25:30 +0000 (23:25 +0900)
Currently, only syncconfig creates or updates include/config/auto.conf
and some other files.  Other config targets create or update only the
.config file.

When you configure and build the kernel from a pristine source tree,
any config target is followed by syncconfig in the build stage since
include/config/auto.conf is missing.

We are moving compiler tests from Makefile to Kconfig.  It means that
parsing Kconfig files will be more costly since Kconfig invokes the
compiler commands internally.  Thus, we want to avoid invoking Kconfig
twice (one for *config to create the .config, and one for syncconfig
to synchronize the auto.conf).  If auto.conf does not exist, we can
generate all configuration files in the first configuration stage,
which will save the syncconfig in the build stage.

Please note this should be done only when auto.conf is missing.  If
*config blindly did this, time stamp files under include/config/ would
be unnecessarily touched, triggering unneeded rebuild of objects.

I assume a scenario like this:

 1. You have a source tree that has already been built
    with CONFIG_FOO disabled

 2. Run "make menuconfig" to enable CONFIG_FOO

 3. CONFIG_FOO turns out to be unnecessary.
    Run "make menuconfig" again to disable CONFIG_FOO

 4. Run "make"

In this case, include/config/foo.h should not be touched since there
is no change in CONFIG_FOO.  The sync process should be delayed until
the user really attempts to build the kernel.

This commit has another motivation; I want to suppress the 'No such
file or directory' warning from the 'include' directive.

The top-level Makefile includes auto.conf with '-include' directive,
like this:

  ifeq ($(dot-config),1)
  -include include/config/auto.conf
  endif

This looks strange because auto.conf is mandatory when dot-config is 1.
I guess only the reason of using '-include' is to suppress the warning
'include/config/auto.conf: No such file or directory' when building
from a clean tree.  However, this has a side-effect; Make considers
the files included by '-include' are optional.  Hence, Make continues
to build even if it fails to generate include/config/auto.conf.  I will
change this in the next commit, but the warning message is annoying.
(At least, kbuild test robot reports it as a regression.)

With this commit, Kconfig will generate all configuration files together
with the .config and I guess it is a solution good enough to suppress
the warning.

Note:
GNU Make 4.2 or later does not display the warning from the 'include'
directive if include files are successfully generated.  See GNU Make
commit 87a5f98d248f ("[SV 102] Don't show unnecessary include file
errors.")  However, older GNU Make versions are still widely used.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/gconf.c
scripts/kconfig/lkc_proto.h
scripts/kconfig/mconf.c
scripts/kconfig/nconf.c
scripts/kconfig/qconf.cc

index 5af899112cae3208108d14cd36dff0fb50f710aa..b35cc93039791a1383e3d0d790ff7837be569a7d 100644 (file)
@@ -686,29 +686,32 @@ int main(int ac, char **av)
                break;
        }
 
-       if (sync_kconfig) {
-               /* syncconfig is used during the build so we shall update autoconf.
-                * All other commands are only used to generate a config.
-                */
-               if (!no_conf_write && conf_write(NULL)) {
-                       fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
-                       exit(1);
-               }
-               if (conf_write_autoconf()) {
-                       fprintf(stderr, "\n*** Error during update of the configuration.\n\n");
-                       return 1;
-               }
-       } else if (input_mode == savedefconfig) {
+       if (input_mode == savedefconfig) {
                if (conf_write_defconfig(defconfig_file)) {
                        fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
                                defconfig_file);
                        return 1;
                }
        } else if (input_mode != listnewconfig) {
-               if (conf_write(NULL)) {
+               if (!no_conf_write && conf_write(NULL)) {
                        fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
                        exit(1);
                }
+
+               /*
+                * Create auto.conf if it does not exist.
+                * This prevents GNU Make 4.1 or older from emitting
+                * "include/config/auto.conf: No such file or directory"
+                * in the top-level Makefile
+                *
+                * syncconfig always creates or updates auto.conf because it is
+                * used during the build.
+                */
+               if (conf_write_autoconf(sync_kconfig) && sync_kconfig) {
+                       fprintf(stderr,
+                               "\n*** Error during sync of the configuration.\n\n");
+                       return 1;
+               }
        }
        return 0;
 }
index fad403dfa5085e60e048cc4d35d0b6dcf4f3cd1d..91d0a5c014acd3a17cecad8f486ff90f59e1211c 100644 (file)
@@ -1013,13 +1013,17 @@ static int conf_split_config(void)
        return res;
 }
 
-int conf_write_autoconf(void)
+int conf_write_autoconf(int overwrite)
 {
        struct symbol *sym;
        const char *name;
+       const char *autoconf_name = conf_get_autoconfig_name();
        FILE *out, *tristate, *out_h;
        int i;
 
+       if (!overwrite && is_present(autoconf_name))
+               return 0;
+
        sym_clear_all_valid();
 
        conf_write_dep("include/config/auto.conf.cmd");
@@ -1082,14 +1086,13 @@ int conf_write_autoconf(void)
        if (rename(".tmpconfig_tristate", name))
                return 1;
 
-       name = conf_get_autoconfig_name();
-       if (make_parent_dir(name))
+       if (make_parent_dir(autoconf_name))
                return 1;
        /*
         * This must be the last step, kbuild has a dependency on auto.conf
         * and this marks the successful completion of the previous steps.
         */
-       if (rename(".tmpconfig", name))
+       if (rename(".tmpconfig", autoconf_name))
                return 1;
 
        return 0;
index a9e48cc7b50a3630e1230d487e513831d65b873f..36f578415c4a64d37128d0a980a80e38c2da0994 100644 (file)
@@ -525,6 +525,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
 {
        if (conf_write(NULL))
                text_insert_msg("Error", "Unable to save configuration !");
+       conf_write_autoconf(0);
 }
 
 
index cf4510a2bdc71e5f91d628d77b2d69b4cc8edb37..86c267540ccc70e74fbb4962210e498aae65766d 100644 (file)
@@ -7,7 +7,7 @@ int conf_read(const char *name);
 int conf_read_simple(const char *name, int);
 int conf_write_defconfig(const char *name);
 int conf_write(const char *name);
-int conf_write_autoconf(void);
+int conf_write_autoconf(int overwrite);
 bool conf_get_changed(void);
 void conf_set_changed_callback(void (*fn)(void));
 void conf_set_message_callback(void (*fn)(const char *s));
index b8f3b607962a930619de150ab51bed0bb44f28e3..83b5836615fb04a9cf389a2c978b75d4f5aa4f50 100644 (file)
@@ -974,6 +974,7 @@ static int handle_exit(void)
                                          "\n\n");
                        return 1;
                }
+               conf_write_autoconf(0);
                /* fall through */
        case -1:
                if (!silent)
index 5cbdb92e11b3b04b855807b263f64c405cf94ee6..1ef232ae5ab9f957972310e40db45f3eaec529a5 100644 (file)
@@ -674,6 +674,7 @@ static int do_exit(void)
                                  "Your configuration changes were NOT saved.",
                                  1,
                                  "<OK>");
+               conf_write_autoconf(0);
                break;
        default:
                btn_dialog(
index ad9c22dd04f5cdbc982bae081d1b938a54d7e5b0..62261b3a13c7be4ca46758cee8ada61c77f6d9c7 100644 (file)
@@ -1535,6 +1535,8 @@ bool ConfigMainWindow::saveConfig(void)
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
                return false;
        }
+       conf_write_autoconf(0);
+
        return true;
 }