Allow detection for "-classic" version of CCE (#17256)

* cce: detect modules based on the classic backend

* cce: tweaked version checks for clang based options

* Added unit test for cce flags
This commit is contained in:
Massimiliano Culpo 2020-06-26 04:20:09 +02:00 committed by GitHub
parent cecd300693
commit c401c63156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -32,9 +32,14 @@ class Cce(Compiler):
'f77': 'cce/ftn', 'f77': 'cce/ftn',
'fc': 'cce/ftn'} 'fc': 'cce/ftn'}
@property
def is_clang_based(self):
version = self.version
return version >= ver('9.0') and 'classic' not in str(version)
@property @property
def version_argument(self): def version_argument(self):
if self.version >= ver('9.0'): if self.is_clang_based:
return '--version' return '--version'
return '-V' return '-V'
@ -50,19 +55,19 @@ def debug_flags(self):
@property @property
def openmp_flag(self): def openmp_flag(self):
if self.version >= ver('9.0'): if self.is_clang_based:
return '-fopenmp' return '-fopenmp'
return "-h omp" return "-h omp"
@property @property
def cxx11_flag(self): def cxx11_flag(self):
if self.version >= ver('9.0'): if self.is_clang_based:
return '-std=c++11' return '-std=c++11'
return "-h std=c++11" return "-h std=c++11"
@property @property
def c99_flag(self): def c99_flag(self):
if self.version >= ver('9.0'): if self.is_clang_based:
return '-std=c99' return '-std=c99'
elif self.version >= ver('8.4'): elif self.version >= ver('8.4'):
return '-h std=c99,noconform,gnu' return '-h std=c99,noconform,gnu'
@ -75,7 +80,7 @@ def c99_flag(self):
@property @property
def c11_flag(self): def c11_flag(self):
if self.version >= ver('9.0'): if self.is_clang_based:
return '-std=c11' return '-std=c11'
elif self.version >= ver('8.5'): elif self.version >= ver('8.5'):
return '-h std=c11,noconform,gnu' return '-h std=c11,noconform,gnu'

View File

@ -142,7 +142,9 @@ def detect_version(self, detect_version_args):
compiler_name = detect_version_args.id.compiler_name compiler_name = detect_version_args.id.compiler_name
compiler_cls = spack.compilers.class_for_compiler_name(compiler_name) compiler_cls = spack.compilers.class_for_compiler_name(compiler_name)
output = modulecmd('avail', compiler_cls.PrgEnv_compiler) output = modulecmd('avail', compiler_cls.PrgEnv_compiler)
version_regex = r'(%s)/([\d\.]+[\d])' % compiler_cls.PrgEnv_compiler version_regex = r'({0})/([\d\.]+[\d]-?[\w]*)'.format(
compiler_cls.PrgEnv_compiler
)
matches = re.findall(version_regex, output) matches = re.findall(version_regex, output)
version = tuple(version for _, version in matches) version = tuple(version for _, version in matches)
compiler_id = detect_version_args.id compiler_id = detect_version_args.id

View File

@ -358,12 +358,20 @@ def test_arm_flags():
def test_cce_flags(): def test_cce_flags():
supported_flag_test("version_argument", "--version", "cce@9.0.1")
supported_flag_test("version_argument", "-V", "cce@9.0.1-classic")
supported_flag_test("openmp_flag", "-fopenmp", "cce@9.0.1")
supported_flag_test("openmp_flag", "-h omp", "cce@9.0.1-classic")
supported_flag_test("openmp_flag", "-h omp", "cce@1.0") supported_flag_test("openmp_flag", "-h omp", "cce@1.0")
supported_flag_test("cxx11_flag", "-std=c++11", "cce@9.0.1")
supported_flag_test("cxx11_flag", "-h std=c++11", "cce@9.0.1-classic")
supported_flag_test("cxx11_flag", "-h std=c++11", "cce@1.0") supported_flag_test("cxx11_flag", "-h std=c++11", "cce@1.0")
unsupported_flag_test("c99_flag", "cce@8.0") unsupported_flag_test("c99_flag", "cce@8.0")
supported_flag_test("c99_flag", "-std=c99", "cce@9.0.1")
supported_flag_test("c99_flag", "-h c99,noconform,gnu", "cce@8.1") supported_flag_test("c99_flag", "-h c99,noconform,gnu", "cce@8.1")
supported_flag_test("c99_flag", "-h std=c99,noconform,gnu", "cce@8.4") supported_flag_test("c99_flag", "-h std=c99,noconform,gnu", "cce@8.4")
unsupported_flag_test("c11_flag", "cce@8.4") unsupported_flag_test("c11_flag", "cce@8.4")
supported_flag_test("c11_flag", "-std=c11", "cce@9.0.1")
supported_flag_test("c11_flag", "-h std=c11,noconform,gnu", "cce@8.5") supported_flag_test("c11_flag", "-h std=c11,noconform,gnu", "cce@8.5")
supported_flag_test("cc_pic_flag", "-h PIC", "cce@1.0") supported_flag_test("cc_pic_flag", "-h PIC", "cce@1.0")
supported_flag_test("cxx_pic_flag", "-h PIC", "cce@1.0") supported_flag_test("cxx_pic_flag", "-h PIC", "cce@1.0")