rust compiler/builder package, new llvm variants
This commit is contained in:
parent
9bd4bc02d6
commit
00de72272d
3 changed files with 35 additions and 9 deletions
|
@ -23,7 +23,7 @@
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from spack import *
|
from spack import *
|
||||||
import os, shutil
|
import os, glob
|
||||||
|
|
||||||
|
|
||||||
class Llvm(Package):
|
class Llvm(Package):
|
||||||
|
@ -46,7 +46,9 @@ class Llvm(Package):
|
||||||
variant('libcxx', default=True, description="Build the LLVM C++ standard library")
|
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('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('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
|
# Build dependency
|
||||||
depends_on('cmake @2.8.12.2:')
|
depends_on('cmake @2.8.12.2:')
|
||||||
|
@ -257,6 +259,28 @@ def install(self, spec, prefix):
|
||||||
if '+compiler-rt' not in spec:
|
if '+compiler-rt' not in spec:
|
||||||
cmake_args.append('-DLLVM_EXTERNAL_COMPILER_RT_BUILD:Bool=OFF')
|
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' not in spec:
|
||||||
if '+clang_extra' in spec:
|
if '+clang_extra' in spec:
|
||||||
raise SpackException('The clang_extra variant requires the clang variant to be selected')
|
raise SpackException('The clang_extra variant requires the clang variant to be selected')
|
||||||
|
@ -267,7 +291,5 @@ def install(self, spec, prefix):
|
||||||
cmake(*cmake_args)
|
cmake(*cmake_args)
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
query_path = os.path.join('bin', 'clang-query')
|
cp = which('cp')
|
||||||
# Manually install clang-query, because llvm doesn't...
|
cp('-a', 'bin/', prefix)
|
||||||
if os.path.exists(query_path):
|
|
||||||
shutil.copy(query_path, os.path.join(prefix, 'bin'))
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ class RustBindgen(Package):
|
||||||
version('0.16', tag='0.16', git='https://github.com/crabtw/rust-bindgen')
|
version('0.16', tag='0.16', git='https://github.com/crabtw/rust-bindgen')
|
||||||
|
|
||||||
extends("rust")
|
extends("rust")
|
||||||
|
depends_on("llvm")
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
cargo('install', '--root', prefix)
|
env = dict(os.environ)
|
||||||
|
env['LIBCLANG_PATH'] = os.path.join(spec['llvm'].prefix, 'lib')
|
||||||
|
cargo('install', '--root', prefix, env=env)
|
||||||
|
|
|
@ -21,6 +21,7 @@ class Rust(Package):
|
||||||
extendable = True
|
extendable = True
|
||||||
|
|
||||||
# Rust
|
# Rust
|
||||||
|
depends_on("llvm")
|
||||||
depends_on("curl")
|
depends_on("curl")
|
||||||
depends_on("git")
|
depends_on("git")
|
||||||
depends_on("cmake")
|
depends_on("cmake")
|
||||||
|
@ -30,8 +31,8 @@ class Rust(Package):
|
||||||
depends_on("openssl")
|
depends_on("openssl")
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
get_submodules()
|
configure('--prefix=%s' % prefix,
|
||||||
configure('--prefix=%s' % prefix)
|
'--llvm-root=' + spec['llvm'].prefix)
|
||||||
|
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
|
Loading…
Reference in a new issue