[PATCH v2] scripts/tags.sh: Prevent binary files appearing in cscope.files

Sergei Litvin posted 1 patch 1 week, 4 days ago
scripts/tags.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] scripts/tags.sh: Prevent binary files appearing in cscope.files
Posted by Sergei Litvin 1 week, 4 days ago
When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting
`cscope.files` file contains filenames with the extensions *.rlib, *.rmeta,
and *.so.

To fix this, modify the regular expression in the `all_compiled_sources()`
function so that only files with the extensions *.h, *.c, *.S, and *.rs are
accepted.

The issue has been introduced by commit 4f491bb6ea2a ("scripts/tags.sh: collect
compiled source precisely") which implemented the parsing of compiled sources
from *.cmd files instead of using the "find" command.

Cc: ojeda@kernel.org
Cc: nsc@kernel.org
Cc: nathan@kernel.org
Cc: stable@vger.kernel.org
Fixes: 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely")
Signed-off-by: Sergei Litvin <litvindev@gmail.com>

---

This is the first part of this patch:
https://lore.kernel.org/lkml/20260602121521.11650-1-litvindev@gmail.com/

which I have split into two parts, as suggested by Nicolas Schier here:
https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/

Changes since V1:
https://lore.kernel.org/lkml/20260705175936.4653-1-litvindev@gmail.com/

as suggested by Miguel Ojeda here:
https://lore.kernel.org/lkml/CANiq72kHbVQfNrum5D2a5sCd3mFQHNtigrQxP1WW=YcggxA=WQ@mail.gmail.com/

- Add "Cc: stable@vger.kernel.org" tag
- Add "Fixes:" tag
- Add missed "Signed-off-by:" tag
---
 scripts/tags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index 243373683f98..c9dc2763a505 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -100,7 +100,7 @@ all_compiled_sources()
 	{
 		echo include/generated/autoconf.h
 		find $ignore -name "*.cmd" -exec \
-			grep -Poh '(?<=^  )\S+|(?<== )\S+[^\\](?=$)' {} \+ |
+			grep -Poh '(?<=^  )\S+\.([chS]|rs)(?=\s)|(?<== )\S+\.(?1)(?=$)' {} \+ |
 		awk '!a[$0]++'
 	} | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) |
 	sort -u
-- 
2.55.0
Re: [PATCH v2] scripts/tags.sh: Prevent binary files appearing in cscope.files
Posted by Nicolas Schier 1 week, 3 days ago
On Tue, Jul 14, 2026 at 10:33:31AM +0200, Sergei Litvin wrote:
> When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting
> `cscope.files` file contains filenames with the extensions *.rlib, *.rmeta,
> and *.so.
> 

With removed Cc trailers and adjusted line break in the commit message, applied
to kbuild/linux.git (kbuild-next-unstable), thanks!

[1/1] scripts/tags.sh: Prevent binary files appearing in cscope.files
      https://git.kernel.org/kbuild/c/1e5ebc3f

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers). Patches applied to the
kbuild-next-unstable branch are accepted pending wider testing in
linux-next and any post-commit review; they will generally be moved
to the kbuild-next branch in about a week if no issues are found.

Best regards,
-- 
Nicolas
Re: [PATCH v2] scripts/tags.sh: Prevent binary files appearing in cscope.files
Posted by Nicolas Schier 1 week, 4 days ago
On Tue, Jul 14, 2026 at 10:33:31AM +0200, Sergei Litvin wrote:
> When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting
> `cscope.files` file contains filenames with the extensions *.rlib, *.rmeta,
> and *.so.
> 
> To fix this, modify the regular expression in the `all_compiled_sources()`
> function so that only files with the extensions *.h, *.c, *.S, and *.rs are
> accepted.
> 
> The issue has been introduced by commit 4f491bb6ea2a ("scripts/tags.sh: collect
> compiled source precisely") which implemented the parsing of compiled sources
> from *.cmd files instead of using the "find" command.
> 
> Cc: ojeda@kernel.org
> Cc: nsc@kernel.org
> Cc: nathan@kernel.org
> Cc: stable@vger.kernel.org
> Fixes: 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely")
> Signed-off-by: Sergei Litvin <litvindev@gmail.com>
> 
> ---

Thanks, looks good to me.  W/o this patch 'make COMPILED_SOURCE=1
cscope' is actually not usable on my system, as soon as some rust libs
are in my build tree, so thanks for fixing!

Tested-by: Nicolas Schier <n.schier@fritz.com>
Reviewed-by: Nicolas Schier <n.schier@fritz.com>


As this is a not really a build relevant bug, I think this should go via
some -next rather than a -fixes tree [1].

Miguel, are you with with it if I take this patch as well as the second
one [2] via kbuild-next?

(I tend to remove the Cc trailers from this patch here, as they are
incomplete.)

Kind regards,
Nicolas



[1]: https://lore.kernel.org/r/CAHk-=wjt1NiKOdyAMz_DT7NmZ++SizPOhRSi492ukdTnpDzHQw@mail.gmail.com/
[2]: [PATCH v4] scripts/tags.sh: Add support for rust source files
     https://lore.kernel.org/linux-kbuild/20260714125259.78824-1-litvindev@gmail.com/T/#u
Re: [PATCH v2] scripts/tags.sh: Prevent binary files appearing in cscope.files
Posted by Miguel Ojeda 1 week, 4 days ago
On Tue, Jul 14, 2026 at 4:00 PM Nicolas Schier <nsc@kernel.org> wrote:
>
> Miguel, are you with with it if I take this patch as well as the second
> one [2] via kbuild-next?

Yes, of course, thanks!

Acked-by: Miguel Ojeda <ojeda@kernel.org>

(If the `cscope` target is actually broken in some cases, then I think
it would still be fine in -fixes; but since nobody complained so far,
I guess it is not that urgent anyway...).

Cheers,
Miguel