]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - scripts/cc-version.sh
2 # SPDX-License-Identifier: GPL-2.0
4 # Print the compiler name and its version in a 5 or 6-digit form.
5 # Also, perform the minimum version check.
9 # When you raise the minimum compiler version, please update
10 # Documentation/process/changes.rst as well.
12 clang_min_version
=10.0.1
13 icc_min_version
=16.0.3 # temporary
15 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
16 # https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
17 if [ "$SRCARCH" = arm64
]; then
21 # Print the compiler name and some version components.
24 cat <<- EOF | "$@" -E -P -x c - 2>/dev/null
25 #if defined(__clang__)
26 Clang __clang_major__ __clang_minor__ __clang_patchlevel__
27 #elif defined(__INTEL_COMPILER)
28 ICC __INTEL_COMPILER __INTEL_COMPILER_UPDATE
29 #elif defined(__GNUC__)
30 GCC __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__
37 # Convert the version string x.y.z to a canonical 5 or 6-digit form.
38 get_canonical_version
()
42 echo $
((10000 * $1 + 100 * $2 + $3))
45 # $@ instead of $1 because multiple words might be given, e.g. CC="ccache gcc".
47 set -- $
(get_compiler_info
"$@")
54 min_version
=$gcc_min_version
58 min_version
=$clang_min_version
61 version
=$
(($2 / 100)).$
(($2 % 100)).
$3
62 min_version
=$icc_min_version
65 echo "$orig_args: unknown compiler" >&2
70 cversion
=$
(get_canonical_version
$version)
71 min_cversion
=$
(get_canonical_version
$min_version)
73 if [ "$cversion" -lt "$min_cversion" ]; then
75 echo >&2 "*** Compiler is too old."
76 echo >&2 "*** Your $name version: $version"
77 echo >&2 "*** Minimum $name version: $min_version"