From nobody Mon Jun 8 04:24:24 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C45D3E0C42 for ; Tue, 2 Jun 2026 12:15:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780402528; cv=none; b=KDmi1DceSs79RowGgonh74TM0jU/iSHwzb7BezwjvIc7H09Ke/ipbO6s/xJPismrluwV1EwXD7vy+vOjdYz4ZNBngneovkdi/tY44JR64RmE69ra5Dk0rtaxl/s6Ar+kpJdXO6XQeLeSKLPVp3Es7c15tWDMbE8SGXKkESR0PHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780402528; c=relaxed/simple; bh=8jFenrVpY6mPEQQtImkt6UJT4aM+INO9AtlA9KVwTDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LLCc5LLtzlPeB21X9NIJi0Ovo+rXTw4BeFJt81Y2zTnAN/IsepXFO3NRP+cW3+hP8vYfMbEWOoJKiWx6467eF8qDcFhH64LS4YB2dJdB/DNoZdIsn6OCs1zQxyUEoLW+538iTW9vK069fIg5BzXgbWGOvJkHckJ1Yb5CgbWVtLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ozv7PPwJ; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ozv7PPwJ" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-45e9f4a3510so6559930f8f.1 for ; Tue, 02 Jun 2026 05:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780402525; x=1781007325; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=39tomWq/D8VlQLXIgboVyRs7DGzptFPLmBA1BoR+QjQ=; b=Ozv7PPwJ9FYIacmMMOcbS84R4q9K8OnzDn9+g3QaNdDUdWjwLGXyChPwRIoUAES3Hy V5eIRwHMZnLPkSNB6hyYgMsgjlUZ+sT6toTN8dTMEnl6oNQS3oS8XBCN9vBUV7Z1Q5bT vSBTIVJ5434e+n8U/k9Kd6ETmGtDxhgvwdXdw1XtcqvNKjT7ibUioGzPQFwBG7JGjOXa rdmc99tY9eTaTFwUHB9CH5guXccEnoQA+5yE99wHMpNIvUeQ7Xyqvi7cDm0o9XoVjkEc VT7I1dR0mKXksROclQerxrH17iKlzw+nRWIGqQhFMNWNWQRnkVJnVs+5n9PfeX4Y04dy qFlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780402525; x=1781007325; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=39tomWq/D8VlQLXIgboVyRs7DGzptFPLmBA1BoR+QjQ=; b=jfETT3GycC09gq+QQb+eVuqpGdcx3BsfZqjG1Lwp3KUXOyhw8sA+XBban3Q3v1kP/p DXaPPZFoyghNlnSsXwmwZNL7hMbjmpER1PnCxJVhIf/i/D+Befx68S9T6wF4eeEb0Lq2 KWoJcFk+B/lTNmtPlrfxYlrKXB2d6RHu9ghaccpsjHu4k3E3YAb+Dlau/crh7R2yJDhm bP46+7CywSqcVdAPdreVmhZOKpV5CTJKOPa+31W7VE/dzJ2lJ0+TMR3BiDQ3q0To/5E1 A4zxUQyiJQW6yXArF+kV/bzaePgwfJ4Ylt0NxoAxB7wtZA8uohnsplrdxDl8H2AWBvYl y21g== X-Forwarded-Encrypted: i=1; AFNElJ9V1BEQzgKl4FcWUt5bjehGeCfwoyN1odILlbhInxDkZlgE7pL0W7FWxcYD3xEi2e5WwGGE1U+qpZCOZhg=@vger.kernel.org X-Gm-Message-State: AOJu0YwQS02/tqY3X0v4zsmyOidLyM1mPoMJ2vDFHaw5BO80HbyA7YAj zGvEEPOzWjRqjTwI5LG3/7h5tlv463NM7Vx9It/GH/nvukrobzLKDi6o X-Gm-Gg: Acq92OFzce1RUwHuHFZ/r7/oICkP9KsIlOt9qlEum4KlnMG+sWnbk7fgnPa6ve3YUB8 gOheAP3T7IbIjuekEm7O+E20gOE4U76X0ID1pn5ySB5WTPpqAejbN6TNyHBvxHJ5pnWCJ35GZfl G7bYsydn7VIIxClWI1ZUq5jr7TviMfmaJtbKuxuA7ZyL4zjqRsDkWMmETTyD/2PFqy0AbsVTFgD GsCQM25U+kUbfM3kPHFuMeRd4kX2fxJlJwbdSdxigzB+Ol+SAMdqlJMwCv3dzCTUEPtF3NvjsGL f1FIwZW+NPYuXgKB8TvCptCklX6rVOdFWK5x2iKNpvaUsUsYmNWAoZgNKMSkD2DKVZYcDvRzBzq jfgVdFIqHrWJQYavzcwp5N53OH5tWbKuEx/jB3FVpbGvqpBUO0xgOerg8K6ACwMvCtRIU8J1HlC hG7/H51jUbLQiYmRX42Dxk5ymJKrH+gax048ppBXKuHNR7XMT0RBDjPXs= X-Received: by 2002:adf:f902:0:b0:43f:dc54:9493 with SMTP id ffacd0b85a97d-45ef6b5b602mr21478259f8f.21.1780402524564; Tue, 02 Jun 2026 05:15:24 -0700 (PDT) Received: from localhost (a89-182-201-216.net-htp.de. [89.182.201.216]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-45ef354b5bdsm31879617f8f.21.2026.06.02.05.15.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jun 2026 05:15:24 -0700 (PDT) From: Sergei Litvin To: miguel.ojeda.sandonis@gmail.com, nathan@kernel.org, nsc@kernel.org Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, ojeda@kernel.org, Sergei Litvin Subject: [PATCH v4] scripts/tags.sh: fix "make COMPILED_SOURCE=1 cscope" command ends up with *.rlib, *.rmeta, *.so filenames in cscope.files Date: Tue, 2 Jun 2026 14:15:21 +0200 Message-ID: <20260602121521.11650-1-litvindev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601211850.3378-1-litvindev@gmail.com> References: <20260601211850.3378-1-litvindev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable PROBLEM (1) When executing the command `make COMPILED_SOURCE=3D1 cscope`, the `cscope.files` file generated by it includes filenames with the extensions *.rlib, *.rmeta, and *.so (taken from *.cmd files, which, in tur= n, are generated from *.d dependency files by the `fixdep` utility). (2) When executing the command `make cscope`, the `cscope.files` file gener= ated by it includes only filenames with the extensions *.h, *.c, *.S and not inc= ludes filenames with *.rs extensions. SOLUTION (1) Modify the regular expression in the `all_compiled_sources()` function = so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted. This causes `make COMPILED_SOURCE=3D1 cscope` command to generate the `cscope.files` file that contains only files with the extensions *.h, *.c, = *.S, and *.rs. (2) Modify the functions `find_arch_sources()`, `find_arch_include_sources(= )`, `find_include_sources()`, and `find_other_sources()` so that they can accep= t an unlimited number of filename patterns as parameters for the search. Add the `setup_name_pattern()` function to convert these filename pattern parameters into a list of parameters that can be passed to the `find` utility via the = new `pattern` variable. This causes `make cscope` command to generate a `cscope.files` file that contains *.rs files along with *.h, *.c, *.S Signed-off-by: Sergei Litvin --- Changes since V3: https://lore.kernel.org/lkml/20260601211850.3378-1-litvindev@gmail.com/ In V3, the functions `find_arch_sources()`, `find_arch_include_sources()`, `find_include_sources()`, and `find_other_sources()` were modified so that = they no longer accept the filename pattern as the last argument, but instead ret= rieve it from the new variable `pattern`. However, at the time, I had overlooked = the case where the `find_other_sources` function was called with the `Kconfig*` parameter. And after Sashiko pointed this out to me, I decided to rewrite i= t in the current version. Changes since V2: https://lore.kernel.org/lkml/20260530085821.19689-1-litvindev@gmail.com/ - The functions find_arch_sources()`, `find_arch_include_sources()`, `find_include_sources()`, and `find_other_sources()` have been modified rat= her than having their calls duplicated to avoid redundant directory traversals (suggested by Sashiko). =E2=80=93 The regular expression in the `all_compiled_sources()` function w= as improved by adding a lookahead anchor (?=3D\s) to the first branch (also suggested b= y Sashiko). Changes between the V1 and V2: https://lore.kernel.org/lkml/20260530085821.19689-1-litvindev@gmail.com/ https://lore.kernel.org/lkml/20260530070631.14955-1-litvindev@gmail.com/ - In Version V1, the `-name` parameters to the `find` calls in the functions `find_arch_sources()`, `find_arch_include_sources()`, `find_include_sources= ()`, and `find_other_sources()` were replaced by `-regextype posix-extended -regex`. However, as noted by Sashiko, the `-regextype` option is a GNU-spe= cific extension; therefore, in V2, duplicate function calls were introduced inste= ad. Signed-off-by: Sergei Litvin --- scripts/tags.sh | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 243373683f98..41e38df96984 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -46,13 +46,31 @@ elif [ "${ALLSOURCE_ARCHS}" =3D "all" ]; then ALLSOURCE_ARCHS=3D$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -pr= intf '%f ') fi =20 +setup_name_pattern() +{ + pattern=3D() + for ext; do + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=3D("-o" "-name" "$ext") + else + pattern+=3D("(" "-name" "$ext") + fi + done + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=3D(")") + fi +} + # find sources in arch/$1 find_arch_sources() { for i in $archincludedir; do local prune=3D"$prune ( -path $i ) -prune -o" done - find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print; + local src=3D${tree}arch/$1 + shift + setup_name_pattern "$@" + find $src $ignore $prune "${pattern[@]}" -not -type l -print; } =20 # find sources in arch/$1/include @@ -61,14 +79,17 @@ find_arch_include_sources() local include=3D$(find ${tree}arch/$1/ -name include -type d -print); if [ -n "$include" ]; then archincludedir=3D"$archincludedir $include" - find $include $ignore -name "$2" -not -type l -print; + shift + setup_name_pattern "$@" + find $include $ignore "${pattern[@]}" -not -type l -print; fi } =20 # find sources in include/ find_include_sources() { - find ${tree}include $ignore -name config -prune -o -name "$1" \ + setup_name_pattern "$@" + find ${tree}include $ignore -name config -prune -o "${pattern[@]}" \ -not -type l -print; } =20 @@ -76,23 +97,24 @@ find_include_sources() # we could benefit from a list of dirs to search in here find_other_sources() { + setup_name_pattern "$@" find ${tree}* $ignore \ \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -p= rune -o \ - -name "$1" -not -type l -print; + "${pattern[@]}" -not -type l -print; } =20 all_sources() { - find_arch_include_sources ${SRCARCH} '*.[chS]' + find_arch_include_sources ${SRCARCH} '*.[chS]' '*.rs' if [ -n "$archinclude" ]; then - find_arch_include_sources $archinclude '*.[chS]' + find_arch_include_sources $archinclude '*.[chS]' '*.rs' fi - find_include_sources '*.[chS]' + find_include_sources '*.[chS]' '*.rs' for arch in $ALLSOURCE_ARCHS do - find_arch_sources $arch '*.[chS]' + find_arch_sources $arch '*.[chS]' '*.rs' done - find_other_sources '*.[chS]' + find_other_sources '*.[chS]' '*.rs' } =20 all_compiled_sources() @@ -100,7 +122,7 @@ all_compiled_sources() { echo include/generated/autoconf.h find $ignore -name "*.cmd" -exec \ - grep -Poh '(?<=3D^ )\S+|(?<=3D=3D )\S+[^\\](?=3D$)' {} \+ | + grep -Poh '(?<=3D^ )\S+\.([chS]|rs)(?=3D\s)|(?<=3D=3D )\S+\.(?1)(?=3D$= )' {} \+ | awk '!a[$0]++' } | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative= -to=3D.) | sort -u --=20 2.54.0