kallsyms: Correctly sequence symbols when CONFIG_LTO_CLANG=y
[platform/kernel/linux-starfive.git] / scripts / tags.sh
index e137cf1..f23b9b7 100755 (executable)
@@ -25,6 +25,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}
@@ -91,7 +98,7 @@ all_compiled_sources()
        {
                echo include/generated/autoconf.h
                find $ignore -name "*.cmd" -exec \
-                       grep -Poh '(?(?=^source_.* \K).*|(?=^  \K\S).*(?= \\))' {} \+ |
+                       sed -n -E 's/^source_.* (.*)/\1/p; s/^  (\S.*) \\/\1/p' {} \+ |
                awk '!a[$0]++'
        } | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) |
        sort -u
@@ -124,7 +131,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