From 4fdd3b6794bee53a3a629615b801f8ee939fe533 Mon Sep 17 00:00:00 2001 From: Srinath Vadlamani Date: Tue, 8 Jan 2019 17:31:25 -0700 Subject: Armcompiler (#9840) * Initial compiler support * added arm.py * Changed licence to Arm suggested header * Changed licence to the same as clang.py Main author of file is Nick Forrington Minor changes by Srinath Vadlamani * compilers: add arm compiler detection to Spack - added arm.py with support for detecting `armclang` and `armflang` Co-authored-by: Srinath Vadlamani * Changed to using get get_compiler_version * linking to general cc for arm compiler * For arm compiler add CFLAGS to use compiler-rt rtlib. * Escape for special characters in rexep * Cleaned up for Flake8 to pass. * libcompiler-rt should be part of the LDFLAGS not CFLAGS * fixed m4 when using clang to used LDFLAGS. Fixed comments for arm.py to display compiler --version output with # NOAQ for flakes pass. * added arm compilers * proper linked names --- lib/spack/env/arm/armclang | 1 + lib/spack/env/arm/armclang++ | 1 + lib/spack/env/arm/armflang | 1 + lib/spack/env/cc | 6 +++--- lib/spack/spack/compilers/arm.py | 39 ++++++++++++++++++--------------------- 5 files changed, 24 insertions(+), 24 deletions(-) create mode 120000 lib/spack/env/arm/armclang create mode 120000 lib/spack/env/arm/armclang++ create mode 120000 lib/spack/env/arm/armflang (limited to 'lib') diff --git a/lib/spack/env/arm/armclang b/lib/spack/env/arm/armclang new file mode 120000 index 0000000000..82c2b8e90a --- /dev/null +++ b/lib/spack/env/arm/armclang @@ -0,0 +1 @@ +../cc \ No newline at end of file diff --git a/lib/spack/env/arm/armclang++ b/lib/spack/env/arm/armclang++ new file mode 120000 index 0000000000..82c2b8e90a --- /dev/null +++ b/lib/spack/env/arm/armclang++ @@ -0,0 +1 @@ +../cc \ No newline at end of file diff --git a/lib/spack/env/arm/armflang b/lib/spack/env/arm/armflang new file mode 120000 index 0000000000..82c2b8e90a --- /dev/null +++ b/lib/spack/env/arm/armflang @@ -0,0 +1 @@ +../cc \ No newline at end of file diff --git a/lib/spack/env/cc b/lib/spack/env/cc index 5e68702c5f..70f429055d 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -106,19 +106,19 @@ case "$command" in cpp) mode=cpp ;; - cc|c89|c99|gcc|clang|icc|pgcc|xlc|xlc_r) + cc|c89|c99|gcc|clang|armclang|icc|pgcc|xlc|xlc_r) command="$SPACK_CC" language="C" comp="CC" lang_flags=C ;; - c++|CC|g++|clang++|icpc|pgc++|xlc++|xlc++_r) + c++|CC|g++|clang++|armclang++|icpc|pgc++|xlc++|xlc++_r) command="$SPACK_CXX" language="C++" comp="CXX" lang_flags=CXX ;; - ftn|f90|fc|f95|gfortran|flang|ifort|pgfortran|xlf90|xlf90_r|nagfor) + ftn|f90|fc|f95|gfortran|flang|armflang|ifort|pgfortran|xlf90|xlf90_r|nagfor) command="$SPACK_FC" language="Fortran 90" comp="FC" diff --git a/lib/spack/spack/compilers/arm.py b/lib/spack/spack/compilers/arm.py index 33801a1ccc..b2c4871236 100644 --- a/lib/spack/spack/compilers/arm.py +++ b/lib/spack/spack/compilers/arm.py @@ -3,10 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import re - -from spack.compiler import Compiler, _version_cache -from spack.util.executable import Executable +from spack.compiler import Compiler, get_compiler_version class Arm(Compiler): @@ -23,10 +20,10 @@ class Arm(Compiler): fc_names = ['armflang'] # Named wrapper links within lib/spack/env - link_paths = {'cc': 'clang/clang', - 'cxx': 'clang/clang++', - 'f77': 'clang/flang', - 'fc': 'clang/flang'} + link_paths = {'cc': 'arm/armclang', + 'cxx': 'arm/armclang++', + 'f77': 'arm/armflang', + 'fc': 'arm/armflang'} @property def openmp_flag(self): @@ -50,19 +47,19 @@ class Arm(Compiler): @classmethod def default_version(cls, comp): - if comp not in _version_cache: - compiler = Executable(comp) - output = compiler('--version', output=str, error=str) - - ver = 'unknown' - match = re.search(r'Arm C/C++/Fortran Compiler version ([^ )]+)', - output) - if match: - ver = match.group(1) - - _version_cache[comp] = ver - - return _version_cache[comp] + """The ``--version`` option seems to be the most consistent one + for arm compilers. Output looks like this:: + + $ armlang --version + Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2) # NOQA + Target: aarch64--linux-gnu + Thread model: posix + InstalledDir: + /opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin # NOQA + """ + return get_compiler_version( + comp, '--version', + r'Arm C\/C\+\+\/Fortran Compiler version ([^ )]+)') @classmethod def fc_version(cls, fc): -- cgit v1.2.3-60-g2f50