Add build number to Arm compiler version identification (#15809)
* Add capability for detecting build number for Arm compilers * Fixing fleck8 errors and updating test_arm_version_detection function for more detailed Arm compielr version detection * Ran flake8 locally and corrected errors * Altering Arm compielr version check to remove else clause and be more consistent with other compielr version checks. Added test case so both the 'if' and 'else' conditionals of the Arm compiler version check have a test case Co-authored-by: EC2 Default User <ec2-user@ip-172-31-7-135.us-east-2.compute.internal>
This commit is contained in:
parent
f83d46bb79
commit
da9ba2b254
2 changed files with 22 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
import spack.compiler
|
import spack.compiler
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Arm(spack.compiler.Compiler):
|
class Arm(spack.compiler.Compiler):
|
||||||
|
@ -35,7 +36,20 @@ class Arm(spack.compiler.Compiler):
|
||||||
# InstalledDir:
|
# InstalledDir:
|
||||||
# /opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin
|
# /opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin
|
||||||
version_argument = '--version'
|
version_argument = '--version'
|
||||||
version_regex = r'Arm C\/C\+\+\/Fortran Compiler version ([^ )]+)'
|
version_regex = r'Arm C\/C\+\+\/Fortran Compiler version ([\d\.]+) '\
|
||||||
|
r'\(build number (\d+)\) '
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def extract_version_from_output(cls, output):
|
||||||
|
"""Extracts the version from compiler's output."""
|
||||||
|
match = re.search(cls.version_regex, output)
|
||||||
|
temp = 'unknown'
|
||||||
|
if match:
|
||||||
|
if match.group(1).count('.') == 1:
|
||||||
|
temp = match.group(1) + ".0." + match.group(2)
|
||||||
|
else:
|
||||||
|
temp = match.group(1) + "." + match.group(2)
|
||||||
|
return temp
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def verbose_flag(cls):
|
def verbose_flag(cls):
|
||||||
|
|
|
@ -369,7 +369,13 @@ def test_clang_version_detection(version_str, expected_version):
|
||||||
'Thread model: posix\n'
|
'Thread model: posix\n'
|
||||||
'InstalledDir:\n'
|
'InstalledDir:\n'
|
||||||
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA
|
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA
|
||||||
'19.0')
|
'19.0.0.73'),
|
||||||
|
('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA
|
||||||
|
'Target: aarch64--linux-gnu\n'
|
||||||
|
'Thread model: posix\n'
|
||||||
|
'InstalledDir:\n'
|
||||||
|
'/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA
|
||||||
|
'19.3.1.75')
|
||||||
])
|
])
|
||||||
def test_arm_version_detection(version_str, expected_version):
|
def test_arm_version_detection(version_str, expected_version):
|
||||||
version = spack.compilers.arm.Arm.extract_version_from_output(version_str)
|
version = spack.compilers.arm.Arm.extract_version_from_output(version_str)
|
||||||
|
|
Loading…
Reference in a new issue