2 # SPDX-License-Identifier: GPL-2.0
4 # Print the linker name and its version in a 5 or 6-digit form.
5 # Also, perform the minimum version check.
9 # Convert the version string x.y.z to a canonical 5 or 6-digit form.
10 get_canonical_version
()
15 # If the 2nd or 3rd field is missing, fill it with a zero.
17 # The 4th field, if present, is ignored.
18 # This occurs in development snapshots as in 2.35.1.20201116
19 echo $
((10000 * $1 + 100 * ${2:-0} + ${3:-0}))
24 # Get the first line of the --version output.
27 set -- $
(LC_ALL
=C
"$@" --version)
29 # Split the line on spaces.
33 min_tool_version
=$
(dirname $0)/min-tool-version.sh
35 if [ "$1" = GNU
-a "$2" = ld
]; then
38 min_version
=$
($min_tool_version binutils
)
41 elif [ "$1" = GNU
-a "$2" = gold
]; then
42 echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2
45 while [ $# -gt 1 -a "$1" != "LLD" ]; do
49 if [ "$1" = LLD
]; then
51 min_version
=$
($min_tool_version llvm
)
55 echo "$orig_args: unknown linker" >&2
60 # There may be something after the version, such as a distribution's package
61 # release number (like Fedora's "2.34-4.fc32") or punctuation (like LLD briefly
62 # added before the "compatible with GNU linkers" string), so remove everything
63 # after just numbers and periods.
64 version
=${version%%[!0-9.]*}
66 cversion
=$
(get_canonical_version
$version)
67 min_cversion
=$
(get_canonical_version
$min_version)
69 if [ "$cversion" -lt "$min_cversion" ]; then
71 echo >&2 "*** Linker is too old."
72 echo >&2 "*** Your $disp_name version: $version"
73 echo >&2 "*** Minimum $disp_name version: $min_version"