summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-01-25 03:41:28 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2016-01-25 03:48:22 -0800
commit004c99ab2ffa0a9e4635f3dbf9a9beaceb6727d3 (patch)
treec7fcab4efc47fe4443464ce01f17a4deed88cae2
parentfb5274145aac9266435f3e16f19ce3e30ba1550f (diff)
downloadspack-004c99ab2ffa0a9e4635f3dbf9a9beaceb6727d3.tar.gz
spack-004c99ab2ffa0a9e4635f3dbf9a9beaceb6727d3.tar.bz2
spack-004c99ab2ffa0a9e4635f3dbf9a9beaceb6727d3.tar.xz
spack-004c99ab2ffa0a9e4635f3dbf9a9beaceb6727d3.zip
Fixes #259: Apple clang compiler detection
- Clang compilers are now versioned with the raw LLVM version or, on macs, with Apple's version with a suffix.
-rw-r--r--lib/spack/spack/compilers/clang.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 998d4e5932..e406d86a24 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -22,7 +22,10 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+import re
+import spack.compiler as cpr
from spack.compiler import *
+from spack.util.executable import *
class Clang(Compiler):
# Subclasses use possible names of C compiler
@@ -47,11 +50,34 @@ class Clang(Compiler):
@classmethod
def default_version(self, comp):
"""The '--version' option works for clang compilers.
- Output looks like this::
+ On most platforms, output looks like this::
clang version 3.1 (trunk 149096)
Target: x86_64-unknown-linux-gnu
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(
- comp, '--version', r'(?:clang version|based on LLVM|LLVM version) ([^ )]+)')
+ if comp not in cpr._version_cache:
+ 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]