linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/11] kbuild/kconfig: do not update config during installation
@ 2018-07-20  7:46 Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel


The main motivation of this patch series is to suppress the syncconfig
during running installation targets.

V1 consisted of only two patches:
  https://patchwork.kernel.org/patch/10468105/
  https://patchwork.kernel.org/patch/10468103/

I noticed that installation targets would continue running
even if the source tree is not configured at all
because the inclusion of include/config/auto.conf was optional.

So, I added one more patch in V2:
 https://patchwork.kernel.org/patch/10483637/

However, kbuild test robot reported a new warning message was displayed:

Makefile:592: include/config/auto.conf: No such file or directory

This warning is displayed only for Make 4.1 or older.

To fix this annoying warning, I changed Kconfig too,
which leaded to more clean-up, improvements in Kconfig.

So, V3 became a big patch series.

Only a few changes for V4.
 - I dropped the last patch in v3.
 - I am keeping include/config/auto.conf as the prerequisite of modules.builtin (11/11)


Masahiro Yamada (11):
  kconfig: rename file_write_dep and move it to confdata.c
  kconfig: split out useful helpers in confdata.c
  kconfig: remove unneeded directory generation from local*config
  kconfig: create directories needed for syncconfig by itself
  kconfig: make syncconfig update .config regardless of sym_change_count
  kconfig: allow all config targets to write auto.conf if missing
  kbuild: use 'include' directive to load auto.conf from top Makefile
  kbuild: add .DELETE_ON_ERROR special target
  kbuild: do not update config when running install targets
  kbuild: do not update config for 'make kernelrelease'
  kbuild: remove auto.conf from prerequisite of phony targets

 Makefile                    |  44 +++++++++------
 scripts/Kbuild.include      |   3 +
 scripts/kconfig/Makefile    |  16 ++----
 scripts/kconfig/conf.c      |  39 +++++++------
 scripts/kconfig/confdata.c  | 135 +++++++++++++++++++++++++++++++++++++-------
 scripts/kconfig/gconf.c     |   1 +
 scripts/kconfig/lkc.h       |   1 -
 scripts/kconfig/lkc_proto.h |   2 +-
 scripts/kconfig/mconf.c     |   1 +
 scripts/kconfig/nconf.c     |   1 +
 scripts/kconfig/qconf.cc    |   2 +
 scripts/kconfig/util.c      |  30 ----------
 12 files changed, 177 insertions(+), 98 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 02/11] kconfig: split out useful helpers in confdata.c Masahiro Yamada
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

file_write_dep() is called only from conf_write_autoconf().
Move it from util.c to confdata.c to make it static.
Also, rename it to conf_write_dep() since it should belong to
the group of conf_write* functions.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/kconfig/confdata.c | 31 ++++++++++++++++++++++++++++++-
 scripts/kconfig/lkc.h      |  1 -
 scripts/kconfig/util.c     | 30 ------------------------------
 3 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 39e2097..4771820 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -813,6 +813,35 @@ int conf_write(const char *name)
 	return 0;
 }
 
+/* write a dependency file as used by kbuild to track dependencies */
+static int conf_write_dep(const char *name)
+{
+	struct file *file;
+	FILE *out;
+
+	if (!name)
+		name = ".kconfig.d";
+	out = fopen("..config.tmp", "w");
+	if (!out)
+		return 1;
+	fprintf(out, "deps_config := \\\n");
+	for (file = file_list; file; file = file->next) {
+		if (file->next)
+			fprintf(out, "\t%s \\\n", file->name);
+		else
+			fprintf(out, "\t%s\n", file->name);
+	}
+	fprintf(out, "\n%s: \\\n"
+		     "\t$(deps_config)\n\n", conf_get_autoconfig_name());
+
+	env_write_dep(out, conf_get_autoconfig_name());
+
+	fprintf(out, "\n$(deps_config): ;\n");
+	fclose(out);
+	rename("..config.tmp", name);
+	return 0;
+}
+
 static int conf_split_config(void)
 {
 	const char *name;
@@ -935,7 +964,7 @@ int conf_write_autoconf(void)
 
 	sym_clear_all_valid();
 
-	file_write_dep("include/config/auto.conf.cmd");
+	conf_write_dep("include/config/auto.conf.cmd");
 
 	if (conf_split_config())
 		return 1;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index ed3ff88..6b7bbc6 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -97,7 +97,6 @@ void menu_set_type(int type);
 
 /* util.c */
 struct file *file_lookup(const char *name);
-int file_write_dep(const char *name);
 void *xmalloc(size_t size);
 void *xcalloc(size_t nmemb, size_t size);
 void *xrealloc(void *p, size_t size);
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index a365594..d999683 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -29,36 +29,6 @@ struct file *file_lookup(const char *name)
 	return file;
 }
 
