clang: add 'version_argument', remove redundant method (#17071)

This commit is contained in:
Greg Becker
2020-06-13 06:31:24 -07:00
committed by GitHub
parent b9cf50d571
commit 58332d028e
2 changed files with 3 additions and 20 deletions

View File

@@ -50,6 +50,8 @@ class Clang(Compiler):
# Subclasses use possible names of Fortran 90 compiler # Subclasses use possible names of Fortran 90 compiler
fc_names = ['flang', 'gfortran', 'xlf90_r'] fc_names = ['flang', 'gfortran', 'xlf90_r']
version_argument = '--version'
@property @property
def debug_flags(self): def debug_flags(self):
return ['-gcodeview', '-gdwarf-2', '-gdwarf-3', '-gdwarf-4', return ['-gcodeview', '-gdwarf-2', '-gdwarf-3', '-gdwarf-4',
@@ -201,26 +203,6 @@ def fc_pic_flag(self):
required_libs = ['libclang'] required_libs = ['libclang']
@classmethod
@llnl.util.lang.memoized
def default_version(cls, comp):
"""The ``--version`` option works for clang compilers.
On most platforms, output looks like this::
clang version 3.1 (trunk 149096)
Target: x86_64-unknown-linux-gnu
Thread model: posix
On macOS, it looks like this::
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
"""
compiler = Executable(comp)
output = compiler('--version', output=str, error=str)
return cls.extract_version_from_output(output)
@classmethod @classmethod
@llnl.util.lang.memoized @llnl.util.lang.memoized
def extract_version_from_output(cls, output): def extract_version_from_output(cls, output):

View File

@@ -389,6 +389,7 @@ def test_clang_flags():
supported_flag_test("fc_pic_flag", "-fPIC", "clang@2.0.0-apple") supported_flag_test("fc_pic_flag", "-fPIC", "clang@2.0.0-apple")
# non-Apple Clang. # non-Apple Clang.
supported_flag_test("version_argument", "--version", "clang@foo.bar")
supported_flag_test("openmp_flag", "-fopenmp", "clang@3.3") supported_flag_test("openmp_flag", "-fopenmp", "clang@3.3")
unsupported_flag_test("cxx11_flag", "clang@3.2") unsupported_flag_test("cxx11_flag", "clang@3.2")
supported_flag_test("cxx11_flag", "-std=c++11", "clang@3.3") supported_flag_test("cxx11_flag", "-std=c++11", "clang@3.3")