Sorted out spack.compilers vs var/spack/compilers
This commit is contained in:
@@ -31,13 +31,10 @@
|
||||
|
||||
description = "List available compilers"
|
||||
|
||||
|
||||
def compilers(parser, args):
|
||||
tty.msg("Available compilers")
|
||||
|
||||
# Index compilers
|
||||
index = index_by(spack.compilers.supported_compilers(), 'name')
|
||||
|
||||
for name, compilers in index.items():
|
||||
tty.hline(name, char='=', color=spack.spec.compiler_color)
|
||||
tty.hline(name, char='-', color=spack.spec.compiler_color)
|
||||
colify(compilers, indent=4)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import os
|
||||
from llnl.util.lang import memoized
|
||||
|
||||
import spack.error
|
||||
from spack.version import Version
|
||||
from spack.util import Executable
|
||||
from spack.util.executable import Executable
|
||||
|
||||
|
||||
from subprocess import check_output
|
||||
|
||||
|
||||
def _verify_executables(*paths):
|
||||
|
||||
@@ -27,21 +27,36 @@
|
||||
#
|
||||
from llnl.util.lang import memoized, list_modules
|
||||
|
||||
import spack
|
||||
import spack.compilers.gcc
|
||||
import spack.spec
|
||||
from spack.util.executable import which
|
||||
|
||||
|
||||
|
||||
@memoized
|
||||
def supported_compilers():
|
||||
return [spack.spec.Compiler(c) for c in list_modules(spack.compilers_path)]
|
||||
"""Return a list of compiler types supported by Spack."""
|
||||
return sorted(c for c in list_modules(spack.compilers_path))
|
||||
|
||||
|
||||
def supported(compiler):
|
||||
return True
|
||||
# return compiler in supported_compilers()
|
||||
def supported(compiler_spec):
|
||||
"""Test if a particular compiler is supported."""
|
||||
if isinstance(compiler_spec, spack.spec.Compiler):
|
||||
return compiler_spec.name in supported_compilers()
|
||||
|
||||
elif isinstance(compiler_spec, basestring):
|
||||
return compiler_spec in supported_compilers()
|
||||
|
||||
else:
|
||||
raise TypeError("compiler_spec must be string or spack.spec.Compiler")
|
||||
|
||||
|
||||
@memoized
|
||||
def default_compiler():
|
||||
from spack.spec import Compiler
|
||||
return Compiler('gcc', gcc.get_version())
|
||||
"""Get the spec for the default compiler supported by Spack.
|
||||
Currently just returns the system's default gcc.
|
||||
|
||||
TODO: provide a better way to specify/find this on startup.
|
||||
"""
|
||||
gcc = which('gcc', required=True)
|
||||
version = gcc('-dumpversion', return_output=True)
|
||||
return spack.spec.Compiler('gcc', version)
|
||||
|
||||
41
lib/spack/spack/compilers/clang.py
Normal file
41
lib/spack/spack/compilers/clang.py
Normal file
@@ -0,0 +1,41 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://scalability-llnl.github.io/spack
|
||||
# Please also see the LICENSE file for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License (as published by
|
||||
# the Free Software Foundation) version 2.1 dated February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack.compiler import Compiler
|
||||
|
||||
class Clang(Compiler):
|
||||
# Subclasses use possible names of C compiler
|
||||
cc_names = ['clang']
|
||||
|
||||
# Subclasses use possible names of C++ compiler
|
||||
cxx_names = ['clang++']
|
||||
|
||||
# Subclasses use possible names of Fortran 77 compiler
|
||||
f77_names = []
|
||||
|
||||
# Subclasses use possible names of Fortran 90 compiler
|
||||
f90_names = []
|
||||
|
||||
def __init__(self, cc, cxx, f77, f90):
|
||||
super(Gcc, self).__init__(cc, cxx, f77, f90)
|
||||
@@ -22,18 +22,20 @@
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
#
|
||||
# This is a stub module. It should be expanded when we implement full
|
||||
# compiler support.
|
||||
#
|
||||
from spack.compiler import Compiler
|
||||
|
||||
import subprocess
|
||||
from spack.version import Version
|
||||
class Gcc(Compiler):
|
||||
# Subclasses use possible names of C compiler
|
||||
cc_names = ['gcc']
|
||||
|
||||
cc = 'gcc'
|
||||
cxx = 'g++'
|
||||
fortran = 'gfortran'
|
||||
# Subclasses use possible names of C++ compiler
|
||||
cxx_names = ['g++']
|
||||
|
||||
def get_version():
|
||||
v = subprocess.check_output([cc, '-dumpversion'])
|
||||
return Version(v)
|
||||
# Subclasses use possible names of Fortran 77 compiler
|
||||
f77_names = ['gfortran']
|
||||
|
||||
# Subclasses use possible names of Fortran 90 compiler
|
||||
f90_names = ['gfortran']
|
||||
|
||||
def __init__(self, cc, cxx, f77, f90):
|
||||
super(Gcc, self).__init__(cc, cxx, f77, f90)
|
||||
|
||||
@@ -22,18 +22,20 @@
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
#
|
||||
# This is a stub module. It should be expanded when we implement full
|
||||
# compiler support.
|
||||
#
|
||||
from spack.compiler import Compiler
|
||||
|
||||
import subprocess
|
||||
from spack.version import Version
|
||||
class Intel(Compiler):
|
||||
# Subclasses use possible names of C compiler
|
||||
cc_names = ['icc']
|
||||
|
||||
cc = 'icc'
|
||||
cxx = 'icc'
|
||||
fortran = 'ifort'
|
||||
# Subclasses use possible names of C++ compiler
|
||||
cxx_names = ['icpc']
|
||||
|
||||
def get_version():
|
||||
v = subprocess.check_output([cc, '-dumpversion'])
|
||||
return Version(v)
|
||||
# Subclasses use possible names of Fortran 77 compiler
|
||||
f77_names = ['ifort']
|
||||
|
||||
# Subclasses use possible names of Fortran 90 compiler
|
||||
f90_names = ['ifort']
|
||||
|
||||
def __init__(self, cc, cxx, f77, f90):
|
||||
super(Gcc, self).__init__(cc, cxx, f77, f90)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
lib_path = join_path(prefix, "lib", "spack")
|
||||
build_env_path = join_path(lib_path, "env")
|
||||
module_path = join_path(lib_path, "spack")
|
||||
compilers_path = join_path(module_path, "compilers")
|
||||
test_path = join_path(module_path, "test")
|
||||
var_path = join_path(prefix, "var", "spack")
|
||||
stage_path = join_path(var_path, "stage")
|
||||
@@ -50,9 +51,9 @@
|
||||
install_path = join_path(prefix, "opt")
|
||||
|
||||
#
|
||||
# Place to look for usable compiler installations
|
||||
# Place to look for usable compiler versions.
|
||||
#
|
||||
compilers_path = join_path(var_path, "compilers")
|
||||
compiler_version_path = join_path(var_path, "compilers")
|
||||
|
||||
#
|
||||
# Set up the packages database.
|
||||
|
||||
@@ -173,16 +173,23 @@ class Compiler(object):
|
||||
"""The Compiler field represents the compiler or range of compiler
|
||||
versions that a package should be built with. Compilers have a
|
||||
name and a version list. """
|
||||
def __init__(self, compiler_spec_like):
|
||||
c = SpecParser().parse_compiler(compiler_spec_like)
|
||||
self.name = c.name
|
||||
self.versions = c.versions
|
||||
def __init__(self, *args):
|
||||
nargs = len(args)
|
||||
if nargs == 1:
|
||||
# If there is one argument, it's a spec to parse
|
||||
c = SpecParser().parse_compiler(args[0])
|
||||
self.name = c.name
|
||||
self.versions = c.versions
|
||||
|
||||
elif nargs == 2:
|
||||
name, version = args
|
||||
self.name = name
|
||||
self.versions = VersionList()
|
||||
self.versions.add(ver(version))
|
||||
|
||||
def __init__(self, name, version):
|
||||
self.name = name
|
||||
self.versions = VersionList()
|
||||
self.versions.add(version)
|
||||
else:
|
||||
raise TypeError(
|
||||
"__init__ takes 1 or 2 arguments. (%d given)" % nargs)
|
||||
|
||||
|
||||
def _add_version(self, version):
|
||||
@@ -776,11 +783,10 @@ def validate_names(self):
|
||||
if not spec.virtual:
|
||||
spack.db.get(spec.name)
|
||||
|
||||
# validate compiler name in addition to the package name.
|
||||
# validate compiler in addition to the package name.
|
||||
if spec.compiler:
|
||||
compiler_name = spec.compiler.name
|
||||
if not spack.compilers.supported(compiler_name):
|
||||
raise UnknownCompilerError(compiler_name)
|
||||
if not spack.compilers.supported(spec.compiler):
|
||||
raise UnknownCompilerError(spec.compiler)
|
||||
|
||||
|
||||
def constrain(self, other, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user