From patchwork Tue Aug 14 06:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144101 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3977375ljj; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzYKrDVP/1Aju2syYLYfnhy+quIsMWLS/7t4XAj98a4Aba+CtnG6CzwCwtQ0Q3nrwUOQsGj X-Received: by 2002:a63:cc04:: with SMTP id x4-v6mr19541555pgf.33.1534229113036; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534229113; cv=none; d=google.com; s=arc-20160816; b=H5suz97SGGBhN8AhqyZd7BMlop2NRxQiAf+m2p7VV3ailLwp5YP8jIxuOgNR+kz4fy QGI/eaidD2KZNVymLETXuIm8wbucXp9SMwP5LB5t9QQjRk+6K2SZOecIWfjSjBcvwx3k LgFVl47RXAUGYKTz31/ddzOe6+Ljix0rQ8qDW2PdiuzQHuc0AeOnnBQK0Ms3vudlhYII 9PM3L9eXMHOdn+BXL1CMnH3jiLCEONAbwV5cBChQ6Dm5nGYXeu20umfBLj/y7CgT+Vss FsfaUWPqSli85MCaitL44Fw/olzSkRKnvt3AQ6uN8sR8huzCcabWY5x623DWpRdwoVI7 qneg== 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=jtf4RvAwN2yQhiQjgNRLjBjwVs832IxjSWznJdaeOY4=; b=tYXuTiXbXl4/i0pofm1rgU/FauGMmKK7XzZwIcGf8kI+Xh4L1V9z0jtQBUxS3cIZPS 9PQa+VQLtJh2XqN5KIDqjKO1J5VaCbu8LQDm1tE9ushfDdcH0szqgogTrraW5YF/awPm vVUrGXY6K0B2D9EzWtmocTp8qVqY+eaaPpmjIRQ1tb0EqA3snIlbcy3EL6R1wB1NzR4w Gtq3iFMfUxjMA59q/zMOCMu6mJWW7BTD6JA1TbG45+2xfiCs3W8A7i8W3VFyAeECxZJC RvyZJJZLZJTfUUNMLfc/3YpLZCGBPvfr2RL2iIjyvilLJHUuEzZ2M8D2HQcGNSKRd+jk L3IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jnuSCB2e; 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 w65-v6si19477104pgb.377.2018.08.13.23.45.12; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) 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=jnuSCB2e; 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 S1731587AbeHNJa4 (ORCPT + 31 others); Tue, 14 Aug 2018 05:30:56 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:55701 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730664AbeHNJaz (ORCPT ); Tue, 14 Aug 2018 05:30:55 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id w7E6hiBA014737; Tue, 14 Aug 2018 15:43:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w7E6hiBA014737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534229025; bh=jtf4RvAwN2yQhiQjgNRLjBjwVs832IxjSWznJdaeOY4=; h=From:To:Cc:Subject:Date:From; b=jnuSCB2eLbcYnPMHJRUBSEoFHt2DwjoJv64B5Oxy3z+dF54JBjci5cE6PQFnbgoBa NY58nAKVzF3YhTBGgvjF7oTSHH9thqXAX+1Ukf1/BCmpywbwOih02Sspum3etj0KdR GtABssbUrl8jjqA+87FgQC0YPtv8C25Zu9GP2UQS1I+P3tkGKvKLm800QGejDfPncy Ox20nEi1di90xW33WlDFXHSOv1r3kM6ehS8rI0Ww4t+R/9tLQrSSneUuNK7XRh68xk AqD0ibB82AiAShbgIuuVHswQep/iiPUjUYD2VVv53g8wXZswoez3D2nnRQoV/xmytE rkY/6OXOk4lBw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Dirk Gouders , Ulf Magnusson , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] kconfig: report recursive dependency involving 'imply' Date: Tue, 14 Aug 2018 15:43:40 +0900 Message-Id: <1534229021-8056-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, Kconfig does not report anything about the recursive dependency where 'imply' keywords are involved. [Test Code] config A bool "a" config B bool "b" imply A depends on A In the code above, Kconfig cannot calculate the symbol values correctly due to the circular dependency. For example, allyesconfig followed by syncconfig results in an odd behavior because CONFIG_B becomes visible in syncconfig. $ make allyesconfig scripts/kconfig/conf --allyesconfig Kconfig # # configuration written to .config # $ cat .config # # Automatically generated file; DO NOT EDIT. # Main menu # CONFIG_A=y $ make syncconfig scripts/kconfig/conf --syncconfig Kconfig * * Restart config... * * * Main menu * a (A) [Y/n/?] y b (B) [N/y/?] (NEW) To report this correctly, sym_check_expr_deps() should recurse to not only sym->rev_dep.expr but also sym->implied.expr . At this moment, sym_check_print_recursive() cannot distinguish 'select' and 'imply' since it does not know the precise context where the recursive dependency is hit. This will be solved by the next commit. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 4ec8b1f..7de7463a 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1098,7 +1098,7 @@ static void sym_check_print_recursive(struct symbol *last_sym) sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else { - fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + fprintf(stderr, "%s:%d:\tsymbol %s is selected or implied by %s\n", prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); @@ -1161,8 +1161,13 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) if (sym2) goto out; + sym2 = sym_check_expr_deps(sym->implied.expr); + if (sym2) + goto out; + for (prop = sym->prop; prop; prop = prop->next) { - if (prop->type == P_CHOICE || prop->type == P_SELECT) + if (prop->type == P_CHOICE || prop->type == P_SELECT || + prop->type == P_IMPLY) continue; stack.prop = prop; sym2 = sym_check_expr_deps(prop->visible.expr); From patchwork Tue Aug 14 06:43:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144102 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3977385ljj; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxYOwXlo1O577PkafKOjElKyg565u1swhA5aaMhYKz4ujO2BowGDFKWOm8DTJXuUjYLyNhS X-Received: by 2002:a63:291:: with SMTP id 139-v6mr19759053pgc.365.1534229113488; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534229113; cv=none; d=google.com; s=arc-20160816; b=KESDZoVBES7qFmzYXZFrgYuLCrg8MRDDH/Yn6FnfH7pHLSEk6517Zg52RiProov5NM uwHF0WeQ73xs6/uy3hBbezb1qL9ylRo8rx4iSaVogxNo8Drm3BIZCwXxzpxI78AZ3ILN m6gSwo/GSbqTBNEKlaGnBcTfPlRu84FwAAWqmW9mcFN/Axu5KAdVFvPhFiDSulkjCcH7 950i0ajGj1non9rA+WaEZJ+zKHml4D4u4zhWYcyLOFdZJzaHbG15B96cMZk0lEvGv6G6 Utknc6+UDeNl3hN+spLVv0KU1VAb0bpMhkWkVJrfuViReLe5eTbw+HNfJZprLAl63MzE +XZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=JwIvDu6TRXCLxKk8WhEsCQ2lFJvY0JE97KL4GS3A8xw=; b=BUIQHHF4tQ70Zh9k7Ja6EdS+ZdcyMrFCNsEOZX/iuL3Gkszqals12buRBLgJpcghru NdYtPeI5/Nj1fv7UQk7mSiNGPXigPrF8iOO168w97ES5z33zjtxX/N8phdIQ0NGHaMTH q6xCXl3RkeHKNsUWKSdwMCvJreUaBcE1zaJQtqgB94Liq0AV2k7FWeBaNF41o/yUdaiS DfekItVL5hYSE7fvDtmRVZwAtQTERJ9iSrOMF+uJIYfDg6ejU6qbLrcvOHeNtodQmc5k YjFpKWmFgFQ6isdvhjcRJJI/4gprMu0JDB2SLUJRaIWwm8DXHejhyE+rp09wrVRwNSrQ f8pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=0BXxIaJx; 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 w65-v6si19477104pgb.377.2018.08.13.23.45.13; Mon, 13 Aug 2018 23:45:13 -0700 (PDT) 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=0BXxIaJx; 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 S1731680AbeHNJa5 (ORCPT + 31 others); Tue, 14 Aug 2018 05:30:57 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:55702 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731066AbeHNJa4 (ORCPT ); Tue, 14 Aug 2018 05:30:56 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id w7E6hiBB014737; Tue, 14 Aug 2018 15:43:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w7E6hiBB014737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534229026; bh=JwIvDu6TRXCLxKk8WhEsCQ2lFJvY0JE97KL4GS3A8xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0BXxIaJxgzYI9IuDN30bHKIU1yINEYCOltZ7FAaqLv5nS9BOPxSF6tpMj9gy3LAMI GPXZs3MoErAKDJ6SgOzvCn9c0qhIjyp94qvvn42o8dEqMH5RWdQWM3bGDxISzFYLFL k6TrBmZXK8I5qkMqPOVUj8rBSvQ0pmlW1zrx5yp4NN7ry8eLxvNu4WWLF+rFcPALLT 55FGDOBc7Ohjl04iwSQ4Ir64GYVLtWc2Po95vnpe1ZRKNWtaUWzqUi4P9E19mVYjLR Ghn5oxWQK7sCKjf+kdYQsK9Z7+PZ91Dxcp5mIUHpxMsdFDld1m60xN7E+HX2QEGivC ZFDEMoO+pa1LA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Dirk Gouders , Ulf Magnusson , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kconfig: improve the recursive dependency report Date: Tue, 14 Aug 2018 15:43:41 +0900 Message-Id: <1534229021-8056-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534229021-8056-1-git-send-email-yamada.masahiro@socionext.com> References: <1534229021-8056-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit improves the warning messages of the recursive dependency. Currently, sym->dir_dep.expr is not checked. Hence, any dependency in property visibility is regarded as the dependency of the symbol. [Test Code 1] config A bool "a" depends on B config B bool "b" depends on A [Test Code 2] config A bool "a" if B config B bool "b" depends on A For both cases above, the same message is displayed: symbol B depends on A symbol A depends on B This commit changes the message for the latter case like this: symbol B depends on A symbol A prompt is visible depending on B Also, 'select' and 'imply' are distinguished. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 7de7463a..9cc443b 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1011,7 +1011,7 @@ static struct dep_stack { struct dep_stack *prev, *next; struct symbol *sym; struct property *prop; - struct expr *expr; + struct expr **expr; } *check_top; static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) @@ -1076,31 +1076,42 @@ static void sym_check_print_recursive(struct symbol *last_sym) fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", prop->file->name, prop->lineno); - if (stack->expr) { - fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", - prop->file->name, prop->lineno, + if (sym_is_choice(sym)) { + fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } else if (sym_is_choice_value(sym)) { + fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", + menu->file->name, menu->lineno, sym->name ? sym->name : "", - prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); - } else if (stack->prop) { + } else if (stack->expr == &sym->dir_dep.expr) { fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); - } else if (sym_is_choice(sym)) { - fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", - menu->file->name, menu->lineno, + } else if (stack->expr == &sym->rev_dep.expr) { + fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); - } else if (sym_is_choice_value(sym)) { - fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", - menu->file->name, menu->lineno, + } else if (stack->expr == &sym->implied.expr) { + fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n", + prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); + } else if (stack->expr) { + fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "", + prop_get_type_name(prop->type), + next_sym->name ? next_sym->name : ""); } else { - fprintf(stderr, "%s:%d:\tsymbol %s is selected or implied by %s\n", + fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n", prop->file->name, prop->lineno, sym->name ? sym->name : "", + prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); } } @@ -1157,14 +1168,23 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) dep_stack_insert(&stack, sym); + stack.expr = &sym->dir_dep.expr; + sym2 = sym_check_expr_deps(sym->dir_dep.expr); + if (sym2) + goto out; + + stack.expr = &sym->rev_dep.expr; sym2 = sym_check_expr_deps(sym->rev_dep.expr); if (sym2) goto out; + stack.expr = &sym->implied.expr; sym2 = sym_check_expr_deps(sym->implied.expr); if (sym2) goto out; + stack.expr = NULL; + for (prop = sym->prop; prop; prop = prop->next) { if (prop->type == P_CHOICE || prop->type == P_SELECT || prop->type == P_IMPLY) @@ -1175,7 +1195,7 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) break; if (prop->type != P_DEFAULT || sym_is_choice(sym)) continue; - stack.expr = prop->expr; + stack.expr = &prop->expr; sym2 = sym_check_expr_deps(prop->expr); if (sym2) break;