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 # When you raise the minimum linker version, please update
10 # Documentation/process/changes.rst as well.
11 bfd_min_version=2.23.0
12 lld_min_version=10.0.1
14 # Convert the version string x.y.z to a canonical 5 or 6-digit form.
15 get_canonical_version()
20 # If the 2nd or 3rd field is missing, fill it with a zero.
22 # The 4th field, if present, is ignored.
23 # This occurs in development snapshots as in 2.35.1.20201116
24 echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0}))
29 # Get the first line of the --version output.
32 set -- $("$@" --version)
34 # Split the line on spaces.
38 if [ "$1" = GNU -a "$2" = ld ]; then
41 min_version=$bfd_min_version
44 elif [ "$1" = GNU -a "$2" = gold ]; then
45 echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2
47 elif [ "$1" = LLD ]; then
49 min_version=$lld_min_version
53 echo "$orig_args: unknown linker" >&2
57 # Some distributions append a package release number, as in 2.34-4.fc32
58 # Trim the hyphen and any characters that follow.
61 cversion=$(get_canonical_version $version)
62 min_cversion=$(get_canonical_version $min_version)
64 if [ "$cversion" -lt "$min_cversion" ]; then
66 echo >&2 "*** Linker is too old."
67 echo >&2 "*** Your $disp_name version: $version"
68 echo >&2 "*** Minimum $disp_name version: $min_version"