Sorted out spack.compilers vs var/spack/compilers
This commit is contained in:
@@ -31,13 +31,10 @@
|
|||||||
|
|
||||||
description = "List available compilers"
|
description = "List available compilers"
|
||||||
|
|
||||||
|
|
||||||
def compilers(parser, args):
|
def compilers(parser, args):
|
||||||
tty.msg("Available compilers")
|
tty.msg("Available compilers")
|
||||||
|
|
||||||
# Index compilers
|
|
||||||
index = index_by(spack.compilers.supported_compilers(), 'name')
|
index = index_by(spack.compilers.supported_compilers(), 'name')
|
||||||
|
|
||||||
for name, compilers in index.items():
|
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)
|
colify(compilers, indent=4)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
|
from llnl.util.lang import memoized
|
||||||
|
|
||||||
import spack.error
|
import spack.error
|
||||||
from spack.version import Version
|
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):
|
def _verify_executables(*paths):
|
||||||
|
|||||||
@@ -27,21 +27,36 @@
|
|||||||
#
|
#
|
||||||
from llnl.util.lang import memoized, list_modules
|
from llnl.util.lang import memoized, list_modules
|
||||||
|
|
||||||
import spack
|
|
||||||
import spack.compilers.gcc
|
|
||||||
import spack.spec
|
import spack.spec
|
||||||
|
from spack.util.executable import which
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
def supported_compilers():
|
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):
|
def supported(compiler_spec):
|
||||||
return True
|
"""Test if a particular compiler is supported."""
|
||||||
# return compiler in supported_compilers()
|
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
|
@memoized
|
||||||
def default_compiler():
|
def default_compiler():
|
||||||
from spack.spec import Compiler
|
"""Get the spec for the default compiler supported by Spack.
|
||||||
return Compiler('gcc', gcc.get_version())
|
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,
|
# 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
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
from spack.compiler import Compiler
|
||||||
# This is a stub module. It should be expanded when we implement full
|
|
||||||
# compiler support.
|
|
||||||
#
|
|
||||||
|
|
||||||
import subprocess
|
class Gcc(Compiler):
|
||||||
from spack.version import Version
|
# Subclasses use possible names of C compiler
|
||||||
|
cc_names = ['gcc']
|
||||||
|
|
||||||
cc = 'gcc'
|
# Subclasses use possible names of C++ compiler
|
||||||
cxx = 'g++'
|
cxx_names = ['g++']
|
||||||
fortran = 'gfortran'
|
|
||||||
|
|
||||||
def get_version():
|
# Subclasses use possible names of Fortran 77 compiler
|
||||||
v = subprocess.check_output([cc, '-dumpversion'])
|
f77_names = ['gfortran']
|
||||||
return Version(v)
|
|
||||||
|
# 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,
|
# 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
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
from spack.compiler import Compiler
|
||||||
# This is a stub module. It should be expanded when we implement full
|
|
||||||
# compiler support.
|
|
||||||
#
|
|
||||||
|
|
||||||
import subprocess
|
class Intel(Compiler):
|
||||||
from spack.version import Version
|
# Subclasses use possible names of C compiler
|
||||||
|
cc_names = ['icc']
|
||||||
|
|
||||||
cc = 'icc'
|
# Subclasses use possible names of C++ compiler
|
||||||
cxx = 'icc'
|
cxx_names = ['icpc']
|
||||||
fortran = 'ifort'
|
|
||||||
|
|
||||||
def get_version():
|
# Subclasses use possible names of Fortran 77 compiler
|
||||||
v = subprocess.check_output([cc, '-dumpversion'])
|
f77_names = ['ifort']
|
||||||
return Version(v)
|
|
||||||
|
# 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")
|
lib_path = join_path(prefix, "lib", "spack")
|
||||||
build_env_path = join_path(lib_path, "env")
|
build_env_path = join_path(lib_path, "env")
|
||||||
module_path = join_path(lib_path, "spack")
|
module_path = join_path(lib_path, "spack")
|
||||||
|
compilers_path = join_path(module_path, "compilers")
|
||||||
test_path = join_path(module_path, "test")
|
test_path = join_path(module_path, "test")
|
||||||
var_path = join_path(prefix, "var", "spack")
|
var_path = join_path(prefix, "var", "spack")
|
||||||
stage_path = join_path(var_path, "stage")
|
stage_path = join_path(var_path, "stage")
|
||||||
@@ -50,9 +51,9 @@
|
|||||||
install_path = join_path(prefix, "opt")
|
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.
|
# Set up the packages database.
|
||||||
|
|||||||
@@ -173,16 +173,23 @@ class Compiler(object):
|
|||||||
"""The Compiler field represents the compiler or range of compiler
|
"""The Compiler field represents the compiler or range of compiler
|
||||||
versions that a package should be built with. Compilers have a
|
versions that a package should be built with. Compilers have a
|
||||||
name and a version list. """
|
name and a version list. """
|
||||||
def __init__(self, compiler_spec_like):
|
def __init__(self, *args):
|
||||||
c = SpecParser().parse_compiler(compiler_spec_like)
|
nargs = len(args)
|
||||||
self.name = c.name
|
if nargs == 1:
|
||||||
self.versions = c.versions
|
# 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):
|
else:
|
||||||
self.name = name
|
raise TypeError(
|
||||||
self.versions = VersionList()
|
"__init__ takes 1 or 2 arguments. (%d given)" % nargs)
|
||||||
self.versions.add(version)
|
|
||||||
|
|
||||||
|
|
||||||
def _add_version(self, version):
|
def _add_version(self, version):
|
||||||
@@ -776,11 +783,10 @@ def validate_names(self):
|
|||||||
if not spec.virtual:
|
if not spec.virtual:
|
||||||
spack.db.get(spec.name)
|
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:
|
if spec.compiler:
|
||||||
compiler_name = spec.compiler.name
|
if not spack.compilers.supported(spec.compiler):
|
||||||
if not spack.compilers.supported(compiler_name):
|
raise UnknownCompilerError(spec.compiler)
|
||||||
raise UnknownCompilerError(compiler_name)
|
|
||||||
|
|
||||||
|
|
||||||
def constrain(self, other, **kwargs):
|
def constrain(self, other, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user