1
linux/scripts/rustc-llvm-version.sh
Gary Guo af0121c2d3 kbuild: rust: add CONFIG_RUSTC_LLVM_VERSION
Each version of Rust supports a range of LLVM versions. There are cases where
we want to gate a config on the LLVM version instead of the Rust version.
Normalized cfi integer tags are one example [1].

The invocation of rustc-version is being moved from init/Kconfig to
scripts/Kconfig.include for consistency with cc-version.

Link: https://lore.kernel.org/all/20240925-cfi-norm-kasan-fix-v1-1-0328985cdf33@google.com/ [1]
Signed-off-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20241011114040.3900487-1-gary@garyguo.net
[ Added missing `-llvm` to the Usage documentation. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-10-13 22:22:28 +02:00

23 lines
453 B
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Usage: $ ./rustc-llvm-version.sh rustc
#
# Print the LLVM version that the Rust compiler uses in a 6 digit form.
# Convert the version string x.y.z to a canonical up-to-6-digits form.
get_canonical_version()
{
IFS=.
set -- $1
echo $((10000 * $1 + 100 * $2 + $3))
}
if output=$("$@" --version --verbose 2>/dev/null | grep LLVM); then
set -- $output
get_canonical_version $3
else
echo 0
exit 1
fi