From patchwork Wed Aug 15 05:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144267 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp432815ljj; Tue, 14 Aug 2018 23:01:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwuJ+8WuM1Tay77aLVou4yy/SxD3aw1LBTg1ZISI92YGpe8km7fJj8zJNxhXLjbv1tOYvAC X-Received: by 2002:a63:4924:: with SMTP id w36-v6mr24120070pga.143.1534312892073; Tue, 14 Aug 2018 23:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534312892; cv=none; d=google.com; s=arc-20160816; b=i3DPDetLHNekV9IiaI/gxI6P/13eMZw3lcmzMscbqDefP6nJ/GJsaUKPMlkwPu8ffJ YfiC6HXYp4G12gIfk2wTt/t04/CAfnWseHft3aE8S/uqnvkp+lF6zWPSPS7Q/7YpWr1g q0OfpKxCGep5+5f6V8MrK7S+Yl3niUxpn+WHE7n7HuNs7exGkl2kLYeQfDV/NcP7a/u7 aaWEbxdmoJ76GGQpGxx/R1GzLusyCEkK38VyDtDQ2knbhaylZOX66yF9v7DVbpVb2zdj ZCOTcKgs7HcQe9AzYlfXIpPOTerAZEDGVgCV2AWDhlySUf/e81kezLhRFIszsX+LbhNF zFKQ== 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=oULS+0WXiytoM/CiXvb0+OtUros6tp5B9Xh7Pk6/W0Y=; b=vTTs88DRwUnMflQudRiRN6xkZUmXm52ob229FydmprHNRqW4eZAe9wW1tOH/aqNMAd Km8WL35t2DuLOs9gvoJ7YT9k7vhnp7t6oyGL8TwxFThBF4O+WtK++SfOQHILZ/83jxS0 2ZPDRU3ZjjwUcs23w89vF30l3YKjamDomzlmtD56QB6dzLAq1YWhI5nTV4my6TipHhDC EcMwzybE7cHouCkH8qWDhvF30NYIXGfxOq+RDb/AwE8R+aM0hRmZQosk33db67L2ENpB BVbQWshZdS+a4AaG8bHQ++qBfzZg5Sd424CDmPbgv+abWp3faWTuMFztd+Jwvl/K9s19 1CrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kQdQhrX+; 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 e10-v6si22886163pgm.94.2018.08.14.23.01.31; Tue, 14 Aug 2018 23:01:32 -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=kQdQhrX+; 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 S1726422AbeHOIwI (ORCPT + 32 others); Wed, 15 Aug 2018 04:52:08 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:54026 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbeHOIwI (ORCPT ); Wed, 15 Aug 2018 04:52:08 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-12.nifty.com with ESMTP id w7F5xsZi013655; Wed, 15 Aug 2018 14:59:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w7F5xsZi013655 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534312794; bh=oULS+0WXiytoM/CiXvb0+OtUros6tp5B9Xh7Pk6/W0Y=; h=From:To:Cc:Subject:Date:From; b=kQdQhrX+SEpT+1rjBaFTkkL8rxuHhfHq8wJ4ojJ6/C81mxE63L2M0HiOeKcyr3bO8 OzooqJbz4EiR8W3xm7O4O3eneT3JpPBLchjb3ehV0BNgmpkdsuQK3GAqWb3i2KHkPG xukfE2v1RaB6egch/rA1dBEf88QvyhaT/DdsrQGm+AObUDe7Wqnm9dS6lNeN1VcGts IgSgOdmUfe3RkFzpMFQBbJ/N73z7QsYZOBTPS0/ol2IyhORRxY0lInkh5G0BGXJ/az Fmshwf0CmX53DOyRwWZcsm4rlIPZVUKIUup/xtjsSA3aWg7Q8WucgPR/s5vO90ErI6 O9NBMYmZRU+3Q== 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 v2 1/3] kconfig: error out when seeing recursive dependency Date: Wed, 15 Aug 2018 14:59:43 +0900 Message-Id: <1534312785-28434-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 Originally, recursive dependency was a fatal error for Kconfig because Kconfig cannot compute symbol values in such a situation. Commit d595cea62403 ("kconfig: print more info when we see a recursive dependency") changed it to a warning, which I guess was not intentional. Get it back to an error again. Also, rename the unit test directory "warn_recursive_dep" to "err_recursive_dep" so that it matches to the behavior. Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added scripts/kconfig/symbol.c | 3 --- .../tests/{warn_recursive_dep => err_recursive_dep}/Kconfig | 0 scripts/kconfig/tests/err_recursive_dep/__init__.py | 10 ++++++++++ .../{warn_recursive_dep => err_recursive_dep}/expected_stderr | 0 scripts/kconfig/tests/warn_recursive_dep/__init__.py | 9 --------- 5 files changed, 10 insertions(+), 12 deletions(-) rename scripts/kconfig/tests/{warn_recursive_dep => err_recursive_dep}/Kconfig (100%) create mode 100644 scripts/kconfig/tests/err_recursive_dep/__init__.py rename scripts/kconfig/tests/{warn_recursive_dep => err_recursive_dep}/expected_stderr (100%) delete mode 100644 scripts/kconfig/tests/warn_recursive_dep/__init__.py -- 2.7.4 Tested-by: Dirk Gouders diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 4ec8b1f..688f487 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1248,9 +1248,6 @@ struct symbol *sym_check_deps(struct symbol *sym) sym->flags &= ~SYMBOL_CHECK; } - if (sym2 && sym2 == sym) - sym2 = NULL; - return sym2; } diff --git a/scripts/kconfig/tests/warn_recursive_dep/Kconfig b/scripts/kconfig/tests/err_recursive_dep/Kconfig similarity index 100% rename from scripts/kconfig/tests/warn_recursive_dep/Kconfig rename to scripts/kconfig/tests/err_recursive_dep/Kconfig diff --git a/scripts/kconfig/tests/err_recursive_dep/__init__.py b/scripts/kconfig/tests/err_recursive_dep/__init__.py new file mode 100644 index 0000000..5f3821b --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_dep/__init__.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Detect recursive dependency error. + +Recursive dependency should be treated as an error. +""" + +def test(conf): + assert conf.oldaskconfig() == 1 + assert conf.stderr_contains('expected_stderr') diff --git a/scripts/kconfig/tests/warn_recursive_dep/expected_stderr b/scripts/kconfig/tests/err_recursive_dep/expected_stderr similarity index 100% rename from scripts/kconfig/tests/warn_recursive_dep/expected_stderr rename to scripts/kconfig/tests/err_recursive_dep/expected_stderr diff --git a/scripts/kconfig/tests/warn_recursive_dep/__init__.py b/scripts/kconfig/tests/warn_recursive_dep/__init__.py deleted file mode 100644 index adb2195..0000000 --- a/scripts/kconfig/tests/warn_recursive_dep/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -Warn recursive inclusion. - -Recursive dependency should be warned. -""" - -def test(conf): - assert conf.oldaskconfig() == 0 - assert conf.stderr_contains('expected_stderr') From patchwork Wed Aug 15 05:59:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144268 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp432876ljj; Tue, 14 Aug 2018 23:01:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzF9SCJelAPHIzX2p7MIELn0PMEK9Kg5v4kT6br1gnNvQznJK4uGRIFFJdnkwVTl7ymsb6U X-Received: by 2002:a17:902:583:: with SMTP id f3-v6mr23024639plf.115.1534312894760; Tue, 14 Aug 2018 23:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534312894; cv=none; d=google.com; s=arc-20160816; b=Nw/m1z9LOcTTRhiaai++dfNnhmhGjmAL9iTsdA2BDohUtiNylNysGnmBokaZ6849PH sNnqYrCx+VwwwwYutPvvaX+a1mECA5L9yKY7NA3zLqcOuB4bF+S33q81JyzW0vqCZT8/ +0TjuIDWP48/30GgLu9KvtDjpYAH05u7IPtTTTFsMz9QNLrlW3jLYIlUHRRzg6oCHufH kTV4s3znG0/6LfzCsv8ix3KKmhgML5Kz/CvCCu7HfZYFL+A6v7WW+TfyjP44asKtNR0K EDfcxHYHrFBKSyoT2r4y02cyos6sBfrmYr3ybBc2cWF6A62jrUPxNZRNKVu7Pfst17cn iMyg== 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=+YSDxX8uowPXcN9orKBzvmOcHcB7atfWoNjn8pQB4Pw=; b=SNX2o5FEw1zCOi8P2s2qZ7noN0grjah7pOJ2S+A6dfubrULQX2kzVHCiQkjsAPW/M9 lze8v7mdRf6lC6DDZNKxQuFv5zhOYamUyIXxejBeVb51FuN55XdMiDyMvKGtKWOhfdTA 9YJVEFxbz73n6UK0pMG5xnL96RsKUi1S9HGnulc4BbU9L8RULAvGVK537qLcWxPYL9E1 f+CXLhnVnYToDdMqPyz4nnq1Vb1d0N8Gwp459MRLgn6bZyyNHPJ3YzWyzrXA4hep16AO 8M9OGPXcEaglR08aAuTSGJ3kCxd5s4XTbCMDQmkZyTSfTMLnLS76u2qF2Svy/5KXrMRZ nMMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jM6b56aa; 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 e1-v6si19489160pgo.325.2018.08.14.23.01.34; Tue, 14 Aug 2018 23:01:34 -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=jM6b56aa; 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 S1728663AbeHOIwR (ORCPT + 32 others); Wed, 15 Aug 2018 04:52:17 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:54244 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbeHOIwQ (ORCPT ); Wed, 15 Aug 2018 04:52:16 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-12.nifty.com with ESMTP id w7F5xsZj013655; Wed, 15 Aug 2018 14:59:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w7F5xsZj013655 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534312795; bh=+YSDxX8uowPXcN9orKBzvmOcHcB7atfWoNjn8pQB4Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jM6b56aaaBV3K6yr+G8FwYLHiHo2rFytD0qWo5dcfOVvUEoecQ/pH8l+HxTWn+3Df rn2eEcy/bmp+sJ5z2OUovQBdOe80pYJNz1Xb2S12B8bXfkCQXiyYvx+kvJR6Q0NXO5 DhzmwUfz0eb7I/R87gpUPepnP39CBmvulwztFxVAQiZdI2xWyl4oqJ+ogoXPJtjYJI XHyZjji44oCDakEHUWc6FXC5NMKe94TuEj5dYEW7Xhd2o9xJQNVi0xtv4YJxykv56x PtQNO4RuRPpNgAUrjlbDl2X1SmBbF4NzhyEzQsnpFHDoHtZv4+EsqFcXSW3ydNvWU2 nY2t0A2AgD58w== 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-doc@vger.kernel.org, Jonathan Corbet , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] kconfig: report recursive dependency involving 'imply' Date: Wed, 15 Aug 2018 14:59:44 +0900 Message-Id: <1534312785-28434-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534312785-28434-1-git-send-email-yamada.masahiro@socionext.com> References: <1534312785-28434-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 Currently, Kconfig does not complain 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 detect 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 has been hit. This will be solved by the next commit. In fact, even the document and the unit-test are confused. Using 'imply' does not solve recursive dependency since 'imply' addresses the unmet direct dependency, which 'select' could cause. Signed-off-by: Masahiro Yamada --- Changes in v2: - Fix documentation and unit-test Documentation/kbuild/kconfig-language.txt | 3 +- scripts/kconfig/symbol.c | 9 +++-- scripts/kconfig/tests/err_recursive_dep/Kconfig | 3 +- .../tests/err_recursive_dep/expected_stderr | 38 +++++++++++++--------- 4 files changed, 33 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index c54cb7c..864e740 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -545,7 +545,7 @@ make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig Practical solutions to kconfig recursive issue ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Developers who run into the recursive Kconfig issue have three options +Developers who run into the recursive Kconfig issue have two options at their disposal. We document them below and also provide a list of historical issues resolved through these different solutions. @@ -553,7 +553,6 @@ historical issues resolved through these different solutions. b) Match dependency semantics: b1) Swap all "select FOO" to "depends on FOO" or, b2) Swap all "depends on FOO" to "select FOO" - c) Consider the use of "imply" instead of "select" The resolution to a) can be tested with the sample Kconfig file Documentation/kbuild/Kconfig.recursion-issue-01 through the removal diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 688f487..90e70609 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); diff --git a/scripts/kconfig/tests/err_recursive_dep/Kconfig b/scripts/kconfig/tests/err_recursive_dep/Kconfig index a65bfcb..ebdb3ff 100644 --- a/scripts/kconfig/tests/err_recursive_dep/Kconfig +++ b/scripts/kconfig/tests/err_recursive_dep/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + # depends on itself config A @@ -31,7 +33,6 @@ config D2 bool # depends on and imply -# This is not recursive dependency config E1 bool "E1" diff --git a/scripts/kconfig/tests/err_recursive_dep/expected_stderr b/scripts/kconfig/tests/err_recursive_dep/expected_stderr index 3de807d..2eb2528 100644 --- a/scripts/kconfig/tests/err_recursive_dep/expected_stderr +++ b/scripts/kconfig/tests/err_recursive_dep/expected_stderr @@ -1,30 +1,38 @@ -Kconfig:9:error: recursive dependency detected! -Kconfig:9: symbol B is selected by B +Kconfig:11:error: recursive dependency detected! +Kconfig:11: symbol B is selected or implied by B For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" -Kconfig:3:error: recursive dependency detected! -Kconfig:3: symbol A depends on A +Kconfig:5:error: recursive dependency detected! +Kconfig:5: symbol A depends on A For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" -Kconfig:15:error: recursive dependency detected! -Kconfig:15: symbol C1 depends on C2 -Kconfig:19: symbol C2 depends on C1 +Kconfig:17:error: recursive dependency detected! +Kconfig:17: symbol C1 depends on C2 +Kconfig:21: symbol C2 depends on C1 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" -Kconfig:30:error: recursive dependency detected! -Kconfig:30: symbol D2 is selected by D1 -Kconfig:25: symbol D1 depends on D2 +Kconfig:32:error: recursive dependency detected! +Kconfig:32: symbol D2 is selected or implied by D1 +Kconfig:27: symbol D1 depends on D2 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" -Kconfig:59:error: recursive dependency detected! -Kconfig:59: symbol G depends on G +Kconfig:37:error: recursive dependency detected! +Kconfig:37: symbol E1 depends on E2 +Kconfig:42: symbol E2 is selected or implied by E1 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" -Kconfig:50:error: recursive dependency detected! -Kconfig:50: symbol F2 depends on F1 -Kconfig:48: symbol F1 default value contains F2 +Kconfig:60:error: recursive dependency detected! +Kconfig:60: symbol G depends on G +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:51:error: recursive dependency detected! +Kconfig:51: symbol F2 depends on F1 +Kconfig:49: symbol F1 default value contains F2 +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" From patchwork Wed Aug 15 05:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144266 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp432683ljj; Tue, 14 Aug 2018 23:01:27 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyLiVfGlQ2AAYERrG4XGNtAam8kg2Ehc6jmRfKwQiCe/fkvA2KQjMjJpH9Bv8qEjp4Qfv9i X-Received: by 2002:a63:e949:: with SMTP id q9-v6mr23815515pgj.4.1534312886988; Tue, 14 Aug 2018 23:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534312886; cv=none; d=google.com; s=arc-20160816; b=sk7cthbODHOkf2TPdf64OhqAq59THJDTsqpPAUK7aq5EmFmuKTT1XSE4hUK4Mpz+DQ yW1mAD3I8xTni1R8w+Ip24KUByQHoavXHAsevAgr2y7pm77JbR4+PLmiM2F04IyobZlc j1Denz/1PzxbhPiWZU/iZtJoMJpnvRzZ7tw/G7TlSfkPnGgrNWuuVHddu+pOJTS5sSr6 +9RUkKUMi9GkCx/N1Qngh1RDzlLGcN7PvOnXoU7Y0p+eJlyxPJT5GHrGccHeaH4POjPi HPlRLxJc8umB9oYxtoS20g1AGYNpgYk9cwxSi0Ugzm7TeOdKyl9UYJyRA4xVM1zfY2mJ 57rw== 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=p4Q4Z5Gs1yt+lCyn3wpiQ3ldS/HwZ89fTXOgjslf4FU=; b=ArHNdukU18n7O9FR7XL4a7mMwOBTTmaCEAq7Bladf/1xmXVbP3dxO+OdIXbegQ959U WPnYIdp/b6rRuYzzbt/KRA4fUbcX41xG8P9TDlZsp/DIC7xITABroadtMpll6S2rO+rj TMqZYxZj70IZS3k0hMSlATOSN9XmaHd1mVsnivGgjrgO2RsaGn6HdarxFv0NerJ2KZfz NtXeCKOEW6s3W/ddvPTxBb/ZgwK6Vxil8SOcUizeIk9zaD0eeDjO0a3O3mg+74i2HYdl gPqf9v/Sk6gqWwMr4MOQL74+MZmtpwAgixTAqdcPpYC51OGNxwFwbPqGW2CfDjqtnhQU WXdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=0nvR7fB9; 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 e205-v6si23467344pfh.158.2018.08.14.23.01.26; Tue, 14 Aug 2018 23:01:26 -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=0nvR7fB9; 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 S1728523AbeHOIwJ (ORCPT + 32 others); Wed, 15 Aug 2018 04:52:09 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:54027 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbeHOIwI (ORCPT ); Wed, 15 Aug 2018 04:52:08 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-12.nifty.com with ESMTP id w7F5xsZk013655; Wed, 15 Aug 2018 14:59:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w7F5xsZk013655 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534312796; bh=p4Q4Z5Gs1yt+lCyn3wpiQ3ldS/HwZ89fTXOgjslf4FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0nvR7fB9NRfTd2X2nqTni1brG1azxLAQelcdwqEDxX46DzBy9/gFuI59V55nXQ+LC RZ1C8m3H99/vafQmpit87hMWsBDStyIgeicxHbz3kdBQ4nJfBbPQBpTgQn8gyZzkOV XDRRwOsArczD1PxLYTa95fGh3AQw4mIgd7JW1/fE7PquAf9BObXjNhxvt/ZhNRyAIz fv2VoDIfuhmEOMBHW9RpBMWji1jge5vGYa+tGgC/HhQ9Y1n/s5BmK/S599i0ZHRucX QCqA6Zo53zPkbXUO/gtMoNpkFae6wlSGpHMsHLK4JOWjf2k1vFWlMQofyPjXv4kFvw p3HZ3KepqfO/w== 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 v2 3/3] kconfig: improve the recursive dependency report Date: Wed, 15 Aug 2018 14:59:45 +0900 Message-Id: <1534312785-28434-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534312785-28434-1-git-send-email-yamada.masahiro@socionext.com> References: <1534312785-28434-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 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 --- Changes in v2: - Update unit test scripts/kconfig/symbol.c | 48 +++++++++++++++------- .../tests/err_recursive_dep/expected_stderr | 6 +-- 2 files changed, 37 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 90e70609..703b9b8 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; diff --git a/scripts/kconfig/tests/err_recursive_dep/expected_stderr b/scripts/kconfig/tests/err_recursive_dep/expected_stderr index 2eb2528..84679b1 100644 --- a/scripts/kconfig/tests/err_recursive_dep/expected_stderr +++ b/scripts/kconfig/tests/err_recursive_dep/expected_stderr @@ -1,5 +1,5 @@ Kconfig:11:error: recursive dependency detected! -Kconfig:11: symbol B is selected or implied by B +Kconfig:11: symbol B is selected by B For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" @@ -15,14 +15,14 @@ For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" Kconfig:32:error: recursive dependency detected! -Kconfig:32: symbol D2 is selected or implied by D1 +Kconfig:32: symbol D2 is selected by D1 Kconfig:27: symbol D1 depends on D2 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" Kconfig:37:error: recursive dependency detected! Kconfig:37: symbol E1 depends on E2 -Kconfig:42: symbol E2 is selected or implied by E1 +Kconfig:42: symbol E2 is implied by E1 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations"