b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # |
| 4 | # Print ld.lld's version in a 5 or 6-digit form. |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | # Convert the version string x.y.z to a canonical 5 or 6-digit form. |
| 9 | get_canonical_version() |
| 10 | { |
| 11 | IFS=. |
| 12 | set -- $1 |
| 13 | |
| 14 | # If the 2nd or 3rd field is missing, fill it with a zero. |
| 15 | echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) |
| 16 | } |
| 17 | |
| 18 | orig_args="$@" |
| 19 | |
| 20 | # Get the first line of the --version output. |
| 21 | IFS=' |
| 22 | ' |
| 23 | set -- $(LC_ALL=C "$@" --version) |
| 24 | |
| 25 | # Split the line on spaces. |
| 26 | IFS=' ' |
| 27 | set -- $1 |
| 28 | |
| 29 | while [ $# -gt 1 -a "$1" != "LLD" ]; do |
| 30 | shift |
| 31 | done |
| 32 | if [ "$1" = LLD ]; then |
| 33 | echo $(get_canonical_version ${2%-*}) |
| 34 | else |
| 35 | echo 0 |
| 36 | fi |