diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-05-25 15:15:51 -0500 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2016-05-25 15:15:51 -0500 |
commit | 76d42b520069e15aa7cf0fa8cbfb3d83c9be7052 (patch) | |
tree | fa8262706cbc99d41e9d0dd09a699fd11f11fc40 /var | |
parent | 1bca69f27281d3bb707bcba41b4f332ab3988509 (diff) | |
parent | 00de72272d2ac4fd949c43cdaa9487defc7875c8 (diff) | |
download | spack-76d42b520069e15aa7cf0fa8cbfb3d83c9be7052.tar.gz spack-76d42b520069e15aa7cf0fa8cbfb3d83c9be7052.tar.bz2 spack-76d42b520069e15aa7cf0fa8cbfb3d83c9be7052.tar.xz spack-76d42b520069e15aa7cf0fa8cbfb3d83c9be7052.zip |
Merge pull request #982 from trws/rust
Rust
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/llvm/package.py | 34 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/rust-bindgen/package.py | 18 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/rust/package.py | 63 |
3 files changed, 109 insertions, 6 deletions
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index c090c131c6..c32f66590a 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * -import os, shutil +import os, glob class Llvm(Package): @@ -46,7 +46,9 @@ class Llvm(Package): variant('libcxx', default=True, description="Build the LLVM C++ standard library") variant('compiler-rt', default=True, description="Build the LLVM compiler runtime, including sanitizers") variant('gold', default=True, description="Add support for LTO with the gold linker plugin") - + variant('shared_libs', default=False, description="Build all components as shared libraries, faster, less memory to build, less stable") + variant('link_dylib', default=False, description="Build and link the libLLVM shared library rather than static") + variant('all_targets', default=True, description="Build all supported targets, default targets <current arch>,NVPTX,AMDGPU,CppBackend") # Build dependency depends_on('cmake @2.8.12.2:') @@ -257,6 +259,28 @@ class Llvm(Package): if '+compiler-rt' not in spec: cmake_args.append('-DLLVM_EXTERNAL_COMPILER_RT_BUILD:Bool=OFF') + if '+shared_libs' in spec: + cmake_args.append('-DBUILD_SHARED_LIBS:Bool=ON') + + if '+link_dylib' in spec: + cmake_args.append('-DLLVM_LINK_LLVM_DYLIB:Bool=ON') + + if '+all_targets' not in spec: # all is default on cmake + targets = ['CppBackend', 'NVPTX', 'AMDGPU'] + if 'x86' in spec.architecture.lower(): + targets.append('X86') + elif 'arm' in spec.architecture.lower(): + targets.append('ARM') + elif 'aarch64' in spec.architecture.lower(): + targets.append('AArch64') + elif 'sparc' in spec.architecture.lower(): + targets.append('sparc') + elif ('ppc' in spec.architecture.lower() or + 'power' in spec.architecture.lower()): + targets.append('PowerPC') + + cmake_args.append('-DLLVM_TARGETS_TO_BUILD:Bool=' + ';'.join(targets)) + if '+clang' not in spec: if '+clang_extra' in spec: raise SpackException('The clang_extra variant requires the clang variant to be selected') @@ -267,7 +291,5 @@ class Llvm(Package): cmake(*cmake_args) make() make("install") - query_path = os.path.join('bin', 'clang-query') - # Manually install clang-query, because llvm doesn't... - if os.path.exists(query_path): - shutil.copy(query_path, os.path.join(prefix, 'bin')) + cp = which('cp') + cp('-a', 'bin/', prefix) diff --git a/var/spack/repos/builtin/packages/rust-bindgen/package.py b/var/spack/repos/builtin/packages/rust-bindgen/package.py new file mode 100644 index 0000000000..854016d12a --- /dev/null +++ b/var/spack/repos/builtin/packages/rust-bindgen/package.py @@ -0,0 +1,18 @@ +from spack import * +import os + + +class RustBindgen(Package): + """The rust programming language toolchain""" + homepage = "http://www.rust-lang.org" + url = "https://github.com/crabtw/rust-bindgen" + + version('0.16', tag='0.16', git='https://github.com/crabtw/rust-bindgen') + + extends("rust") + depends_on("llvm") + + def install(self, spec, prefix): + env = dict(os.environ) + env['LIBCLANG_PATH'] = os.path.join(spec['llvm'].prefix, 'lib') + cargo('install', '--root', prefix, env=env) diff --git a/var/spack/repos/builtin/packages/rust/package.py b/var/spack/repos/builtin/packages/rust/package.py new file mode 100644 index 0000000000..65f81ce534 --- /dev/null +++ b/var/spack/repos/builtin/packages/rust/package.py @@ -0,0 +1,63 @@ +from spack import * +import os + + +def get_submodules(): + git = which('git') + git('submodule', 'update', '--init', '--recursive') + +class Rust(Package): + """The rust programming language toolchain""" + homepage = "http://www.rust-lang.org" + url = "https://github.com/rust-lang/rust" + + version('1.8.0', tag='1.8.0', git="https://github.com/rust-lang/rust") + + resource(name='cargo', + git="https://github.com/rust-lang/cargo.git", + tag='0.10.0', + destination='cargo') + + extendable = True + + # Rust + depends_on("llvm") + depends_on("curl") + depends_on("git") + depends_on("cmake") + depends_on("python@:2.8") + + # Cargo + depends_on("openssl") + + def install(self, spec, prefix): + configure('--prefix=%s' % prefix, + '--llvm-root=' + spec['llvm'].prefix) + + make() + make("install") + + # Install cargo, rust package manager + with working_dir(os.path.join('cargo', 'cargo')): + get_submodules() + configure('--prefix=' + prefix, + '--local-rust-root=' + prefix) + + make() + make("install") + + def setup_dependent_package(self, module, ext_spec): + """ + Called before python modules' install() methods. + + In most cases, extensions will only need to have one or two lines:: + + cargo('build') + cargo('install', '--root', prefix) + + or + + cargo('install', '--root', prefix) + """ + # Rust extension builds can have a global cargo executable function + module.cargo = Executable(join_path(self.spec.prefix.bin, 'cargo')) |