Documentation/process/changes.rst | 7 +++++++ scripts/tags.sh | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
Hi,
v2-changelog
------------
Handle review remarks from Masahiro Yamada:
- scripts/tags.sh: remove the O= language, and focus on the general
case of the build directory being different from the kernel source
tree, as specified in kernel Makefile L159.
- Fix failure when build directory is a subdirectory of the kernel
source tree.
NEW:
- Update Documentation/process/changes.rst with new gtags (GNU GLOBAL)
requirements.
Thanks!
Cover letter / v1
-----------------
https://lkml.kernel.org/r/20230504201833.202494-1-darwi@linutronix.de
make gtags for O= kernel builds is currently broken. For example, when doing:
make O=../build/ x86_64_defconfig
make O=../build/ gtags
gtags generates a warning for each kernel source file to be indexed:
make[1]: Entering directory '/home/darwi/build'
GEN gtags
Warning: '/home/darwi/linux/arch/x86/include/asm/qspinlock.h' is out of source tree. ignored.
Warning: '/home/darwi/linux/arch/x86/include/asm/hpet.h' is out of source tree. ignored.
...
Warning: '/home/darwi/linux/virt/lib/irqbypass.c' is out of source tree. ignored.
make[1]: Leaving directory '/home/darwi/build/'
and then generates an empty index:
$ du -hs ~/build/G*
16K /home/darwi/build/GPATH
16K /home/darwi/build/GRTAGS
16K /home/darwi/build/GTAGS
This series includes a proposed fix. After applying it:
$ make O=../build/ gtags
make[1]: Entering directory '/home/darwi/build'
GEN gtags
make[1]: Leaving directory '/home/darwi/build'
$ du -hs ~/build/G*
9.1M /home/darwi/build/GPATH
506M /home/darwi/build/GRTAGS
696M /home/darwi/build/GTAGS
The generated files can then be integrated with editors or IDEs as
usual.
=>
Ahmed S. Darwish (2):
scripts/tags.sh: Resolve gtags empty index generation
docs: Set minimal gtags / GNU GLOBAL version to 6.6.5
Documentation/process/changes.rst | 7 +++++++
scripts/tags.sh | 14 +++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
base-commit: ba0ad6ed89fd5dada3b7b65ef2b08e95d449d4ab
--
2.40.0
Hi,
v3-changelog
------------
Handle review remarks from Masahiro Yamada:
- Apply shellcheck on new "scripts/tags.sh" code.
- Shorten code through shell's "default value" parameter expansion.
NEW:
- Cc docs maintainer (Documentation/process/changes.rst change).
Thanks!
v2-changelog
------------
https://lkml.kernel.org/r/20230509012616.81579-1-darwi@linutronix.de
Handle review remarks from Masahiro Yamada:
- scripts/tags.sh: remove the O= language, and focus on the general
case of the build directory being different from the kernel source
tree, as specified in kernel Makefile L159.
- Fix failure when build directory is a subdirectory of the kernel
source tree.
NEW:
- Update Documentation/process/changes.rst with new gtags (GNU GLOBAL)
requirements.
Thanks!
Cover letter / v1
-----------------
https://lkml.kernel.org/r/20230504201833.202494-1-darwi@linutronix.de
make gtags for O= kernel builds is currently broken. For example, when doing:
make O=../build/ x86_64_defconfig
make O=../build/ gtags
gtags generates a warning for each kernel source file to be indexed:
make[1]: Entering directory '/home/darwi/build'
GEN gtags
Warning: '/home/darwi/linux/arch/x86/include/asm/qspinlock.h' is out of source tree. ignored.
Warning: '/home/darwi/linux/arch/x86/include/asm/hpet.h' is out of source tree. ignored.
...
Warning: '/home/darwi/linux/virt/lib/irqbypass.c' is out of source tree. ignored.
make[1]: Leaving directory '/home/darwi/build/'
and then generates an empty index:
$ du -hs ~/build/G*
16K /home/darwi/build/GPATH
16K /home/darwi/build/GRTAGS
16K /home/darwi/build/GTAGS
This series includes a proposed fix. After applying it:
$ make O=../build/ gtags
make[1]: Entering directory '/home/darwi/build'
GEN gtags
make[1]: Leaving directory '/home/darwi/build'
$ du -hs ~/build/G*
9.1M /home/darwi/build/GPATH
506M /home/darwi/build/GRTAGS
696M /home/darwi/build/GTAGS
The generated files can then be integrated with editors or IDEs as
usual.
=>
Ahmed S. Darwish (2):
scripts/tags.sh: Resolve gtags empty index generation
docs: Set minimal gtags / GNU GLOBAL version to 6.6.5
Documentation/process/changes.rst | 7 +++++++
scripts/tags.sh | 9 ++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
--
2.30.2
On Tue, May 16, 2023 at 2:33 AM Ahmed S. Darwish <darwi@linutronix.de> wrote: > > Hi, > > v3-changelog > ------------ > > Handle review remarks from Masahiro Yamada: > > - Apply shellcheck on new "scripts/tags.sh" code. > > - Shorten code through shell's "default value" parameter expansion. > > NEW: > > - Cc docs maintainer (Documentation/process/changes.rst change). > > Thanks! > > v2-changelog > ------------ > > https://lkml.kernel.org/r/20230509012616.81579-1-darwi@linutronix.de > > Handle review remarks from Masahiro Yamada: > > - scripts/tags.sh: remove the O= language, and focus on the general > case of the build directory being different from the kernel source > tree, as specified in kernel Makefile L159. > > - Fix failure when build directory is a subdirectory of the kernel > source tree. > > NEW: > > - Update Documentation/process/changes.rst with new gtags (GNU GLOBAL) > requirements. > > Thanks! > > Cover letter / v1 > ----------------- > > https://lkml.kernel.org/r/20230504201833.202494-1-darwi@linutronix.de > > make gtags for O= kernel builds is currently broken. For example, when doing: > > make O=../build/ x86_64_defconfig > make O=../build/ gtags > > gtags generates a warning for each kernel source file to be indexed: > > make[1]: Entering directory '/home/darwi/build' > GEN gtags > Warning: '/home/darwi/linux/arch/x86/include/asm/qspinlock.h' is out of source tree. ignored. > Warning: '/home/darwi/linux/arch/x86/include/asm/hpet.h' is out of source tree. ignored. > ... > Warning: '/home/darwi/linux/virt/lib/irqbypass.c' is out of source tree. ignored. > make[1]: Leaving directory '/home/darwi/build/' > > and then generates an empty index: > > $ du -hs ~/build/G* > 16K /home/darwi/build/GPATH > 16K /home/darwi/build/GRTAGS > 16K /home/darwi/build/GTAGS > > This series includes a proposed fix. After applying it: > > $ make O=../build/ gtags > make[1]: Entering directory '/home/darwi/build' > GEN gtags > make[1]: Leaving directory '/home/darwi/build' > > $ du -hs ~/build/G* > 9.1M /home/darwi/build/GPATH > 506M /home/darwi/build/GRTAGS > 696M /home/darwi/build/GTAGS > > The generated files can then be integrated with editors or IDEs as > usual. > > => > > Ahmed S. Darwish (2): > scripts/tags.sh: Resolve gtags empty index generation > docs: Set minimal gtags / GNU GLOBAL version to 6.6.5 Both applied. Thanks. > > Documentation/process/changes.rst | 7 +++++++ > scripts/tags.sh | 9 ++++++++- > 2 files changed, 15 insertions(+), 1 deletion(-) > > base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6 > -- > 2.30.2 -- Best Regards Masahiro Yamada
gtags considers any file outside of its current working directory
"outside the source tree" and refuses to index it. For O= kernel builds,
or when "make" is invoked from a directory other then the kernel source
tree, gtags ignores the entire kernel source and generates an empty
index.
Force-set gtags current working directory to the kernel source tree.
Due to commit 9da0763bdd82 ("kbuild: Use relative path when building in
a subdir of the source tree"), if the kernel build is done in a
sub-directory of the kernel source tree, the kernel Makefile will set
the kernel's $srctree to ".." for shorter compile-time and run-time
warnings. Consequently, the list of files to be indexed will be in the
"../*" form, rendering all such paths invalid once gtags switches to the
kernel source tree as its current working directory.
If gtags indexing is requested and the build directory is not the kernel
source tree, index all files in absolute-path form.
Note, indexing in absolute-path form will not affect the generated
index, as paths in gtags indices are always relative to the gtags "root
directory" anyway (as evidenced by "gtags --dump").
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Cc: <stable@vger.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..f6b3c7cd39c7 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -32,6 +32,13 @@ else
tree=${srctree}/
fi
+# gtags(1) refuses to index any file outside of its current working dir.
+# If gtags indexing is requested and the build output directory is not
+# the kernel source tree, index all files in absolute-path form.
+if [[ "$1" == "gtags" && -n "${tree}" ]]; then
+ tree=$(realpath "$tree")/
+fi
+
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
if [ "${ALLSOURCE_ARCHS}" = "" ]; then
ALLSOURCE_ARCHS=${SRCARCH}
@@ -131,7 +138,7 @@ docscope()
dogtags()
{
- all_target_sources | gtags -i -f -
+ all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD"
}
# Basic regular expressions with an optional /kind-spec/ for ctags and
--
2.30.2
Kernel build now uses the gtags "-C (--directory)" option, available
since GNU GLOBAL v6.6.5. Update the documentation accordingly.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Cc: <stable@vger.kernel.org>
Link: https://lists.gnu.org/archive/html/info-global/2020-09/msg00000.html
---
Documentation/process/changes.rst | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
index ef540865ad22..a9ef00509c9b 100644
--- a/Documentation/process/changes.rst
+++ b/Documentation/process/changes.rst
@@ -60,6 +60,7 @@ openssl & libcrypto 1.0.0 openssl version
bc 1.06.95 bc --version
Sphinx\ [#f1]_ 1.7 sphinx-build --version
cpio any cpio --version
+gtags (optional) 6.6.5 gtags --version
====================== =============== ========================================
.. [#f1] Sphinx is needed only to build the Kernel documentation
@@ -174,6 +175,12 @@ You will need openssl to build kernels 3.7 and higher if module signing is
enabled. You will also need openssl development packages to build kernels 4.3
and higher.
+gtags / GNU GLOBAL (optional)
+-----------------------------
+
+The kernel build requires GNU GLOBAL version 6.6.5 or later to generate
+tag files through ``make gtags``. This is due to its use of the gtags
+``-C (--directory)`` flag.
System utilities
****************
--
2.30.2
© 2016 - 2026 Red Hat, Inc.