-/* write a dependency file as used by kbuild to track dependencies */
-int file_write_dep(const char *name)
-{
-	struct file *file;
-	FILE *out;
-
-	if (!name)
-		name = ".kconfig.d";
-	out = fopen("..config.tmp", "w");
-	if (!out)
-		return 1;
-	fprintf(out, "deps_config := \\\n");
-	for (file = file_list; file; file = file->next) {
-		if (file->next)
-			fprintf(out, "\t%s \\\n", file->name);
-		else
-			fprintf(out, "\t%s\n", file->name);
-	}
-	fprintf(out, "\n%s: \\\n"
-		     "\t$(deps_config)\n\n", conf_get_autoconfig_name());
-
-	env_write_dep(out, conf_get_autoconfig_name());
-
-	fprintf(out, "\n$(deps_config): ;\n");
-	fclose(out);
-	rename("..config.tmp", name);
-	return 0;
-}
-
-
 /* Allocate initial growable string */
 struct gstr str_new(void)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 02/11] kconfig: split out useful helpers in confdata.c
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 03/11] kconfig: remove unneeded directory generation from local*config Masahiro Yamada
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

Split out helpers:
 is_present() - check if the given path exists
 is_dir() - check if the given path exists and it is a directory
 make_parent_dir() - create the parent directories of the given path

These helpers will be reused in later commits.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4:
  - Rename mkdir_p() to make_parent_dir() for clarification
  - Add is_present() instead of is_file()

 scripts/kconfig/confdata.c | 81 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 64 insertions(+), 17 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 4771820..f9c5ad4 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -16,6 +16,64 @@
 
 #include "lkc.h"
 
+/* return true if 'path' exists, false otherwise */
+static bool is_present(const char *path)
+{
+	struct stat st;
+
+	return !stat(path, &st);
+}
+
+/* return true if 'path' exists and it is a directory, false otherwise */
+static bool is_dir(const char *path)
+{
+	struct stat st;
+
+	if (stat(path, &st))
+		return 0;
+
+	return S_ISDIR(st.st_mode);
+}
+
+/*
+ * Create the parent directory of the given path.
+ *
+ * For example, if 'include/config/auto.conf' is given, create 'include/config'.
+ */
+static int make_parent_dir(const char *path)
+{
+	char tmp[PATH_MAX + 1];
+	char *p;
+
+	strncpy(tmp, path, sizeof(tmp));
+	tmp[sizeof(tmp) - 1] = 0;
+
+	/* Remove the base name. Just return if nothing is left */
+	p = strrchr(tmp, '/');
+	if (!p)
+		return 0;
+	*(p + 1) = 0;
+
+	/* Just in case it is an absolute path */
+	p = tmp;
+	while (*p == '/')
+		p++;
+
+	while ((p = strchr(p, '/'))) {
+		*p = 0;
+
+		/* skip if the directory exists */
+		if (!is_dir(tmp) && mkdir(tmp, 0755))
+			return -1;
+
+		*p = '/';
+		while (*p == '/')
+			p++;
+	}
+
+	return 0;
+}
+
 struct conf_printer {
 	void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
 	void (*print_comment)(FILE *, const char *, void *);
@@ -83,7 +141,6 @@ const char *conf_get_autoconfig_name(void)
 
 char *conf_get_default_confname(void)
 {
-	struct stat buf;
 	static char fullname[PATH_MAX+1];
 	char *env, *name;
 
@@ -91,7 +148,7 @@ char *conf_get_default_confname(void)
 	env = getenv(SRCTREE);
 	if (env) {
 		sprintf(fullname, "%s/%s", env, name);
-		if (!stat(fullname, &buf))
+		if (is_present(fullname))
 			return fullname;
 	}
 	return name;
@@ -725,10 +782,9 @@ int conf_write(const char *name)
 
 	dirname[0] = 0;
 	if (name && name[0]) {
-		struct stat st;
 		char *slash;
 
-		if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
+		if (is_dir(name)) {
 			strcpy(dirname, name);
 			strcat(dirname, "/");
 			basename = conf_get_configname();
@@ -848,7 +904,6 @@ static int conf_split_config(void)
 	char path[PATH_MAX+1];
 	char *s, *d, c;
 	struct symbol *sym;
-	struct stat sb;
 	int res, i, fd;
 
 	name = conf_get_autoconfig_name();
@@ -926,18 +981,10 @@ static int conf_split_config(void)
 				res = 1;
 				break;
 			}
-			/*
-			 * Create directory components,
-			 * unless they exist already.
-			 */
-			d = path;
-			while ((d = strchr(d, '/'))) {
-				*d = 0;
-				if (stat(path, &sb) && mkdir(path, 0755)) {
-					res = 1;
-					goto out;
-				}
-				*d++ = '/';
+
+			if (make_parent_dir(path)) {
+				res = 1;
+				goto out;
 			}
 			/* Try it again. */
 			fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 03/11] kconfig: remove unneeded directory generation from local*config
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 02/11] kconfig: split out useful helpers in confdata.c Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 04/11] kconfig: create directories needed for syncconfig by itself Masahiro Yamada
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

Commit 17263baf958b ("kconfig: Create include/generated for
localmodconfig") added the 'mkdir' line because local{yes,mod}config
ran streamline_config.pl followed by silentoldconfig at that time.

Since commit 81d2bc227305 ("kconfig: invoke oldconfig instead of
silentoldconfig from local*config"), no sub-directory is required.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/kconfig/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index f3c0e62..96a1c3d 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -41,7 +41,6 @@ syncconfig: $(obj)/conf
 	$< $(silent) --$@ $(Kconfig)
 
 localyesconfig localmodconfig: $(obj)/conf
-	$(Q)mkdir -p include/config include/generated
 	$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
 	$(Q)if [ -f .config ]; then 					\
 			cmp -s .tmp.config .config ||			\
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 04/11] kconfig: create directories needed for syncconfig by itself
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (2 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 03/11] kconfig: remove unneeded directory generation from local*config Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 05/11] kconfig: make syncconfig update .config regardless of sym_change_count Masahiro Yamada
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

'make syncconfig' creates some files such as include/config/auto.conf,
include/generate/autoconf.h, etc. but the necessary directory creation
relies on scripts/kconfig/Makefile.

To make Kconfig self-contained, create directories as needed in
conf_write_autoconf().

This change allows scripts/kconfig/Makefile cleanups; syncconfig can
be merged into simple-targets.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/kconfig/Makefile   | 15 ++++++---------
 scripts/kconfig/confdata.c | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 96a1c3d..963ba90 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -3,8 +3,7 @@
 # Kernel configuration targets
 # These targets are used from top-level makefile
 
-PHONY += xconfig gconfig menuconfig config syncconfig \
-	localmodconfig localyesconfig
+PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig
 
 ifdef KBUILD_KCONFIG
 Kconfig := $(KBUILD_KCONFIG)
@@ -34,12 +33,6 @@ config: $(obj)/conf
 nconfig: $(obj)/nconf
 	$< $(silent) $(Kconfig)
 
-# This has become an internal implementation detail and is now deprecated
-# for external use.
-syncconfig: $(obj)/conf
-	$(Q)mkdir -p include/config include/generated
-	$< $(silent) --$@ $(Kconfig)
-
 localyesconfig localmodconfig: $(obj)/conf
 	$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
 	$(Q)if [ -f .config ]; then 					\
@@ -55,8 +48,12 @@ localyesconfig localmodconfig: $(obj)/conf
 	$(Q)rm -f .tmp.config
 
 # These targets map 1:1 to the commandline options of 'conf'
+#
+# Note:
+#  syncconfig has become an internal implementation detail and is now
+#  deprecated for external use
 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
-	alldefconfig randconfig listnewconfig olddefconfig
+	alldefconfig randconfig listnewconfig olddefconfig syncconfig
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f9c5ad4..029ab16 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -894,6 +894,9 @@ static int conf_write_dep(const char *name)
 
 	fprintf(out, "\n$(deps_config): ;\n");
 	fclose(out);
+
+	if (make_parent_dir(name))
+		return 1;
 	rename("..config.tmp", name);
 	return 0;
 }
@@ -910,6 +913,8 @@ static int conf_split_config(void)
 	conf_read_simple(name, S_DEF_AUTO);
 	sym_calc_value(modules_sym);
 
+	if (make_parent_dir("include/config/foo.h"))
+		return 1;
 	if (chdir("include/config"))
 		return 1;
 
@@ -986,6 +991,7 @@ static int conf_split_config(void)
 				res = 1;
 				goto out;
 			}
+
 			/* Try it again. */
 			fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 			if (fd == -1) {
@@ -1058,14 +1064,22 @@ int conf_write_autoconf(void)
 	name = getenv("KCONFIG_AUTOHEADER");
 	if (!name)
 		name = "include/generated/autoconf.h";
+	if (make_parent_dir(name))
+		return 1;
 	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;
+
 	name = conf_get_autoconfig_name();
+	if (make_parent_dir(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.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 05/11] kconfig: make syncconfig update .config regardless of sym_change_count
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (3 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 04/11] kconfig: create directories needed for syncconfig by itself Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 06/11] kconfig: allow all config targets to write auto.conf if missing Masahiro Yamada
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

syncconfig updates the .config only when sym_change_count > 0, i.e.
any change in config symbols has been detected.

Not only symbols but also comments are contained in the .config file.
If only comments are updated, they are not fed back to the .config,
then the stale comments are left-over.  Of course, this is just a
matter of comments, but why not fix it.

I see some scenarios where this happens.

Scenario A:

 1. You have a source tree that has already been configured.

 2. Linus increments the version number in the top-level Makefile
    (i.e. he commits a new release)

 3. You pull it, and run 'make'

 4. syncconfig is invoked because the environment variable,
    KERNELVERSION is updated, but the .config is not updated since
    no config symbol is changed.

 5. The .config file contains a kernel version in the top line:

    # Automatically generated file; DO NOT EDIT.
    # Linux/arm64 4.18.0-rc2 Kernel Configuration

    ... which points to a previous version.

Scenario B:

 1. You have a source tree that has already been configured.

 2. You upgrade the compiler, but it still has the same version number.
    This may happen if you regularly build the latest compiler from
    the source code.

 3. You run 'make'

 4. syncconfig is invoked because the environment variable,
    CC_VERSION_TEXT is updated, but the .config is not updated since
    no config symbol is changed.

 5. The .config file contains the version string of the compiler:

    #
    # Compiler: aarch64-linux-gcc (GCC) 9.0.0 20180628 (experimental)
    #

    ... which carries the information of the old compiler.

If KCONFIG_NOSILENTUPDATE is set, syncconfig is not allowed to update
the .config file.  Otherwise, it is fine to update it regardless of
sym_change_count.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/kconfig/conf.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 671ff53..5af8991 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -496,6 +496,7 @@ int main(int ac, char **av)
 	int opt;
 	const char *name, *defconfig_file = NULL /* gcc uninit */;
 	struct stat tmpstat;
+	int no_conf_write = 0;
 
 	tty_stdio = isatty(0) && isatty(1);
 
@@ -633,13 +634,14 @@ int main(int ac, char **av)
 	}
 
 	if (sync_kconfig) {
-		if (conf_get_changed()) {
-			name = getenv("KCONFIG_NOSILENTUPDATE");
-			if (name && *name) {
+		name = getenv("KCONFIG_NOSILENTUPDATE");
+		if (name && *name) {
+			if (conf_get_changed()) {
 				fprintf(stderr,
 					"\n*** The configuration requires explicit update.\n\n");
 				return 1;
 			}
+			no_conf_write = 1;
 		}
 	}
 
@@ -688,7 +690,7 @@ int main(int ac, char **av)
 		/* syncconfig is used during the build so we shall update autoconf.
 		 * All other commands are only used to generate a config.
 		 */
-		if (conf_get_changed() && conf_write(NULL)) {
+		if (!no_conf_write && conf_write(NULL)) {
 			fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
 			exit(1);
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 06/11] kconfig: allow all config targets to write auto.conf if missing
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (4 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 05/11] kconfig: make syncconfig update .config regardless of sym_change_count Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada, linux-kernel

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

Changes in v4: None

 scripts/kconfig/conf.c      | 31 +++++++++++++++++--------------
 scripts/kconfig/confdata.c  | 11 +++++++----
 scripts/kconfig/gconf.c     |  1 +
 scripts/kconfig/lkc_proto.h |  2 +-
 scripts/kconfig/mconf.c     |  1 +
 scripts/kconfig/nconf.c     |  1 +
 scripts/kconfig/qconf.cc    |  2 ++
 7 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 5af8991..b35cc93 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -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;
 }
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 029ab16..620b50d 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1008,13 +1008,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");
@@ -1077,14 +1081,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;
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 610c4ab..f16ed51 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -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);
 }
 
 
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a8b7a33..b0cd52f 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -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 *fmt, va_list ap));
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 5294ed1..82b27a0 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -977,6 +977,7 @@ static int handle_exit(void)
 					  "\n\n");
 			return 1;
 		}
