kbuild: rust_is_available: fix version check when CC has multiple arguments
authorRussell Currey <ruscur@russell.cc>
Fri, 16 Jun 2023 00:16:22 +0000 (02:16 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 9 Aug 2023 17:33:31 +0000 (19:33 +0200)
rust_is_available.sh uses cc-version.sh to identify which C compiler is
in use, as scripts/Kconfig.include does.  cc-version.sh isn't designed to
be able to handle multiple arguments in one variable, i.e. "ccache clang".
Its invocation in rust_is_available.sh quotes "$CC", which makes
$1 == "ccache clang" instead of the intended $1 == ccache & $2 == clang.

cc-version.sh could also be changed to handle having "ccache clang" as one
argument, but it only has the one consumer upstream, making it simpler to
fix the caller here.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Fixes: 78521f3399ab ("scripts: add `rust_is_available.sh`")
Link: https://github.com/Rust-for-Linux/linux/pull/873
[ Reworded title prefix and reflow line to 75 columns. ]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20230616001631.463536-3-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
scripts/rust_is_available.sh

index f43a010eaf30505fc1f103490cff145c431d9ee3..0c9be438e4cd33656d4f13d7ce577a5f710e62af 100755 (executable)
@@ -113,10 +113,10 @@ fi
 #
 # In the future, we might be able to perform a full version check, see
 # https://github.com/rust-lang/rust-bindgen/issues/2138.
-cc_name=$($(dirname $0)/cc-version.sh "$CC" | cut -f1 -d' ')
+cc_name=$($(dirname $0)/cc-version.sh $CC | cut -f1 -d' ')
 if [ "$cc_name" = Clang ]; then
        clang_version=$( \
-               LC_ALL=C "$CC" --version 2>/dev/null \
+               LC_ALL=C $CC --version 2>/dev/null \
                        | sed -nE '1s:.*version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
        )
        if [ "$clang_version" != "$bindgen_libclang_version" ]; then