blob: b6d6f52c5cfaeefdbaef700218f09c6358d12bfa [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
4# Print ld.lld's version in a 5 or 6-digit form.
5
6set -e
7
8# Convert the version string x.y.z to a canonical 5 or 6-digit form.
9get_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
18orig_args="$@"
19
20# Get the first line of the --version output.
21IFS='
22'
23set -- $(LC_ALL=C "$@" --version)
24
25# Split the line on spaces.
26IFS=' '
27set -- $1
28
29while [ $# -gt 1 -a "$1" != "LLD" ]; do
30 shift
31done
32if [ "$1" = LLD ]; then
33 echo $(get_canonical_version ${2%-*})
34else
35 echo 0
36fi