Message ID | 20230504201833.202494-2-darwi@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp597171vqo; Thu, 4 May 2023 13:46:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dvd0RXs2TnWT9bWrIAlxkhDkMw5Hn4apo5V48gzFBYT3PXxMa6/vc/uH9GU2UtIVAG6bP X-Received: by 2002:a05:6a20:3ca5:b0:f3:cac4:ca5d with SMTP id b37-20020a056a203ca500b000f3cac4ca5dmr4485357pzj.35.1683233184413; Thu, 04 May 2023 13:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233184; cv=none; d=google.com; s=arc-20160816; b=l7NSePAhK7ki7stIoM2wKwCw9rhYvG/EzG2O8iy5Es0W6aIloWi6MmZm19QAAiMt7P cXtcN+uznoUQRxCNIjZYdlYkqLgdjIhuEEtNN8ab3U11f3g7+eJ5BupK7zTfb8nl4D/h kZ0eVm9EEtndCOT9/KyeE7zFOLoyT9fiRnLFHBh5tqJR1X+7Mo2MYyjr+GWFhGZ4O9Wo EugXsl4srfWjjjg9ugABt2JTD6vH1cHiuZrM/A8NKHxbgMqU6VHYqOUbzB3jtCXrwbRX rG4alc3+PCQBse2IsquNqseoWYTwfjpwXSbtIbSyI2PGnZ0VpXXLjuGoB3z7SImAYLX6 2HGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=XQ86TMvno5qeng6U0rCVgoMQaGJVwnTJIy9oD2h9Q1A=; b=j+U+DKsHVv4J8jeme3WbHuhQ8d1BjIiBaR39B9Yz8Xlf4Fw6SF3eDLi6HP4oAMdcq7 DrmsdbEGlB7oMnuuce4Et2Rtm67/tZs+Gp2FQTzqm+Tz7CP5qRQfqxme9AFFNBZybblm yLAitxyc8ku8EazVCzx9WJE91R+AT8L+p7bEIJjUpL+qiAcp0+TlVRr8DIUr2WhOV75d troNGS1iQ0ATIohuhXa8MUg7CSNPGB9tmNliPPLG3MYgQhqJ55wSFGkoo9eH+LzzEOuU GN798Tqk1tNyU2c4fsHt2eBYASjjmLpzDX9BjUUopGCbsLmDAkdbTGEqNWu3frdQoaz9 43Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="BEE9oUQ/"; dkim=neutral (no key) header.i=@linutronix.de header.b=M4w+POcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o30-20020a637e5e000000b00513af1fa0b5si212670pgn.797.2023.05.04.13.46.11; Thu, 04 May 2023 13:46:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="BEE9oUQ/"; dkim=neutral (no key) header.i=@linutronix.de header.b=M4w+POcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjEDUbb (ORCPT <rfc822;b08248@gmail.com> + 99 others); Thu, 4 May 2023 16:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbjEDUbO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 4 May 2023 16:31:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70D518DCA; Thu, 4 May 2023 13:20:03 -0700 (PDT) From: "Ahmed S. Darwish" <darwi@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683231558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQ86TMvno5qeng6U0rCVgoMQaGJVwnTJIy9oD2h9Q1A=; b=BEE9oUQ/E2WZ1iOrhE5rFNn7EV5qH7DX8gPHCT11aJrUiXf3PxrF/5hqFdCeg9DOvCYFlm BKBTKhA9ABi4/TqM6rNfDfSRx2JGaBERFCwFZXC5kGnnvCap+TLx3LcNgMgq8Y/ymRxfUd vt7bOcG1QerPAeaEpEGYWq/74wVc0vaicLN8zg600580VpDNhhXjduFGMTxf1G9SYfq1jA Hpy//bDtkaLjtEuzlrhRaar6+4it0UgzSVtU+dp5u/PMBq5cYdcpNeVLK6yKGh3AzjHhrg 6cuwfvo95TTjBjcUYQJqJ8TeIMe3+JhImTMO8FEFu0acu/GaiEdgNFW9rgvrEg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683231558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQ86TMvno5qeng6U0rCVgoMQaGJVwnTJIy9oD2h9Q1A=; b=M4w+POcjZb2xIsQOBUzBJeslZ2v85/wkjHh+e8SvBtE9m4SbvpmFev6+6JmT61ROUnd4AX 10NbKaqPaMOxfuBQ== To: Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu> Cc: Thomas Gleixner <tglx@linutronix.de>, linux-kbuild@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>, "Ahmed S. Darwish" <darwi@linutronix.de> Subject: [PATCH v1 1/1] scripts/tags.sh: Fix gtags generation for O= kernel builds Date: Thu, 4 May 2023 22:18:33 +0200 Message-Id: <20230504201833.202494-2-darwi@linutronix.de> In-Reply-To: <20230504201833.202494-1-darwi@linutronix.de> References: <20230504201833.202494-1-darwi@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764997919927306189?= X-GMAIL-MSGID: =?utf-8?q?1764997919927306189?= |
Series |
scripts: Fix "make gtags" for O= kernel builds
|
|
Commit Message
Ahmed S. Darwish
May 4, 2023, 8:18 p.m. UTC
gtags considers any file outside of its current working directory
"outside the source tree" and refuses to index it.
For O= kernel builds, scripts/tags.sh invokes gtags with the current
working directory set to ${O}. This leads to gtags ignoring the entire
kernel source and generating an empty index.
For O= builds, set gtags' working directory to the kernel source tree
and explicitly set its output path through parameters instead.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
scripts/tags.sh | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Comments
On Thu, May 04, 2023 at 10:18:33PM +0200, Ahmed S. Darwish wrote: > gtags considers any file outside of its current working directory > "outside the source tree" and refuses to index it. > > For O= kernel builds, scripts/tags.sh invokes gtags with the current > working directory set to ${O}. This leads to gtags ignoring the entire > kernel source and generating an empty index. > > For O= builds, set gtags' working directory to the kernel source tree > and explicitly set its output path through parameters instead. > > Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de> Reviewed-by: Nathan Chancellor <nathan@kernel.org> > --- > scripts/tags.sh | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/tags.sh b/scripts/tags.sh > index ea31640b2671..1a6db535503b 100755 > --- a/scripts/tags.sh > +++ b/scripts/tags.sh > @@ -131,7 +131,14 @@ docscope() > > dogtags() > { > - all_target_sources | gtags -i -f - > + # gtags refuses to index any file outside of the current working > + # directory. For O= builds, set the current working directory to > + # the kernel source tree and the output tags dir to ${O}. > + suffixparams= > + if [ -v O ]; then I think if [ -n "$O" ]; then would match the style preferred by Kbuild (though that is usually for portability sake, which probably does not matter here since bash is explicitly requested). Perhaps not worth addressing if there is no other reason for a v2. > + suffixparams="-C $tree $O" > + fi > + all_target_sources | gtags -i -f - $suffixparams > } > > # Basic regular expressions with an optional /kind-spec/ for ctags and > -- > 2.30.2 >
Hi Nathan, On Thu, 04 May 2023, Nathan Chancellor wrote: > > On Thu, May 04, 2023 at 10:18:33PM +0200, Ahmed S. Darwish wrote: ... > > + suffixparams= > > + if [ -v O ]; then > > I think > > if [ -n "$O" ]; then > > would match the style preferred by Kbuild (though that is usually for > portability sake, which probably does not matter here since bash is > explicitly requested). Perhaps not worth addressing if there is no other > reason for a v2. > Thanks, I'll do it. I've just discovered that a v2 is necessary anyway. If O= has a "~", for example as in: make O=~/build/ gtags the snippet below: > > + suffixparams="-C $tree $O" > > + fi > > + all_target_sources | gtags -i -f - $suffixparams ^ will fail since the "~" in the O= directory path won't get dereferenced before getting passed to the gtags call (an eval is needed). I'll submit a v2 shortly. Kind regards, -- Ahmed S. Darwish Linutronix GmbH
On Fri, May 5, 2023 at 12:00 AM Ahmed S. Darwish <darwi@linutronix.de> wrote: > > Hi Nathan, > > On Thu, 04 May 2023, Nathan Chancellor wrote: > > > > On Thu, May 04, 2023 at 10:18:33PM +0200, Ahmed S. Darwish wrote: > ... > > > + suffixparams= > > > + if [ -v O ]; then > > > > I think > > > > if [ -n "$O" ]; then > > > > would match the style preferred by Kbuild (though that is usually for > > portability sake, which probably does not matter here since bash is > > explicitly requested). Perhaps not worth addressing if there is no other > > reason for a v2. > > > > Thanks, I'll do it. I've just discovered that a v2 is necessary anyway. > > If O= has a "~", for example as in: > > make O=~/build/ gtags > > the snippet below: > > > > + suffixparams="-C $tree $O" > > > + fi > > > + all_target_sources | gtags -i -f - $suffixparams > ^ > will fail since the "~" in the O= directory path won't get dereferenced > before getting passed to the gtags call (an eval is needed). > > I'll submit a v2 shortly. > > Kind regards, > > -- > Ahmed S. Darwish > Linutronix GmbH It is wrong to check whether you are building out of the source tree. See line 159 of the Makefile. BTW, this patch does not work for me. It spits a ton of "not found" warnings, then generates empty tags. $ make O=build gtags make[1]: Entering directory '/home/masahiro/ref/linux/build' GEN gtags Warning: '../arch/x86/include/asm/vmalloc.h' not found. ignored. Warning: '../arch/x86/include/asm/pgtable-3level_types.h' not found. ignored. Warning: '../arch/x86/include/asm/paravirt.h' not found. ignored. Warning: '../arch/x86/include/asm/text-patching.h' not found. ignored. Warning: '../arch/x86/include/asm/softirq_stack.h' not found. ignored. Warning: '../arch/x86/include/asm/intel_ds.h' not found. ignored. Warning: '../arch/x86/include/asm/resctrl.h' not found. ignored. Warning: '../arch/x86/include/asm/setup_arch.h' not found. ignored. Warning: '../arch/x86/include/asm/simd.h' not found. ignored. Warning: '../arch/x86/include/asm/mmconfig.h' not found. ignored. Warning: '../arch/x86/include/asm/pgtable_types.h' not found. ignored. Warning: '../arch/x86/include/asm/mem_encrypt.h' not found. ignored. Warning: '../arch/x86/include/asm/dmi.h' not found. ignored. Warning: '../arch/x86/include/asm/thermal.h' not found. ignored. ...
On Fri, May 5, 2023 at 7:13 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Fri, May 5, 2023 at 12:00 AM Ahmed S. Darwish <darwi@linutronix.de> wrote: > > > > Hi Nathan, > > > > On Thu, 04 May 2023, Nathan Chancellor wrote: > > > > > > On Thu, May 04, 2023 at 10:18:33PM +0200, Ahmed S. Darwish wrote: > > ... > > > > + suffixparams= > > > > + if [ -v O ]; then > > > > > > I think > > > > > > if [ -n "$O" ]; then > > > > > > would match the style preferred by Kbuild (though that is usually for > > > portability sake, which probably does not matter here since bash is > > > explicitly requested). Perhaps not worth addressing if there is no other > > > reason for a v2. > > > > > > > Thanks, I'll do it. I've just discovered that a v2 is necessary anyway. > > > > If O= has a "~", for example as in: > > > > make O=~/build/ gtags > > > > the snippet below: > > > > > > + suffixparams="-C $tree $O" > > > > + fi > > > > + all_target_sources | gtags -i -f - $suffixparams > > ^ > > will fail since the "~" in the O= directory path won't get dereferenced > > before getting passed to the gtags call (an eval is needed). > > > > I'll submit a v2 shortly. > > > > Kind regards, > > > > -- > > Ahmed S. Darwish > > Linutronix GmbH > > > > It is wrong to check whether you are building out of the > source tree. See line 159 of the Makefile. Let me correct this sentense. It is wrong to use 'O' to check whether you are building out of the source tree.
Hi Masahiro, On Fri, 05 May 2023, Masahiro Yamada wrote: > > It is wrong to check whether you are building out of the > source tree. See line 159 of the Makefile. > Oh, didn't think about that case. Thanks for the reference and the further clarification in reply. I'll remove the ${O} check then and use saner mechanisms. > BTW, this patch does not work for me. > It spits a ton of "not found" warnings, then generates > empty tags. > > > $ make O=build gtags Interesting... When doing: $ make O=../build gtags scripts/tags.sh "$tree" variable is set to the absolute path of the kernel source tree. Thus all the paths fed to gtags are absolute and this patch series works. When doing what you tested with: $ make O=build/ gtags scripts/tags.sh "$tree" variable is set to the path of the kernel source tree *relative* to O=build/. So in that case kernel source "$tree" equals ".." With this series, the build will fail as gtags current working dir is the kernel source tree, and all the fed paths are thus invalid as they're relative to O=build/ instead. Without this series the build will still fail given the original problem of having the files "outside the source tree", where gtags thinks the source tree is "build/". I'll think of something that can cover the both cases. Kind regards, Ahmed -- Linutronix GmbH
diff --git a/scripts/tags.sh b/scripts/tags.sh index ea31640b2671..1a6db535503b 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -131,7 +131,14 @@ docscope() dogtags() { - all_target_sources | gtags -i -f - + # gtags refuses to index any file outside of the current working + # directory. For O= builds, set the current working directory to + # the kernel source tree and the output tags dir to ${O}. + suffixparams= + if [ -v O ]; then + suffixparams="-C $tree $O" + fi + all_target_sources | gtags -i -f - $suffixparams } # Basic regular expressions with an optional /kind-spec/ for ctags and