public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] kconfig: simplify select-with-unmet-direct-dependency warning
@ 2010-09-26 20:24 Arnaud Lacombe
  2010-09-27 10:57 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaud Lacombe @ 2010-09-26 20:24 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, Arnaud Lacombe, Catalin Marinas

This is an attempt to simplify the expressing printed by kconfig when a
symbol is selected but still has direct unmet dependency.

First, the symbol reverse dependency is split in sub-expression. Then,
each sub-expression is checked to ensure that it does not contains the
unmet dependency. This removes the false-positive symbols and fixed symbol
which already have the correct dependency. Finally, only the symbol
responsible of the "select" is printed, instead of its full dependency tree.

CC: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
---
 scripts/kconfig/expr.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/symbol.c |    6 +++++-
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 27e795c..49753cb 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1017,6 +1017,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
 #endif
 }
 
+static inline struct expr *
+expr_get_leftmost_symbol(const struct expr *e)
+{
+
+	if (e == NULL)
+		return NULL;
+
+	while (e->type != E_SYMBOL)
+		e = e->left.expr;
+
+	return expr_copy(e);
+}
+
+/*
+ * Given expression `e1' and `e2', returns the leaf of the longest
+ * sub-expression of `e1' not containing 'e2.
+ */
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
+{
+	struct expr *ret;
+
+	switch (e1->type) {
+	case E_OR:
+		return expr_alloc_and(
+		    expr_simplify_unmet_dep(e1->left.expr, e2),
+		    expr_simplify_unmet_dep(e1->right.expr, e2));
+	case E_AND: {
+		struct expr *e;
+		e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
+		e = expr_eliminate_dups(e);
+		ret = (!expr_eq(e, e1)) ? e1 : NULL;
+		expr_free(e);
+		break;
+		}
+	default:
+		ret = e1;
+		break;
+	}
+
+	return expr_get_leftmost_symbol(ret);
+}
+
 void expr_print(const struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
 {
 	if (!e) {
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index cd258da..ee16790 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -385,12 +385,16 @@ void sym_calc_value(struct symbol *sym)
 			}
 		calc_newval:
 			if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
+				struct expr *e;
+				e = expr_simplify_unmet_dep(sym->rev_dep.expr,
+				    sym->dir_dep.expr);
 				fprintf(stderr, "warning: (");
-				expr_fprint(sym->rev_dep.expr, stderr);
+				expr_fprint(e, stderr);
 				fprintf(stderr, ") selects %s which has unmet direct dependencies (",
 					sym->name);
 				expr_fprint(sym->dir_dep.expr, stderr);
 				fprintf(stderr, ")\n");
+				expr_free(e);
 			}
 			newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
 		}
-- 
1.7.2.30.gc37d7.dirty


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

* Re: [RFC] kconfig: simplify select-with-unmet-direct-dependency warning
  2010-09-26 20:24 [RFC] kconfig: simplify select-with-unmet-direct-dependency warning Arnaud Lacombe
@ 2010-09-27 10:57 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2010-09-27 10:57 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Michal Marek, linux-kbuild

On Sun, 2010-09-26 at 21:24 +0100, Arnaud Lacombe wrote:
> This is an attempt to simplify the expressing printed by kconfig when a
> symbol is selected but still has direct unmet dependency.

I haven't analysed the patch but I gave it a try and the result is a bit
weird.

I tried an ARMv7 platform which has CPU_V7 enabled. This selects
CPU_32v6K. The simplified entries:

config CPU_V7
	bool "Support ARM V7 processor"
	select CPU_32v6K

I changed CPU_32v6K to not depend on CPU_V7:

config CPU_32v6K
	bool "Support ARM V6K processor extensions"
	depends on CPU_V6

There is another option which isn't set in my config, however it gets
reported:

config CPU_MMP2
	bool
	select CPU_V6
	select CPU_32v6K

And the error kbuild reports with this patch is:

warning: (CPU_V7 && CPU_MMP2) selects CPU_32v6K which has unmet direct
dependencies (CPU_V6)

The weird thing is the inclusion of CPU_MMP2 above. First of all, it
isn't set in my .config. Secondly, it selects CPU_V6 so CPU_32v6K would
have met its dependency.

-- 
Catalin


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

end of thread, other threads:[~2010-09-27 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-26 20:24 [RFC] kconfig: simplify select-with-unmet-direct-dependency warning Arnaud Lacombe
2010-09-27 10:57 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox