Skip to content
Snippets Groups Projects
Commit 9455621e authored by Barry Smith's avatar Barry Smith Committed by Todd Gamblin
Browse files

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
parent 8fb5cb21
No related branches found
No related tags found
No related merge requests found
../cc
\ No newline at end of file
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment