From patchwork Tue Mar 6 10:13:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 130756 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3754975lja; Tue, 6 Mar 2018 02:15:06 -0800 (PST) X-Google-Smtp-Source: AG47ELuQ7rldrXu82SBcMx2LaIV5PZPvg2Qj6fU3SvNduolcwI74MNVuF0uH5Sq36b8kIVwTH7g1 X-Received: by 2002:a17:902:9a45:: with SMTP id x5-v6mr6610511plv.18.1520331306689; Tue, 06 Mar 2018 02:15:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520331306; cv=none; d=google.com; s=arc-20160816; b=fGzv2XydNcjbzNOGDEvc0kiUF+UmojLIUHFa+EvD6FsnMurxN61GCpp+UEXEcTBx2P eFpZunwy+ZgphY/rqWEn0EmXxDFL4ztS/Bfdyad+P7xYiVgS2nQoYGzHsAzX4U1y/W7O UySzinj+Z0zr0GoTPSWtD2ts/15SjTr6lMQ2n543TZZKyRxAdRiSQ65xxIrP1z8Y+dz4 U7OULzg1WRDBTbnwf0WV+70Ku9OvEgYIO/Ns92oHrgsVJbYo1dE3OwxWZ6VxzdoWqZ85 rQyrigtY2ampqCcAW4j987tcF3XX0r+pS9T0TfRjcZLoxdix731gbb6W8yb4+a7sbFl6 W9uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=Nnflowr8wPMe2KsviImpKXg5z2L/ofyoLX0K/v/tOSY=; b=XRnkkLKuuyFxemGYfeb28yFW5lVjpyMUT/mo23MACFvjwkUbg9wmY+s3h+B2S1Hnq9 SNRG+US43KLNQlqSDQxjFiBUgJ31XUFdjytFQGMABvVrUAII4p/o60ZiBlbG+xeW4Adn l7+UL0c+D5B/p9E9QU4iBKRp11jvKlHNfjVzbYlrPcIP0vIiQKxh3EBkfhsQo1bE0UWs q5i+dOnr1T0j7WyuqHhRDRyz6I6mbdI9Fc69ri19Fw9K2PtJH7nwW2uLhv86U6nauMoq J91V1B5Q1owTM0fU3kXMrT18LmnOBFi+y6LEg1/J0qnJ5sQgBjf6oljJTW17CqKRC5MG xnNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BTrMLJRI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si9231820plz.589.2018.03.06.02.15.06; Tue, 06 Mar 2018 02:15:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BTrMLJRI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753335AbeCFKPC (ORCPT + 28 others); Tue, 6 Mar 2018 05:15:02 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:23729 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbeCFKO7 (ORCPT ); Tue, 6 Mar 2018 05:14:59 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id w26ADWAO002547; Tue, 6 Mar 2018 19:13:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com w26ADWAO002547 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520331213; bh=Nnflowr8wPMe2KsviImpKXg5z2L/ofyoLX0K/v/tOSY=; h=From:To:Cc:Subject:Date:From; b=BTrMLJRIAoZKEoMt5RZoCywuMRCneygund1dRQcirGCvgCzFCsXJKN+NLAbv+I4Mh QBosIg/66V+gRHJJNmBFkqB3+ARHXaVA5TwALsxI03ocniSQjafe8SSF1KrXPqFB4K p27NjEmbrjCFU6s230NYLI/jXpnPNpRg52w1JiVqdWz6YvNBlRhIf1JYaFIyfwLNyJ mlPLL30IqOXaj0X4OWjCZPJtE9djTZ2thkRHKiJZ5xwbzvnyxBFiqmbqGyDcTCH3Uj 04fabCm7dodNuiot1vrCgYqQwvICgJwH/loziEIS5H7shakUZRiuqHQViyFys1vabN 5e7M44ooOo6Qg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Eugeniu Rosca , Randy Dunlap , Petr Vorel , Linus Torvalds , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH] kconfig: make unmet dependency warnings readable Date: Tue, 6 Mar 2018 19:13:30 +0900 Message-Id: <1520331210-27940-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the unmet dependency warnings end up with endlessly long expressions, most of which are false positives. Here is test code to demonstrate how it currently works. [Test Case] config DEP1 def_bool y config DEP2 def_bool n config A bool "A" depends on DEP2 select C config B bool "B" select C config C bool depends on DEP1 && DEP2 [Result] $ make allyesconfig scripts/kconfig/conf --allyesconfig Kconfig warning: (A && B) selects C which has unmet direct dependencies (DEP1 && DEP2) Here, I see some points to be improved. First, '(A || B)' would make more sense than '(A && B)'. I am not sure if this is intentional, but expr_simplify_unmet_dep() turns OR expressions into AND, like follows: case E_OR: return expr_alloc_and( Second, 'A' never causes unmet dependency because 'DEP1' is fixed to 'y', and 'A' correctly depends on 'DEP2'. It will be better to not report 'A', but it is impossible to avoid this false positive in the current expr_simplify_unmet_dep(). After all, I decided to use the same helpers as used for printing reverse dependencies in the help. With this commit, unreadable warnings in the real world: $ make ARCH=score allyesconfig scripts/kconfig/conf --allyesconfig Kconfig warning: (HWSPINLOCK_QCOM && AHCI_MTK && STMMAC_PLATFORM && DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_OXNAS && DWMAC_ROCKCHIP && DWMAC_SOCFPGA && DWMA C_STI && TI_CPSW && PINCTRL_GEMINI && PINCTRL_OXNAS && PINCTRL_ROCKCHIP && PINCTRL_DOVE && PINCTRL_ARMADA_37XX && PINCTRL_STM32 && S3C2410_WATCHDOG && VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 && LP C18XX_DMAMUX && VIDEO_OMAP4 && COMMON_CLK_GEMINI && COMMON_CLK_ASPEED && C OMMON_CLK_NXP && COMMON_CLK_OXNAS && COMMON_CLK_BOSTON && ATMEL_ST && QCOM _ADSP_PIL && QCOM_Q6V5_PIL && QCOM_GSBI && ATMEL_EBI && ST_IRQCHIP && RESE T_IMX7 && PHY_HI6220_USB && PHY_RALINK_USB && PHY_ROCKCHIP_PCIE && PHY_DA8 XX_USB) selects MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM) warning: (PINCTRL_AT91 && PINCTRL_AT91PIO4 && PINCTRL_OXNAS && PINCTRL_PIS TACHIO && PINCTRL_PIC32 && PINCTRL_MESON && PINCTRL_NOMADIK && PINCTRL_MTK && PINCTRL_MT7622 && GPIO_TB10X) selects OF_GPIO which has unmet direct d ependencies (GPIOLIB && OF && HAS_IOMEM) warning: (FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && LOCKDEP) sele cts FRAME_POINTER which has unmet direct dependencies (DEBUG_KERNEL && (CR IS || M68K || FRV || UML || SUPERH || BLACKFIN || MN10300 || METAG) || ARC H_WANT_FRAME_POINTERS) will be turned into: $ make ARCH=score allyesconfig scripts/kconfig/conf --allyesconfig Kconfig WARNING: Unmet direct dependencies detected for MFD_SYSCON Depends on: HAS_IOMEM [=n] Selected by [y]: - PINCTRL_STM32 [=y] && PINCTRL [=y] && (ARCH_STM32 || COMPILE_TEST [=y]) && OF [=y] - RTC_DRV_AT91SAM9 [=y] && RTC_CLASS [=y] && (ARCH_AT91 || COMPILE_TEST [=y]) - ATMEL_ST [=y] && GENERIC_CLOCKEVENTS [=y] - RESET_IMX7 [=y] && RESET_CONTROLLER [=y] - PHY_HI6220_USB [=y] && (ARCH_HISI && ARM64 || COMPILE_TEST [=y]) - PHY_RALINK_USB [=y] && (RALINK || COMPILE_TEST [=y]) - PHY_ROCKCHIP_PCIE [=y] && (ARCH_ROCKCHIP && OF [=y] || COMPILE_TEST [=y]) WARNING: Unmet direct dependencies detected for OF_GPIO Depends on: GPIOLIB [=y] && OF [=y] && HAS_IOMEM [=n] Selected by [y]: - PINCTRL_MTK [=y] && PINCTRL [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y]) && OF [=y] - PINCTRL_MT7622 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y]) && OF [=y] && (ARM64 || COMPILE_TEST [=y]) WARNING: Unmet direct dependencies detected for FRAME_POINTER Depends on: DEBUG_KERNEL [=y] && (CRIS || M68K || FRV || UML || SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS [=n] Selected by [y]: - LATENCYTOP [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y] && PROC_FS [=y] && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC && !X86 Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 29 ----------------------------- scripts/kconfig/expr.h | 1 - scripts/kconfig/symbol.c | 33 +++++++++++++++++++++------------ 3 files changed, 21 insertions(+), 42 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 49376e1..235e179 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1150,35 +1150,6 @@ expr_get_leftmost_symbol(const struct expr *e) 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(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 8dbf2a4..94a383b 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -305,7 +305,6 @@ struct expr *expr_transform(struct expr *e); int expr_contains_symbol(struct expr *dep, struct symbol *sym); bool expr_depends_symbol(struct expr *dep, struct symbol *sym); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); -struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 0f7eba7..9138b80 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -333,6 +333,25 @@ static struct symbol *sym_calc_choice(struct symbol *sym) return def_sym; } +static void sym_warn_unmet_dependency(struct symbol *sym) +{ + struct gstr gs = str_new(); + + str_printf(&gs, "\nWARNING:\n"); + str_printf(&gs, " Unmet direct dependencies detected for %s\n", + sym->name); + str_printf(&gs, " Depends on:\n "); + expr_gstr_print(sym->dir_dep.expr, &gs); + str_printf(&gs, "\n"); + + expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, + " Selected by [y]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, + " Selected by [m]:\n"); + + fputs(str_get(&gs), stderr); +} + void sym_calc_value(struct symbol *sym) { struct symbol_value newval, oldval; @@ -414,18 +433,8 @@ 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(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); - } + if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) + sym_warn_unmet_dependency(sym); newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } if (newval.tri == mod &&