1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # 3 # 4 # Print the linker name and its version in a 5 4 # Print the linker name and its version in a 5 or 6-digit form. 5 # Also, perform the minimum version check. 5 # Also, perform the minimum version check. 6 6 7 set -e 7 set -e 8 8 >> 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 >> 13 9 # Convert the version string x.y.z to a canoni 14 # Convert the version string x.y.z to a canonical 5 or 6-digit form. 10 get_canonical_version() 15 get_canonical_version() 11 { 16 { 12 IFS=. 17 IFS=. 13 set -- $1 18 set -- $1 14 19 15 # If the 2nd or 3rd field is missing, 20 # If the 2nd or 3rd field is missing, fill it with a zero. 16 # 21 # 17 # The 4th field, if present, is ignore 22 # The 4th field, if present, is ignored. 18 # This occurs in development snapshots 23 # This occurs in development snapshots as in 2.35.1.20201116 19 echo $((10000 * $1 + 100 * ${2:-0} + $ 24 echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) 20 } 25 } 21 26 22 orig_args="$@" 27 orig_args="$@" 23 28 24 # Get the first line of the --version output. 29 # Get the first line of the --version output. 25 IFS=' 30 IFS=' 26 ' 31 ' 27 set -- $(LC_ALL=C "$@" --version) 32 set -- $(LC_ALL=C "$@" --version) 28 33 29 # Split the line on spaces. 34 # Split the line on spaces. 30 IFS=' ' 35 IFS=' ' 31 set -- $1 36 set -- $1 32 37 33 min_tool_version=$(dirname $0)/min-tool-versio << 34 << 35 if [ "$1" = GNU -a "$2" = ld ]; then 38 if [ "$1" = GNU -a "$2" = ld ]; then 36 shift $(($# - 1)) 39 shift $(($# - 1)) 37 version=$1 40 version=$1 38 min_version=$($min_tool_version binuti !! 41 min_version=$bfd_min_version 39 name=BFD 42 name=BFD 40 disp_name="GNU ld" 43 disp_name="GNU ld" 41 elif [ "$1" = GNU -a "$2" = gold ]; then 44 elif [ "$1" = GNU -a "$2" = gold ]; then 42 echo "gold linker is not supported as 45 echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2 43 exit 1 46 exit 1 44 else 47 else 45 while [ $# -gt 1 -a "$1" != "LLD" ]; d 48 while [ $# -gt 1 -a "$1" != "LLD" ]; do 46 shift 49 shift 47 done 50 done 48 51 49 if [ "$1" = LLD ]; then 52 if [ "$1" = LLD ]; then 50 version=$2 53 version=$2 51 min_version=$($min_tool_versio !! 54 min_version=$lld_min_version 52 name=LLD 55 name=LLD 53 disp_name=LLD 56 disp_name=LLD 54 else 57 else 55 echo "$orig_args: unknown link 58 echo "$orig_args: unknown linker" >&2 56 exit 1 59 exit 1 57 fi 60 fi 58 fi 61 fi 59 62 60 # There may be something after the version, su !! 63 # Some distributions append a package release number, as in 2.34-4.fc32 61 # release number (like Fedora's "2.34-4.fc32") !! 64 # Trim the hyphen and any characters that follow. 62 # added before the "compatible with GNU linker !! 65 version=${version%-*} 63 # after just numbers and periods. << 64 version=${version%%[!0-9.]*} << 65 66 66 cversion=$(get_canonical_version $version) 67 cversion=$(get_canonical_version $version) 67 min_cversion=$(get_canonical_version $min_vers 68 min_cversion=$(get_canonical_version $min_version) 68 69 69 if [ "$cversion" -lt "$min_cversion" ]; then 70 if [ "$cversion" -lt "$min_cversion" ]; then 70 echo >&2 "***" 71 echo >&2 "***" 71 echo >&2 "*** Linker is too old." 72 echo >&2 "*** Linker is too old." 72 echo >&2 "*** Your $disp_name versio 73 echo >&2 "*** Your $disp_name version: $version" 73 echo >&2 "*** Minimum $disp_name ver 74 echo >&2 "*** Minimum $disp_name version: $min_version" 74 echo >&2 "***" 75 echo >&2 "***" 75 exit 1 76 exit 1 76 fi 77 fi 77 78 78 echo $name $cversion 79 echo $name $cversion
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.