rustc-llvm-version.sh 482 B

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