Skip to content
Snippets Groups Projects
Commit 8ef800f6 authored by Todd Gamblin's avatar Todd Gamblin
Browse files

Merge pull request #394 from LLNL/bugfix/apple-llvm-compiler-detection

Bugfix/apple llvm compiler detection
parents 41cd8f8e 004c99ab
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,10 @@ ...@@ -22,7 +22,10 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import re
import spack.compiler as cpr
from spack.compiler import * from spack.compiler import *
from spack.util.executable import *
class Clang(Compiler): class Clang(Compiler):
# Subclasses use possible names of C compiler # Subclasses use possible names of C compiler
...@@ -47,11 +50,34 @@ class Clang(Compiler): ...@@ -47,11 +50,34 @@ class Clang(Compiler):
@classmethod @classmethod
def default_version(self, comp): def default_version(self, comp):
"""The '--version' option works for clang compilers. """The '--version' option works for clang compilers.
Output looks like this:: On most platforms, output looks like this::
clang version 3.1 (trunk 149096) clang version 3.1 (trunk 149096)
Target: x86_64-unknown-linux-gnu Target: x86_64-unknown-linux-gnu
Thread model: posix Thread model: posix
On Mac OS X, it looks like this:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
""" """
return get_compiler_version( if comp not in cpr._version_cache:
comp, '--version', r'(?:clang version|based on LLVM) ([^ )]+)') compiler = Executable(comp)
output = compiler('--version', output=str, error=str)
ver = 'unknown'
match = re.search(r'^Apple LLVM version ([^ )]+)', output)
if match:
# Apple's LLVM compiler has its own versions, so suffix them.
ver = match.group(1) + '-apple'
else:
# Normal clang compiler versions are left as-is
match = re.search(r'^clang version ([^ )]+)', output)
if match:
ver = match.group(1)
cpr._version_cache[comp] = ver
return cpr._version_cache[comp]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment