2 # SPDX-License-Identifier: GPL-2.0-only
4 # Print the assembler name and its version in a 5 or 6-digit form.
5 # Also, perform the minimum version check.
6 # (If it is the integrated assembler, return 0 as the version, and
7 # skip the version check.)
11 # Convert the version string x.y.z to a canonical 5 or 6-digit form.
12 get_canonical_version()
17 # If the 2nd or 3rd field is missing, fill it with a zero.
19 # The 4th field, if present, is ignored.
20 # This occurs in development snapshots as in 2.35.1.20201116
21 echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0}))
24 # Clang fails to handle -Wa,--version unless -fno-integrated-as is given.
25 # We check -fintegrated-as, expecting it is explicitly passed in for the
26 # integrated assembler case.
29 while [ $# -gt 0 ]; do
30 if [ "$1" = -fintegrated-as ]; then
31 # For the integrated assembler, we do not check the
32 # version here. It is the same as the clang version, and
33 # it has been already checked by scripts/cc-version.sh.
41 check_integrated_as "$@"
45 # Get the first line of the --version output.
48 set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler-with-cpp /dev/null -o /dev/null 2>/dev/null)
50 # Split the line on spaces.
54 min_tool_version=$(dirname $0)/min-tool-version.sh
56 if [ "$1" = GNU -a "$2" = assembler ]; then
59 min_version=$($min_tool_version binutils)
62 echo "$orig_args: unknown assembler invoked" >&2
66 # Some distributions append a package release number, as in 2.34-4.fc32
67 # Trim the hyphen and any characters that follow.
70 cversion=$(get_canonical_version $version)
71 min_cversion=$(get_canonical_version $min_version)
73 if [ "$cversion" -lt "$min_cversion" ]; then
75 echo >&2 "*** Assembler is too old."
76 echo >&2 "*** Your $name assembler version: $version"
77 echo >&2 "*** Minimum $name assembler version: $min_version"