+		conf_write_autoconf(0);
 		/* fall through */
 	case -1:
 		if (!silent)
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 97b7844..208f7be 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -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(
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index ad9c22d..62261b3 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1535,6 +1535,8 @@ bool ConfigMainWindow::saveConfig(void)
 		QMessageBox::information(this, "qconf", "Unable to save configuration!");
 		return false;
 	}
+	conf_write_autoconf(0);
+
 	return true;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (5 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 06/11] kconfig: allow all config targets to write auto.conf if missing Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-09-03  9:39   ` Borislav Petkov
  2018-07-20  7:46 ` [PATCH v4 08/11] kbuild: add .DELETE_ON_ERROR special target Masahiro Yamada
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel

When you build targets that require the kernel configuration, dot-config
is set to 1, then the top-level Makefile includes auto.conf.  However,
Make considers its inclusion is optional because the '-include' directive
is used here.

If a necessary configuration file is missing for the external module
building, the following error message is displayed:

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

However, Make still continues building; /bin/false let the creation of
'include/config/auto.config' fail, but Make can ignore the error since
it is included by the '-include' directive.

I guess the reason of using '-include' directive was to suppress
the warning when you build the kernel from a pristine source tree:

  Makefile:605: include/config/auto.conf: No such file or directory

The previous commit made sure include/config/auto.conf exists after
the 'make *config' stage.  Now, we can use the 'include' directive
without showing the warning.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5c8e9a3..2fa9830 100644
--- a/Makefile
+++ b/Makefile
@@ -585,7 +585,7 @@ virt-y		:= virt/
 endif # KBUILD_EXTMOD
 
 ifeq ($(dot-config),1)
--include include/config/auto.conf
+include include/config/auto.conf
 endif
 
 # The all: target is the default when no target is given on the
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 08/11] kbuild: add .DELETE_ON_ERROR special target
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (6 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 09/11] kbuild: do not update config when running install targets Masahiro Yamada
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel

If Make gets a fatal signal while a shell is executing, it may delete
the target file that the recipe was supposed to update.  This is needed
to make sure that it is remade from scratch when Make is next run; if
Make is interrupted after the recipe has begun to write the target file,
it results in an incomplete file whose time stamp is newer than that
of the prerequisites files.  Make automatically deletes the incomplete
file on interrupt unless the target is marked .PRECIOUS.

The situation is just the same as when the shell fails for some reasons.
Usually when a recipe line fails, if it has changed the target file at
all, the file is corrupted, or at least it is not completely updated.
Yet the file’s time stamp says that it is now up to date, so the next
time Make runs, it will not try to update that file.

