From 8738a3a88c48fd9ed2a9c6182e71e94e6e2d5c3f Mon Sep 17 00:00:00 2001 From: David Beckingsale Date: Thu, 31 Jul 2014 15:37:35 -0700 Subject: Added LLVM package --- var/spack/packages/llvm/package.py | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 var/spack/packages/llvm/package.py (limited to 'var') diff --git a/var/spack/packages/llvm/package.py b/var/spack/packages/llvm/package.py new file mode 100644 index 0000000000..dab10f77d3 --- /dev/null +++ b/var/spack/packages/llvm/package.py @@ -0,0 +1,48 @@ +############################################################################## +# Copyright (c) 2013, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Written by David Beckingsale, david@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 import * + +class Llvm(Package): + """The LLVM Project is a collection of modular and reusable compiler and + toolchain technologies. Despite its name, LLVM has little to do with + traditional virtual machines, though it does provide helpful libraries + that can be used to build them. The name "LLVM" itself is not an acronym; + it is the full name of the project. + """ + homepage = "http://llvm.org/" + url = "http://llvm.org/releases/3.4.2/llvm-3.4.2.src.tar.gz" + + version('3.4.2', 'a20669f75967440de949ac3b1bad439c') + + def install(self, spec, prefix): + configure("--prefix=%s" % prefix, + "--enable-optimized", + "--enable-debug-runtime", + "--enable-debug-symbols", + "--disable-assertions", + "REQUIRES_RTTI=1") + + make() + make("install") -- cgit v1.2.3-70-g09d2 From c55041e9d47cba97fc461c088c4b935b3355e340 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 1 Aug 2014 08:33:00 -0700 Subject: Partial commit of more packages. --- README.md | 18 +++++++- lib/spack/llnl/util/filesystem.py | 21 ++++++---- lib/spack/spack/build_environment.py | 5 ++- lib/spack/spack/cmd/create.py | 30 +++++++------- lib/spack/spack/package.py | 2 +- lib/spack/spack/util/executable.py | 2 +- var/spack/packages/clang/package.py | 47 +++++++++++++++++++++ var/spack/packages/llvm-compiler-rt/package.py | 57 ++++++++++++++++++++++++++ var/spack/packages/llvm-lld/package.py | 46 +++++++++++++++++++++ var/spack/packages/llvm/package.py | 18 ++++---- 10 files changed, 210 insertions(+), 36 deletions(-) create mode 100644 var/spack/packages/clang/package.py create mode 100644 var/spack/packages/llvm-compiler-rt/package.py create mode 100644 var/spack/packages/llvm-lld/package.py (limited to 'var') diff --git a/README.md b/README.md index c883cf44b4..11d505a779 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,20 @@ for Spack is also available. Authors ---------------- Spack was written by Todd Gamblin, tgamblin@llnl.gov. -LLNL-CODE-647188 + +Significant contributions were also made by the following awesome +people: + + * David Beckingsale + * David Boehme + * Luc Jaulmes + * Matt Legendre + * Greg Lee + * Adam Moody + +Release +---------------- +Spack is released under an LGPL license. For more details see the +LICENSE file. + +``LLNL-CODE-647188`` diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 11c3dee604..3782aefcce 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -124,8 +124,19 @@ def expand_user(path): return path.replace('%u', username) +def mkdirp(*paths): + for path in paths: + if not os.path.exists(path): + os.makedirs(path) + elif not os.path.isdir(path): + raise OSError(errno.EEXIST, "File alredy exists", path) + + @contextmanager -def working_dir(dirname): +def working_dir(dirname, **kwargs): + if kwargs.get('create', False): + mkdirp(dirname) + orig_dir = os.getcwd() os.chdir(dirname) yield @@ -137,14 +148,6 @@ def touch(path): os.utime(path, None) -def mkdirp(*paths): - for path in paths: - if not os.path.exists(path): - os.makedirs(path) - elif not os.path.isdir(path): - raise OSError(errno.EEXIST, "File alredy exists", path) - - def join_path(prefix, *args): path = str(prefix) for elt in args: diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 38d5f70282..f72c724420 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -153,6 +153,9 @@ def set_module_variables_for_package(pkg): m.make = MakeExecutable('make', pkg.parallel) m.gmake = MakeExecutable('gmake', pkg.parallel) + # easy shortcut to os.environ + m.env = os.environ + # number of jobs spack prefers to build with. m.make_jobs = multiprocessing.cpu_count() @@ -168,7 +171,7 @@ def set_module_variables_for_package(pkg): # standard CMake arguments m.std_cmake_args = ['-DCMAKE_INSTALL_PREFIX=%s' % pkg.prefix, - '-DCMAKE_BUILD_TYPE=None'] + '-DCMAKE_BUILD_TYPE=RelWithDebInfo'] if platform.mac_ver()[0]: m.std_cmake_args.append('-DCMAKE_FIND_FRAMEWORK=LAST') diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index 1a1a19a4b6..c98162aca7 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -87,6 +87,9 @@ def setup_parser(subparser): subparser.add_argument( '--keep-stage', action='store_true', dest='keep_stage', help="Don't clean up staging area when command completes.") + subparser.add_argument( + '-n', '--name', dest='alternate_name', default=None, + help="Override the autodetected name for the created package.") subparser.add_argument( '-f', '--force', action='store_true', dest='force', help="Overwrite any existing package file with the same name.") @@ -121,30 +124,27 @@ def make_version_calls(ver_hash_tuples): return '\n'.join(format % ("'%s'" % v, h) for v, h in ver_hash_tuples) -def get_name(): - """Prompt user to input a package name.""" - name = "" - while not name: - new_name = raw_input("Name: ") - if spack.db.valid_name(name): - name = new_name - else: - print "Package name can only contain A-Z, a-z, 0-9, '_' and '-'" - return name - - def create(parser, args): url = args.url # Try to deduce name and version of the new package from the URL name, version = spack.url.parse_name_and_version(url) - if not name: - tty.msg("Couldn't guess a name for this package.") - name = get_name() + + # Use a user-supplied name if one is present + name = kwargs.get(args, 'alternate_name', False) + if args.name: + name = args.name if not version: tty.die("Couldn't guess a version string from %s." % url) + if not name: + tty.die("Couldn't guess a name for this package. Try running:", "", + "spack create --name ") + + if not spack.db.valid_name(name): + tty.die("Package name can only contain A-Z, a-z, 0-9, '_' and '-'") + tty.msg("This looks like a URL for %s version %s." % (name, version)) tty.msg("Creating template for package %s" % name) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 8df658e660..0375df7dac 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -57,7 +57,7 @@ from spack.util.web import get_pages from spack.util.compression import allowed_archive, extension """Allowed URL schemes for spack packages.""" -_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file"] +_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"] class Package(object): diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index bc27b25889..923c7c19a5 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -121,7 +121,7 @@ def which(name, **kwargs): for dir in path: exe = os.path.join(dir, name) - if os.access(exe, os.X_OK): + if os.path.isfile(exe) and os.access(exe, os.X_OK): return Executable(exe) if required: diff --git a/var/spack/packages/clang/package.py b/var/spack/packages/clang/package.py new file mode 100644 index 0000000000..07948a3ed7 --- /dev/null +++ b/var/spack/packages/clang/package.py @@ -0,0 +1,47 @@ +############################################################################## +# 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 import * + +class Clang(Package): + """The goal of the Clang project is to create a new C, C++, + Objective C and Objective C++ front-end for the LLVM compiler. + """ + homepage = "http://clang.llvm.org" + url = "http://llvm.org/releases/3.4.2/cfe-3.4.2.src.tar.gz" + + depends_on("llvm") + + version('3.4.2', '87945973b7c73038871c5f849a818588') + + def install(self, spec, prefix): + env['CXXFLAGS'] = '-std=c++11' + + with working_dir('spack-build', create=True): + cmake('..', + '-DCLANG_PATH_TO_LLVM_BUILD=%s' % spec['llvm'].prefix, + '-DLLVM_MAIN_SRC_DIR=%s' % spec['llvm'].prefix, + *std_cmake_args) + make() + make("install") diff --git a/var/spack/packages/llvm-compiler-rt/package.py b/var/spack/packages/llvm-compiler-rt/package.py new file mode 100644 index 0000000000..e3fa176afe --- /dev/null +++ b/var/spack/packages/llvm-compiler-rt/package.py @@ -0,0 +1,57 @@ +############################################################################## +# 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 import * + +class LlvmCompilerRt(Package): + """Compiler-rt consists of several libraries to be used with LLVM: + basics: + A simple library that provides an implementation of the + low-level target-specific hooks required by code + generation and other runtime components. + + sanitizer runtimes: + Runtime libraries that are required to run the code with + sanitizer instrumentation. + + profiler: + Library used to collect coverage information. + + BlocksRuntime: + A target-independent implementation of Apple "Blocks" + runtime interfaces. + """ + homepage = "http://compiler-rt.llvm.org" + url = "http://llvm.org/releases/3.4/compiler-rt-3.4.src.tar.gz" + + depends_on("clang") + depends_on("llvm") + + version('3.4', '7938353e3a3bda85733a165e7ac4bb84') + + def install(self, spec, prefix): + cmake(".", *std_cmake_args) + + make() + make("install") diff --git a/var/spack/packages/llvm-lld/package.py b/var/spack/packages/llvm-lld/package.py new file mode 100644 index 0000000000..ba0b229228 --- /dev/null +++ b/var/spack/packages/llvm-lld/package.py @@ -0,0 +1,46 @@ +############################################################################## +# 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 import * + +class LlvmLld(Package): + """lld - The LLVM Linker + lld is a new set of modular code for creating linker tools.""" + homepage = "http://lld.llvm.org" + url = "http://llvm.org/releases/3.4/lld-3.4.src.tar.gz" + + depends_on('llvm') + + version('3.4', '3b6a17e58c8416c869c14dd37682f78e') + + def install(self, spec, prefix): + env['CXXFLAGS'] = '-std=c++11' + + with working_dir('spack-build', create=True): + cmake('..', + '-DLLD_PATH_TO_LLVM_BUILD=%s' % spec['llvm'].prefix, + '-DLLVM_MAIN_SRC_DIR=%s' % spec['llvm'].prefix, + *std_cmake_args) + make('VERBOSE=1') + make("install") diff --git a/var/spack/packages/llvm/package.py b/var/spack/packages/llvm/package.py index dab10f77d3..08ae7208cd 100644 --- a/var/spack/packages/llvm/package.py +++ b/var/spack/packages/llvm/package.py @@ -37,12 +37,14 @@ class Llvm(Package): version('3.4.2', 'a20669f75967440de949ac3b1bad439c') def install(self, spec, prefix): - configure("--prefix=%s" % prefix, - "--enable-optimized", - "--enable-debug-runtime", - "--enable-debug-symbols", - "--disable-assertions", - "REQUIRES_RTTI=1") + env['CXXFLAGS'] = '-std=c++11' - make() - make("install") + with working_dir('spack-build', create=True): + cmake('..', + '-DLLVM_REQUIRES_RTTI=1', + '-DPYTHON_EXECUTABLE=/usr/bin/python', + '-DPYTHON_INCLUDE_DIR=/usr/include/python2.6', + '-DPYTHON_LIBRARY=/usr/lib64/libpython2.6.so', + *std_cmake_args) + make() + make("install") -- cgit v1.2.3-70-g09d2 From 9165a000a3b0ac68692d8ad58bb41d85276cec61 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 18 Sep 2014 23:22:03 -0700 Subject: Better C++11 support, remove non-standalone llvm-compiler-rt. - LLVM non-standalone add-ons are difficult to build outside LLVM. - May have to wait for future versions of LLVM to build some of these --- lib/spack/spack/build_environment.py | 2 +- lib/spack/spack/cmd/pkg.py | 124 +++++++++++++++++++++++++ lib/spack/spack/compiler.py | 3 + lib/spack/spack/compilers/gcc.py | 11 +++ lib/spack/spack/compilers/intel.py | 9 ++ lib/spack/spack/package.py | 9 ++ var/spack/packages/clang/package.py | 2 +- var/spack/packages/llvm-compiler-rt/package.py | 57 ------------ var/spack/packages/llvm-lld/package.py | 4 +- var/spack/packages/llvm/package.py | 2 +- 10 files changed, 161 insertions(+), 62 deletions(-) create mode 100644 lib/spack/spack/cmd/pkg.py delete mode 100644 var/spack/packages/llvm-compiler-rt/package.py (limited to 'var') diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index f72c724420..80abde70a9 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -84,7 +84,7 @@ class MakeExecutable(Executable): def set_compiler_environment_variables(pkg): assert(pkg.spec.concrete) - compiler = compilers.compiler_for_spec(pkg.spec.compiler) + compiler = pkg.compiler # Set compiler variables used by CMake and autotools os.environ['CC'] = 'cc' diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py new file mode 100644 index 0000000000..82ebd13ff9 --- /dev/null +++ b/lib/spack/spack/cmd/pkg.py @@ -0,0 +1,124 @@ +############################################################################## +# 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 +############################################################################## +import os + +from external import argparse +import llnl.util.tty as tty +from llnl.util.tty.colify import colify + +import spack +from spack.util.executable import * + +description = "Query packages associated with particular git revisions in spack." + +def setup_parser(subparser): + sp = subparser.add_subparsers( + metavar='SUBCOMMAND', dest='pkg_command') + + list_parser = sp.add_parser('list', help=pkg_list.__doc__) + list_parser.add_argument('rev', default='HEAD', nargs='?', + help="Revision to list packages for.") + + diff_parser = sp.add_parser('diff', help=pkg_diff.__doc__) + diff_parser.add_argument('rev1', nargs='?', default='HEAD^', + help="Revision to compare against.") + diff_parser.add_argument('rev2', nargs='?', default='HEAD', + help="Revision to compare to rev1 (default is HEAD).") + + add_parser = sp.add_parser('added', help=pkg_added.__doc__) + add_parser.add_argument('rev1', nargs='?', default='HEAD^', + help="Revision to compare against.") + add_parser.add_argument('rev2', nargs='?', default='HEAD', + help="Revision to compare to rev1 (default is HEAD).") + + rm_parser = sp.add_parser('removed', help=pkg_removed.__doc__) + rm_parser.add_argument('rev1', nargs='?', default='HEAD^', + help="Revision to compare against.") + rm_parser.add_argument('rev2', nargs='?', default='HEAD', + help="Revision to compare to rev1 (default is HEAD).") + + +def get_git(): + # cd to spack prefix to do git operations + os.chdir(spack.prefix) + + # If this is a non-git version of spack, give up. + if not os.path.isdir('.git'): + tty.die("No git repo in %s. Can't use 'spack pkg'" % spack.prefix) + + return which("git", required=True) + + +def list_packages(rev): + git = get_git() + relpath = spack.packages_path[len(spack.prefix + os.path.sep):] + os.path.sep + output = git('ls-tree', '--full-tree', '--name-only', rev, relpath, + return_output=True) + return sorted(line[len(relpath):] for line in output.split('\n') if line) + + +def pkg_list(args): + """List packages associated with a particular spack git revision.""" + colify(list_packages(args.rev)) + + +def diff_packages(rev1, rev2): + p1 = set(list_packages(rev1)) + p2 = set(list_packages(rev2)) + return p1.difference(p2), p2.difference(p1) + + +def pkg_diff(args): + """Compare packages available in two different git revisions.""" + u1, u2 = diff_packages(args.rev1, args.rev2) + + if u1: + print "%s:" % args.rev1 + colify(sorted(u1), indent=4) + if u1: print + + if u2: + print "%s:" % args.rev2 + colify(sorted(u2), indent=4) + + +def pkg_removed(args): + """Show packages removed since a commit.""" + u1, u2 = diff_packages(args.rev1, args.rev2) + if u1: colify(sorted(u1)) + + +def pkg_added(args): + """Show packages added since a commit.""" + u1, u2 = diff_packages(args.rev1, args.rev2) + if u2: colify(sorted(u2)) + + +def pkg(parser, args): + action = { 'diff' : pkg_diff, + 'list' : pkg_list, + 'removed' : pkg_removed, + 'added' : pkg_added } + action[args.pkg_command](args) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 716356bdd2..e4a6629759 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -94,6 +94,9 @@ class Compiler(object): # Names of generic arguments used by this compiler arg_rpath = '-Wl,-rpath,%s' + # argument used to get C++11 options + cxx11_flag = "-std=c++11" + def __init__(self, cspec, cc, cxx, f77, fc): def check(exe): diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py index cc3c52ca61..097b24bb87 100644 --- a/lib/spack/spack/compilers/gcc.py +++ b/lib/spack/spack/compilers/gcc.py @@ -22,7 +22,9 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## +import llnl.util.tty as tty from spack.compiler import * +from spack.version import ver class Gcc(Compiler): # Subclasses use possible names of C compiler @@ -40,6 +42,15 @@ class Gcc(Compiler): # MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes. suffixes = [r'-mp-\d\.\d'] + @property + def cxx11_flag(self): + if self.version < ver('4.3'): + tty.die("Only gcc 4.3 and above support c++11.") + elif self.version < ver('4.7'): + return "-std=gnu++0x" + else: + return "-std=gnu++11" + @classmethod def fc_version(cls, fc): return get_compiler_version( diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index 02e3b96b19..2a72c4eaea 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -37,6 +37,15 @@ class Intel(Compiler): # Subclasses use possible names of Fortran 90 compiler fc_names = ['ifort'] + @property + def cxx11_flag(self): + if self.version < ver('11.1'): + tty.die("Only intel 11.1 and above support c++11.") + elif self.version < ver('13'): + return "-std=c++0x" + else: + return "-std=c++11" + @classmethod def default_version(cls, comp): diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 0375df7dac..1afdeaf2a0 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -48,6 +48,7 @@ from llnl.util.lang import * import spack import spack.spec import spack.error +import spack.compilers import spack.hooks import spack.build_environment as build_env import spack.url as url @@ -505,6 +506,14 @@ class Package(object): return self.spec.prefix + @property + def compiler(self): + """Get the spack.compiler.Compiler object used to build this package.""" + if not self.spec.concrete: + raise ValueError("Can only get a compiler for a concrete package.") + return spack.compilers.compiler_for_spec(self.spec.compiler) + + def url_version(self, version): """Given a version, this returns a string that should be substituted into the package's URL to download that version. diff --git a/var/spack/packages/clang/package.py b/var/spack/packages/clang/package.py index 07948a3ed7..b0097bd126 100644 --- a/var/spack/packages/clang/package.py +++ b/var/spack/packages/clang/package.py @@ -36,7 +36,7 @@ class Clang(Package): version('3.4.2', '87945973b7c73038871c5f849a818588') def install(self, spec, prefix): - env['CXXFLAGS'] = '-std=c++11' + env['CXXFLAGS'] = self.compiler.cxx11_flag with working_dir('spack-build', create=True): cmake('..', diff --git a/var/spack/packages/llvm-compiler-rt/package.py b/var/spack/packages/llvm-compiler-rt/package.py deleted file mode 100644 index e3fa176afe..0000000000 --- a/var/spack/packages/llvm-compiler-rt/package.py +++ /dev/null @@ -1,57 +0,0 @@ -############################################################################## -# 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 import * - -class LlvmCompilerRt(Package): - """Compiler-rt consists of several libraries to be used with LLVM: - basics: - A simple library that provides an implementation of the - low-level target-specific hooks required by code - generation and other runtime components. - - sanitizer runtimes: - Runtime libraries that are required to run the code with - sanitizer instrumentation. - - profiler: - Library used to collect coverage information. - - BlocksRuntime: - A target-independent implementation of Apple "Blocks" - runtime interfaces. - """ - homepage = "http://compiler-rt.llvm.org" - url = "http://llvm.org/releases/3.4/compiler-rt-3.4.src.tar.gz" - - depends_on("clang") - depends_on("llvm") - - version('3.4', '7938353e3a3bda85733a165e7ac4bb84') - - def install(self, spec, prefix): - cmake(".", *std_cmake_args) - - make() - make("install") diff --git a/var/spack/packages/llvm-lld/package.py b/var/spack/packages/llvm-lld/package.py index ba0b229228..f229211396 100644 --- a/var/spack/packages/llvm-lld/package.py +++ b/var/spack/packages/llvm-lld/package.py @@ -35,12 +35,12 @@ class LlvmLld(Package): version('3.4', '3b6a17e58c8416c869c14dd37682f78e') def install(self, spec, prefix): - env['CXXFLAGS'] = '-std=c++11' + env['CXXFLAGS'] = self.compier.cxx11_flag with working_dir('spack-build', create=True): cmake('..', '-DLLD_PATH_TO_LLVM_BUILD=%s' % spec['llvm'].prefix, '-DLLVM_MAIN_SRC_DIR=%s' % spec['llvm'].prefix, *std_cmake_args) - make('VERBOSE=1') + make() make("install") diff --git a/var/spack/packages/llvm/package.py b/var/spack/packages/llvm/package.py index 08ae7208cd..c7a10df55a 100644 --- a/var/spack/packages/llvm/package.py +++ b/var/spack/packages/llvm/package.py @@ -37,7 +37,7 @@ class Llvm(Package): version('3.4.2', 'a20669f75967440de949ac3b1bad439c') def install(self, spec, prefix): - env['CXXFLAGS'] = '-std=c++11' + env['CXXFLAGS'] = self.compiler.cxx11_flag with working_dir('spack-build', create=True): cmake('..', -- cgit v1.2.3-70-g09d2