blob: d70edb4d8a4f2d865e3f4498fa31c5b12e6aafe2 [file] [log] [blame]
Nathan Chancellord5750cd2020-11-19 13:46:58 -07001#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
4# Usage: $ ./scripts/lld-version.sh ld.lld
5#
6# Print the linker version of `ld.lld' in a 5 or 6-digit form
7# such as `100001' for ld.lld 10.0.1 etc.
8
9linker_string="$($* --version)"
10
11if ! ( echo $linker_string | grep -q LLD ); then
12 echo 0
13 exit 1
14fi
15
16VERSION=$(echo $linker_string | cut -d ' ' -f 2)
17MAJOR=$(echo $VERSION | cut -d . -f 1)
18MINOR=$(echo $VERSION | cut -d . -f 2)
19PATCHLEVEL=$(echo $VERSION | cut -d . -f 3)
20printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL