diff --git a/lib/spack/env/clang/gfortran b/lib/spack/env/clang/gfortran new file mode 120000 index 0000000000000000000000000000000000000000..82c2b8e90a381ef733daa21645dc316ee5efe94d --- /dev/null +++ b/lib/spack/env/clang/gfortran @@ -0,0 +1 @@ +../cc \ No newline at end of file diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index 34eec4ea7be9c640c465270694d97dda3aae8835..da18adcecd21a3cdec0977922786de801bb4db88 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -24,6 +24,7 @@ ############################################################################## import re import os +import sys import spack import spack.compiler as cpr from spack.compiler import * @@ -41,18 +42,18 @@ class Clang(Compiler): cxx_names = ['clang++'] # Subclasses use possible names of Fortran 77 compiler - f77_names = [] + f77_names = ['gfortran'] # Subclasses use possible names of Fortran 90 compiler - fc_names = [] + fc_names = ['gfortran'] # Named wrapper links within spack.build_env_path link_paths = {'cc': 'clang/clang', 'cxx': 'clang/clang++', # Use default wrappers for fortran, in case provided in # compilers.yaml - 'f77': 'f77', - 'fc': 'f90'} + 'f77': 'clang/gfortran', + 'fc': 'clang/gfortran'} @property def is_apple(self): @@ -121,6 +122,28 @@ def _find_full_path(self, path): full_path = xcrun('-f', basename, output=str) return full_path.strip() + @classmethod + def fc_version(cls, fc): + version = get_compiler_version( + fc, '-dumpversion', + # older gfortran versions don't have simple dumpversion output. + r'(?:GNU Fortran \(GCC\))?(\d+\.\d+(?:\.\d+)?)') + # This is horribly ad hoc, we need to map from gcc/gfortran version + # to clang version, but there could be multiple clang + # versions that work for a single gcc/gfortran version + if sys.platform == 'darwin': + clangversionfromgcc = {'6.2.0': '8.0.0-apple'} + else: + clangversionfromgcc = {} + if version in clangversionfromgcc: + return clangversionfromgcc[version] + else: + return 'unknown' + + @classmethod + def f77_version(cls, f77): + return cls.fc_version(f77) + def setup_custom_environment(self, env): """Set the DEVELOPER_DIR environment for the Xcode toolchain.