However, Make does not cater to delete the incomplete target file in
this case.  We need to add .DELETE_ON_ERROR somewhere in the Makefile
to request it.

scripts/Kbuild.include seems a suitable place to add it because it is
included from almost all sub-makes.

Please note .DELETE_ON_ERROR is not effective for phony targets.

The external module building should never ever touch the kernel tree.
The following recipe fails if include/generated/autoconf.h is missing.
However, include/config/auto.conf is not deleted since it is a phony
target.

 PHONY += include/config/auto.conf

 include/config/auto.conf:
         $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
         echo >&2;                                                       \
         echo >&2 "  ERROR: Kernel configuration is invalid.";           \
         echo >&2 "         include/generated/autoconf.h or $@ are missing.";\
         echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it."; \
         echo >&2 ;                                                      \
         /bin/false)

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/Kbuild.include | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 3d14d0e..7f4b1db 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -400,3 +400,6 @@ endif
 endef
 #
 ###############################################################################
+
+# delete partially updated (i.e. corrupted) files on error
+.DELETE_ON_ERROR:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 09/11] kbuild: do not update config when running install targets
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (7 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 08/11] kbuild: add .DELETE_ON_ERROR special target Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 10/11] kbuild: do not update config for 'make kernelrelease' Masahiro Yamada
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel

"make syncconfig" is automatically invoked when any of the following
happens:

 - .config is updated
 - any of Kconfig files is updated
 - any of environment variables referenced in Kconfig is changed

Then, it updates configuration files such as include/config/auto.conf
include/generated/autoconf.h, etc.

Even install targets (install, modules_install, etc.) are no exception.
However, they should never ever modify the source tree.  Install
targets are often run with root privileges.  Once those configuration
files are owned by root, "make mrproper" would end up with permission
error.

Install targets should just copy things blindly.  They should not care
whether the configuration is up-to-date or not.  This makes more sense
because we are interested in the configuration that was used in the
previous kernel building.

This issue has existed since before, but rarely happened.  I expect
more chance where people are hit by this; with the new Kconfig syntax
extension, the .config now contains the compiler information.  If you
cross-compile the kernel with CROSS_COMPILE, but forget to pass it
for "make install", you meet "any of environment variables referenced
in Kconfig is changed" because $(CC) is referenced in Kconfig.
Another scenario is the compiler upgrade before the installation.

Install targets need the configuration.  "make modules_install" refer
to CONFIG_MODULES etc.  "make dtbs_install" also needs CONFIG_ARCH_*
to decide which dtb files to install.  However, the auto-update of
the configuration files should be avoided.  We already do this for
external modules.

Now, Make targets are categorized into 3 groups:

[1] Do not need the kernel configuration at all

    help, coccicheck, headers_install etc.

[2] Need the latest kernel configuration

    If new config options are added, Kconfig will show prompt to
    ask user's selection.

    Build targets such as vmlinux, in-kernel modules are the cases.

[3] Need the kernel configuration, but do not want to update it

    Install targets except headers_install, and external modules
    are the cases.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 Makefile | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 2fa9830..ad83917 100644
--- a/Makefile
+++ b/Makefile
@@ -225,10 +225,12 @@ no-dot-config-targets := $(clean-targets) \
 			 cscope gtags TAGS tags help% %docs check% coccicheck \
 			 $(version_h) headers_% archheaders archscripts \
 			 kernelversion %src-pkg
+no-sync-config-targets := $(no-dot-config-targets) install %install
 
-config-targets := 0
-mixed-targets  := 0
-dot-config     := 1
+config-targets  := 0
+mixed-targets   := 0
+dot-config      := 1
+may-sync-config := 1
 
 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
 	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
@@ -236,6 +238,16 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
 	endif
 endif
 
+ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
+	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
+		may-sync-config := 0
+	endif
+endif
+
+ifneq ($(KBUILD_EXTMOD),)
+	may-sync-config := 0
+endif
+
 ifeq ($(KBUILD_EXTMOD),)
         ifneq ($(filter config %config,$(MAKECMDGOALS)),)
                 config-targets := 1
@@ -607,7 +619,7 @@ ARCH_CFLAGS :=
 include arch/$(SRCARCH)/Makefile
 
 ifeq ($(dot-config),1)
-ifeq ($(KBUILD_EXTMOD),)
+ifeq ($(may-sync-config),1)
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
 # because some architectures define CROSS_COMPILE there.
@@ -622,8 +634,9 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
 include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
 	$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
 else
-# external modules needs include/generated/autoconf.h and include/config/auto.conf
-# but do not care if they are up-to-date. Use auto.conf to trigger the test
+# External modules and some install targets need include/generated/autoconf.h
+# and include/config/auto.conf but do not care if they are up-to-date.
+# Use auto.conf to trigger the test
 PHONY += include/config/auto.conf
 
 include/config/auto.conf:
@@ -635,7 +648,7 @@ include/config/auto.conf:
 	echo >&2 ;							\
 	/bin/false)
 
