compilers: update clang fortran compiler wrapper selection (#9678)
Clang has support for using different fortran compilers with the Clang executable. Spack includes logic to select a compiler wrapper symlink which refers to the fortran executable (since some build systems depend on the name of the compiler, e.g. 'gfortran' or 'flang'). This selection was previously based on the architecture, and chose incorrectly in some situations (e.g. for clang/gfortran on Linux). This replaces architecture-based wrapper selection with a selection that is based on the name of the Fortran compiler executable.
This commit is contained in:
parent
c10d432a2e
commit
2912cf3e17
1 changed files with 43 additions and 15 deletions
|
@ -16,6 +16,25 @@
|
||||||
from spack.version import ver
|
from spack.version import ver
|
||||||
|
|
||||||
|
|
||||||
|
#: compiler symlink mappings for mixed f77 compilers
|
||||||
|
f77_mapping = [
|
||||||
|
('gfortran', 'clang/gfortran'),
|
||||||
|
('xlf_r', 'xl_r/xlf_r'),
|
||||||
|
('xlf', 'xl/xlf'),
|
||||||
|
('pgfortran', 'pgi/pgfortran'),
|
||||||
|
('ifort', 'intel/ifort')
|
||||||
|
]
|
||||||
|
|
||||||
|
#: compiler symlink mappings for mixed f90/fc compilers
|
||||||
|
fc_mapping = [
|
||||||
|
('gfortran', 'clang/gfortran'),
|
||||||
|
('xlf90_r', 'xl_r/xlf90_r'),
|
||||||
|
('xlf90', 'xl/xlf90'),
|
||||||
|
('pgfortran', 'pgi/pgfortran'),
|
||||||
|
('ifort', 'intel/ifort')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Clang(Compiler):
|
class Clang(Compiler):
|
||||||
# Subclasses use possible names of C compiler
|
# Subclasses use possible names of C compiler
|
||||||
cc_names = ['clang']
|
cc_names = ['clang']
|
||||||
|
@ -29,23 +48,32 @@ 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']
|
||||||
|
|
||||||
# Named wrapper links within lib/spack/env
|
# Clang has support for using different fortran compilers with the
|
||||||
|
# clang executable.
|
||||||
|
@property
|
||||||
|
def link_paths(self):
|
||||||
|
# clang links are always the same
|
||||||
link_paths = {'cc': 'clang/clang',
|
link_paths = {'cc': 'clang/clang',
|
||||||
'cxx': 'clang/clang++'}
|
'cxx': 'clang/clang++'}
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
# fortran links need to look at the actual compiler names from
|
||||||
# Use default wrappers for fortran, in case provided in
|
# compilers.yaml to figure out which named symlink to use
|
||||||
# compilers.yaml
|
for compiler_name, link_path in f77_mapping:
|
||||||
link_paths['f77'] = 'clang/gfortran'
|
if self.f77 and compiler_name in self.f77:
|
||||||
link_paths['fc'] = 'clang/gfortran'
|
link_paths['f77'] = link_path
|
||||||
elif spack.architecture.sys_type() == 'linux-rhel7-ppc64le':
|
break
|
||||||
# This platform uses clang with IBM XL Fortran compiler
|
|
||||||
link_paths['f77'] = 'xl_r/xlf_r'
|
|
||||||
link_paths['fc'] = 'xl_r/xlf90_r'
|
|
||||||
else:
|
else:
|
||||||
link_paths['f77'] = 'clang/flang'
|
link_paths['f77'] = 'clang/flang'
|
||||||
|
|
||||||
|
for compiler_name, link_path in fc_mapping:
|
||||||
|
if self.fc and compiler_name in self.fc:
|
||||||
|
link_paths['fc'] = link_path
|
||||||
|
break
|
||||||
|
else:
|
||||||
link_paths['fc'] = 'clang/flang'
|
link_paths['fc'] = 'clang/flang'
|
||||||
|
|
||||||
|
return link_paths
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_apple(self):
|
def is_apple(self):
|
||||||
ver_string = str(self.version)
|
ver_string = str(self.version)
|
||||||
|
|
Loading…
Reference in a new issue