Add support for gfortran to be used with clang (#2192)
1) list gfortran as a fc and f77 compiler that can work with clang 2) allow compatible gfortran to ./spack compiler find with clang by matching version numbers This is based on the discussions in https://github.com/LLNL/spack/issues/237 https://github.com/dealii/dealii/wiki/deal.II-in-Spack#mixing-gcc-and-clang-on-osx This is not a long term solution but something to get us through the next months until the compiler infrastructure is reworked to allow mixing and matching for C/C++ and Fortran compilers Funded-by: IDEAS Project: IDEAS/xSDK Time: 1.5 hours
This commit is contained in:
parent
8fb5cb2137
commit
9455621ec2
1
lib/spack/env/clang/gfortran
vendored
Symbolic link
1
lib/spack/env/clang/gfortran
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../cc
|
@ -24,6 +24,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import spack
|
import spack
|
||||||
import spack.compiler as cpr
|
import spack.compiler as cpr
|
||||||
from spack.compiler import *
|
from spack.compiler import *
|
||||||
@ -41,18 +42,18 @@ class Clang(Compiler):
|
|||||||
cxx_names = ['clang++']
|
cxx_names = ['clang++']
|
||||||
|
|
||||||
# Subclasses use possible names of Fortran 77 compiler
|
# Subclasses use possible names of Fortran 77 compiler
|
||||||
f77_names = []
|
f77_names = ['gfortran']
|
||||||
|
|
||||||
# Subclasses use possible names of Fortran 90 compiler
|
# Subclasses use possible names of Fortran 90 compiler
|
||||||
fc_names = []
|
fc_names = ['gfortran']
|
||||||
|
|
||||||
# Named wrapper links within spack.build_env_path
|
# Named wrapper links within spack.build_env_path
|
||||||
link_paths = {'cc': 'clang/clang',
|
link_paths = {'cc': 'clang/clang',
|
||||||
'cxx': 'clang/clang++',
|
'cxx': 'clang/clang++',
|
||||||
# Use default wrappers for fortran, in case provided in
|
# Use default wrappers for fortran, in case provided in
|
||||||
# compilers.yaml
|
# compilers.yaml
|
||||||
'f77': 'f77',
|
'f77': 'clang/gfortran',
|
||||||
'fc': 'f90'}
|
'fc': 'clang/gfortran'}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_apple(self):
|
def is_apple(self):
|
||||||
@ -121,6 +122,28 @@ def _find_full_path(self, path):
|
|||||||
full_path = xcrun('-f', basename, output=str)
|
full_path = xcrun('-f', basename, output=str)
|
||||||
return full_path.strip()
|
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):
|
def setup_custom_environment(self, env):
|
||||||
"""Set the DEVELOPER_DIR environment for the Xcode toolchain.
|
"""Set the DEVELOPER_DIR environment for the Xcode toolchain.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user