-endif # KBUILD_EXTMOD
+endif # may-sync-config
 
 else
 # Dummy target needed, because used as prerequisite
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 10/11] kbuild: do not update config for 'make kernelrelease'
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (8 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 09/11] kbuild: do not update config when running install targets Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-20  7:46 ` [PATCH v4 11/11] kbuild: remove auto.conf from prerequisite of phony targets Masahiro Yamada
  2018-07-25 14:40 ` [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel

'make kernelrelease' depends on CONFIG_LOCALVERSION(_AUTO), but
for the same reason as install targets, we do not want to update
the configuration just for printing the kernelrelease string.

This is likely to happen when you compiled the kernel with
CROSS_COMPILE, but forget to pass it to 'make kernelrelease'.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ad83917..0ec1c27 100644
--- a/Makefile
+++ b/Makefile
@@ -225,7 +225,8 @@ no-dot-config-targets := $(clean-targets) \
 			 cscope gtags TAGS tags help% %docs check% coccicheck \
 			 $(version_h) headers_% archheaders archscripts \
 			 kernelversion %src-pkg
-no-sync-config-targets := $(no-dot-config-targets) install %install
+no-sync-config-targets := $(no-dot-config-targets) install %install \
+			   kernelrelease
 
 config-targets  := 0
 mixed-targets   := 0
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 11/11] kbuild: remove auto.conf from prerequisite of phony targets
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (9 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 10/11] kbuild: do not update config for 'make kernelrelease' Masahiro Yamada
@ 2018-07-20  7:46 ` Masahiro Yamada
  2018-07-25 14:40 ` [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-20  7:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, linux-kernel

The top-level Makefile adds include/config/auto.conf as
prerequisites of 'scripts', 'prepare1', etc.

They were needed to terminate the build when include/config/auto.conf
is missing.

Now that the inclusion of include/config/auto.conf is mandatory
in the top-level Makefile if dot-config is 1 (Note 'include' directive
is used instead of '-include').

Make terminates the build by itself if it fails to create or update
include/config/auto.conf so we are sure that include/config/auto.conf
exists in the very first stage of make.

I am still keeping include/config/auto.conf as the prerequisite of
%/modules.builtin because modules.builtin is a real file.  According
to commit a6c366324cac ("kbuild: Do not unnecessarily regenerate
modules.builtin"), it is intentional to compare time-stamps between
%/modules.builtin and include/config/auto.conf .  I moved tristate.conf
here because it is only included from scripts/Makefile.modbuiltin.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4: None

 Makefile | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 0ec1c27..ceb9c1e 100644
--- a/Makefile
+++ b/Makefile
@@ -650,10 +650,6 @@ include/config/auto.conf:
 	/bin/false)
 
 endif # may-sync-config
-
-else
-# Dummy target needed, because used as prerequisite
-include/config/auto.conf: ;
 endif # $(dot-config)
 
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
@@ -1048,15 +1044,14 @@ define filechk_kernel.release
 endef
 
 # Store (new) KERNELRELEASE string in include/config/kernel.release
-include/config/kernel.release: include/config/auto.conf FORCE
+include/config/kernel.release: $(srctree)/Makefile FORCE
 	$(call filechk,kernel.release)
 
 # Additional helpers built in scripts/
 # Carefully list dependencies so we do not try to build scripts twice
 # in parallel
 PHONY += scripts
-scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
-	 asm-generic gcc-plugins $(autoksyms_h)
+scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
 	$(Q)$(MAKE) $(build)=$(@)
 
 # Things we need to do before we recursively start building the kernel
@@ -1086,8 +1081,7 @@ endif
 # that need to depend on updated CONFIG_* values can be checked here.
 prepare2: prepare3 outputmakefile asm-generic
 
-prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
-                   include/config/auto.conf
+prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
 	$(cmd_crmodverdir)
 
 archprepare: archheaders archscripts prepare1 scripts_basic
@@ -1225,7 +1219,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
 modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
 	$(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
 
-%/modules.builtin: include/config/auto.conf
+%/modules.builtin: include/config/auto.conf include/config/tristate.conf
 	$(Q)$(MAKE) $(modbuiltin)=$*
 
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 00/11] kbuild/kconfig: do not update config during installation
  2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
                   ` (10 preceding siblings ...)
  2018-07-20  7:46 ` [PATCH v4 11/11] kbuild: remove auto.conf from prerequisite of phony targets Masahiro Yamada
@ 2018-07-25 14:40 ` Masahiro Yamada
  11 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-07-25 14:40 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Dirk Gouders, Ulf Magnusson, Sam Ravnborg, Masahiro Yamada,
	Michal Marek, Linux Kernel Mailing List

2018-07-20 16:46 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>
> The main motivation of this patch series is to suppress the syncconfig
> during running installation targets.
>
> V1 consisted of only two patches:
>   https://patchwork.kernel.org/patch/10468105/
>   https://patchwork.kernel.org/patch/10468103/
>
> I noticed that installation targets would continue running
> even if the source tree is not configured at all
> because the inclusion of include/config/auto.conf was optional.
>
> So, I added one more patch in V2:
>  https://patchwork.kernel.org/patch/10483637/
>
> However, kbuild test robot reported a new warning message was displayed:
>
> Makefile:592: include/config/auto.conf: No such file or directory
>
> This warning is displayed only for Make 4.1 or older.
>
> To fix this annoying warning, I changed Kconfig too,
> which leaded to more clean-up, improvements in Kconfig.
>
> So, V3 became a big patch series.
>
> Only a few changes for V4.
>  - I dropped the last patch in v3.
>  - I am keeping include/config/auto.conf as the prerequisite of modules.builtin (11/11)


Applied to linux-kbuild/kconfig.


>
> Masahiro Yamada (11):
>   kconfig: rename file_write_dep and move it to confdata.c
>   kconfig: split out useful helpers in confdata.c
>   kconfig: remove unneeded directory generation from local*config
>   kconfig: create directories needed for syncconfig by itself
>   kconfig: make syncconfig update .config regardless of sym_change_count
>   kconfig: allow all config targets to write auto.conf if missing
>   kbuild: use 'include' directive to load auto.conf from top Makefile
>   kbuild: add .DELETE_ON_ERROR special target
>   kbuild: do not update config when running install targets
>   kbuild: do not update config for 'make kernelrelease'
>   kbuild: remove auto.conf from prerequisite of phony targets
>
>  Makefile                    |  44 +++++++++------
>  scripts/Kbuild.include      |   3 +
>  scripts/kconfig/Makefile    |  16 ++----
>  scripts/kconfig/conf.c      |  39 +++++++------
>  scripts/kconfig/confdata.c  | 135 +++++++++++++++++++++++++++++++++++++-------
>  scripts/kconfig/gconf.c     |   1 +
>  scripts/kconfig/lkc.h       |   1 -
>  scripts/kconfig/lkc_proto.h |   2 +-
>  scripts/kconfig/mconf.c     |   1 +
>  scripts/kconfig/nconf.c     |   1 +
>  scripts/kconfig/qconf.cc    |   2 +
>  scripts/kconfig/util.c      |  30 ----------
>  12 files changed, 177 insertions(+), 98 deletions(-)
>
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-07-20  7:46 ` [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
@ 2018-09-03  9:39   ` Borislav Petkov
  2018-09-03  9:54     ` Masahiro Yamada
  0 siblings, 1 reply; 18+ messages in thread
From: Borislav Petkov @ 2018-09-03  9:39 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Dirk Gouders, Ulf Magnusson, Sam Ravnborg,
	Michal Marek, linux-kernel

Hey,

On Fri, Jul 20, 2018 at 04:46:32PM +0900, Masahiro Yamada wrote:
> When you build targets that require the kernel configuration, dot-config
> is set to 1, then the top-level Makefile includes auto.conf.  However,
> Make considers its inclusion is optional because the '-include' directive
> is used here.
> 
> If a necessary configuration file is missing for the external module
> building, the following error message is displayed:
> 
>   ERROR: Kernel configuration is invalid.
>          include/generated/autoconf.h or include/config/auto.conf are missing.
>          Run 'make oldconfig && make prepare' on kernel src to fix it.
> 
> However, Make still continues building; /bin/false let the creation of
> 'include/config/auto.config' fail, but Make can ignore the error since
> it is included by the '-include' directive.
> 
> I guess the reason of using '-include' directive was to suppress
> the warning when you build the kernel from a pristine source tree:
> 
>   Makefile:605: include/config/auto.conf: No such file or directory
> 
> The previous commit made sure include/config/auto.conf exists after
> the 'make *config' stage.  Now, we can use the 'include' directive
> without showing the warning.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
> Changes in v4: None
> 
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

This complains here:

[boris@zn: ~/kernel/linux> git clean -dqfx
[boris@zn: ~/kernel/linux> cp ../configs/config-4.19-rc1 .config
'../configs/config-4.19-rc1' -> '.config'
[boris@zn: ~/kernel/linux> make
Makefile:605: include/config/auto.conf: No such file or directory

I guess because I'm skipping the "make oldconfig" step but that should
not be necessary since it should do oldconfig automatically before
building...

It still works - it is just the warning that is new.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-09-03  9:39   ` Borislav Petkov
@ 2018-09-03  9:54     ` Masahiro Yamada
  2018-09-03 10:00       ` Borislav Petkov
  0 siblings, 1 reply; 18+ messages in thread
From: Masahiro Yamada @ 2018-09-03  9:54 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Linux Kbuild mailing list, Dirk Gouders, Ulf Magnusson,
	Sam Ravnborg, Michal Marek, Linux Kernel Mailing List

Hi,

2018-09-03 18:39 GMT+09:00 Borislav Petkov <bp@alien8.de>:
> Hey,
>
> On Fri, Jul 20, 2018 at 04:46:32PM +0900, Masahiro Yamada wrote:
>> When you build targets that require the kernel configuration, dot-config
>> is set to 1, then the top-level Makefile includes auto.conf.  However,
>> Make considers its inclusion is optional because the '-include' directive
>> is used here.
>>
>> If a necessary configuration file is missing for the external module
>> building, the following error message is displayed:
>>
>>   ERROR: Kernel configuration is invalid.
>>          include/generated/autoconf.h or include/config/auto.conf are missing.
>>          Run 'make oldconfig && make prepare' on kernel src to fix it.
>>
>> However, Make still continues building; /bin/false let the creation of
>> 'include/config/auto.config' fail, but Make can ignore the error since
>> it is included by the '-include' directive.
>>
>> I guess the reason of using '-include' directive was to suppress
>> the warning when you build the kernel from a pristine source tree:
>>
>>   Makefile:605: include/config/auto.conf: No such file or directory
>>
>> The previous commit made sure include/config/auto.conf exists after
>> the 'make *config' stage.  Now, we can use the 'include' directive
>> without showing the warning.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>> Changes in v4: None
>>
>>  Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> This complains here:
>
> [boris@zn: ~/kernel/linux> git clean -dqfx
> [boris@zn: ~/kernel/linux> cp ../configs/config-4.19-rc1 .config
> '../configs/config-4.19-rc1' -> '.config'
> [boris@zn: ~/kernel/linux> make
> Makefile:605: include/config/auto.conf: No such file or directory
>
> I guess because I'm skipping the "make oldconfig" step but that should
> not be necessary since it should do oldconfig automatically before
> building...
>
> It still works - it is just the warning that is new.


You are right - I missed this usecase,
but I still want to excuse "it is rare enough".


Thanks.

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-09-03  9:54     ` Masahiro Yamada
@ 2018-09-03 10:00       ` Borislav Petkov
  2018-09-05 22:53         ` Segher Boessenkool
  0 siblings, 1 reply; 18+ messages in thread
From: Borislav Petkov @ 2018-09-03 10:00 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Dirk Gouders, Ulf Magnusson,
	Sam Ravnborg, Michal Marek, Linux Kernel Mailing List

On Mon, Sep 03, 2018 at 06:54:12PM +0900, Masahiro Yamada wrote:
> You are right - I missed this usecase,
> but I still want to excuse "it is rare enough".

Isn't there a Makefile way to check file existence before including it?

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-09-03 10:00       ` Borislav Petkov
@ 2018-09-05 22:53         ` Segher Boessenkool
  2018-09-06  0:46           ` Masahiro Yamada
  0 siblings, 1 reply; 18+ messages in thread
From: Segher Boessenkool @ 2018-09-05 22:53 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Masahiro Yamada, Linux Kbuild mailing list, Dirk Gouders,
	Ulf Magnusson, Sam Ravnborg, Michal Marek,
	Linux Kernel Mailing List

On Mon, Sep 03, 2018 at 12:00:21PM +0200, Borislav Petkov wrote:
> On Mon, Sep 03, 2018 at 06:54:12PM +0900, Masahiro Yamada wrote:
> > You are right - I missed this usecase,
> > but I still want to excuse "it is rare enough".
> 
> Isn't there a Makefile way to check file existence before including it?

Sure there is, you can use $(wildcard ) .


Segher

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile
  2018-09-05 22:53         ` Segher Boessenkool
@ 2018-09-06  0:46           ` Masahiro Yamada
  0 siblings, 0 replies; 18+ messages in thread
From: Masahiro Yamada @ 2018-09-06  0:46 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Borislav Petkov, Linux Kbuild mailing list, Dirk Gouders,
	Ulf Magnusson, Sam Ravnborg, Michal Marek,
	Linux Kernel Mailing List

2018-09-06 7:53 GMT+09:00 Segher Boessenkool <segher@kernel.crashing.org>:
> On Mon, Sep 03, 2018 at 12:00:21PM +0200, Borislav Petkov wrote:
>> On Mon, Sep 03, 2018 at 06:54:12PM +0900, Masahiro Yamada wrote:
>> > You are right - I missed this usecase,
>> > but I still want to excuse "it is rare enough".
>>
>> Isn't there a Makefile way to check file existence before including it?
>
> Sure there is, you can use $(wildcard ) .


If you work around it by $(wildcard ),
we need something else that terminates building
in case auto.conf is really missing.


I do not want to revert

commit 2063945fdc3d4c0ac8f9319d942eda720d02aabe
Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Date:   Fri Jul 20 16:46:36 2018 +0900

    kbuild: remove auto.conf from prerequisite of phony targets





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-09-06  0:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 02/11] kconfig: split out useful helpers in confdata.c Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 03/11] kconfig: remove unneeded directory generation from local*config Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 04/11] kconfig: create directories needed for syncconfig by itself Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 05/11] kconfig: make syncconfig update .config regardless of sym_change_count Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 06/11] kconfig: allow all config targets to write auto.conf if missing Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
2018-09-03  9:39   ` Borislav Petkov
2018-09-03  9:54     ` Masahiro Yamada
2018-09-03 10:00       ` Borislav Petkov
2018-09-05 22:53         ` Segher Boessenkool
2018-09-06  0:46           ` Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 08/11] kbuild: add .DELETE_ON_ERROR special target Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 09/11] kbuild: do not update config when running install targets Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 10/11] kbuild: do not update config for 'make kernelrelease' Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 11/11] kbuild: remove auto.conf from prerequisite of phony targets Masahiro Yamada
2018-07-25 14:40 ` [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada

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