Jiri Slaby 557df3
From: Carlos Llamas <cmllamas@google.com>
Jiri Slaby 557df3
Date: Wed, 15 Feb 2023 18:38:50 +0000
Jiri Slaby 557df3
Subject: [PATCH] scripts/tags.sh: fix incompatibility with PCRE2
Jiri Slaby 557df3
References: bsc#1012628
Jiri Slaby 557df3
Patch-mainline: 6.2.2
Jiri Slaby 557df3
Git-commit: 6ec363fc6142226b9ab5a6528f65333d729d2b6b
Jiri Slaby 557df3
Jiri Slaby 557df3
commit 6ec363fc6142226b9ab5a6528f65333d729d2b6b upstream.
Jiri Slaby 557df3
Jiri Slaby 557df3
Starting with release 10.38 PCRE2 drops default support for using \K in
Jiri Slaby 557df3
lookaround patterns as described in [1]. Unfortunately, scripts/tags.sh
Jiri Slaby 557df3
relies on such functionality to collect all_compiled_soures() leading to
Jiri Slaby 557df3
the following error:
Jiri Slaby 557df3
Jiri Slaby 557df3
  $ make COMPILED_SOURCE=1 tags
Jiri Slaby 557df3
    GEN     tags
Jiri Slaby 557df3
  grep: \K is not allowed in lookarounds (but see PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK)
Jiri Slaby 557df3
Jiri Slaby 557df3
The usage of \K for this pattern was introduced in commit 4f491bb6ea2a
Jiri Slaby 557df3
("scripts/tags.sh: collect compiled source precisely") which speeds up
Jiri Slaby 557df3
the generation of tags significantly.
Jiri Slaby 557df3
Jiri Slaby 557df3
In order to fix this issue without compromising the performance we can
Jiri Slaby 557df3
switch over to an equivalent sed expression. The same matching pattern
Jiri Slaby 557df3
is preserved here except \K is replaced with a backreference \1.
Jiri Slaby 557df3
Jiri Slaby 557df3
[1] https://www.pcre.org/current/doc/html/pcre2syntax.html#SEC11
Jiri Slaby 557df3
Jiri Slaby 557df3
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jiri Slaby 557df3
Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Jiri Slaby 557df3
Cc: Masahiro Yamada <masahiroy@kernel.org>
Jiri Slaby 557df3
Cc: Jialu Xu <xujialu@vimux.org>
Jiri Slaby 557df3
Cc: Vipin Sharma <vipinsh@google.com>
Jiri Slaby 557df3
Cc: stable@vger.kernel.org
Jiri Slaby 557df3
Fixes: 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely")
Jiri Slaby 557df3
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Jiri Slaby 557df3
Link: https://lore.kernel.org/r/20230215183850.3353198-1-cmllamas@google.com
Jiri Slaby 557df3
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jiri Slaby 557df3
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Jiri Slaby 557df3
---
Jiri Slaby 557df3
 scripts/tags.sh | 2 +-
Jiri Slaby 557df3
 1 file changed, 1 insertion(+), 1 deletion(-)
Jiri Slaby 557df3
Jiri Slaby 557df3
diff --git a/scripts/tags.sh b/scripts/tags.sh
Jiri Slaby 557df3
index e137cf15..0d045182 100755
Jiri Slaby 557df3
--- a/scripts/tags.sh
Jiri Slaby 557df3
+++ b/scripts/tags.sh
Jiri Slaby 557df3
@@ -91,7 +91,7 @@ all_compiled_sources()
Jiri Slaby 557df3
 	{
Jiri Slaby 557df3
 		echo include/generated/autoconf.h
Jiri Slaby 557df3
 		find $ignore -name "*.cmd" -exec \
Jiri Slaby 557df3
-			grep -Poh '(?(?=^source_.* \K).*|(?=^  \K\S).*(?= \\))' {} \+ |
Jiri Slaby 557df3
+			sed -n -E 's/^source_.* (.*)/\1/p; s/^  (\S.*) \\/\1/p' {} \+ |
Jiri Slaby 557df3
 		awk '!a[$0]++'
Jiri Slaby 557df3
 	} | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) |
Jiri Slaby 557df3
 	sort -u
Jiri Slaby 557df3
-- 
Jiri Slaby 557df3
2.35.3
Jiri Slaby 557df3