Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
kbuild: rust_is_available: fix version check when CC has multiple arg…
Browse files Browse the repository at this point in the history
…uments

[ Upstream commit dee3a6b ]

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 <[email protected]>
Fixes: 78521f3 ("scripts: add `rust_is_available.sh`")
Link: Rust-for-Linux#873
[ Reworded title prefix and reflow line to 75 columns. ]
Reviewed-by: Martin Rodriguez Reboredo <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
ruscur authored and gregkh committed Sep 11, 2023
1 parent e227495 commit f4f8655
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/rust_is_available.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4f8655

Please sign in to comment.