1af0121c2SGary Guo#!/bin/sh 2af0121c2SGary Guo# SPDX-License-Identifier: GPL-2.0 3af0121c2SGary Guo# 4af0121c2SGary Guo# Usage: $ ./rustc-llvm-version.sh rustc 5af0121c2SGary Guo# 6af0121c2SGary Guo# Print the LLVM version that the Rust compiler uses in a 6 digit form. 7af0121c2SGary Guo 8af0121c2SGary Guo# Convert the version string x.y.z to a canonical up-to-6-digits form. 9af0121c2SGary Guoget_canonical_version() 10af0121c2SGary Guo{ 11af0121c2SGary Guo IFS=. 12af0121c2SGary Guo set -- $1 13af0121c2SGary Guo echo $((10000 * $1 + 100 * $2 + $3)) 14af0121c2SGary Guo} 15af0121c2SGary Guo 16*c38a04ecSMiguel Ojedaif output=$("$@" --version --verbose 2>/dev/null | grep -E 'LLVM.*[0-9]+\.[0-9]+\.[0-9]+'); then 17af0121c2SGary Guo set -- $output 18af0121c2SGary Guo get_canonical_version $3 19af0121c2SGary Guoelse 20af0121c2SGary Guo echo 0 21af0121c2SGary Guo exit 1 22af0121c2SGary Guofi 23