Convert LLVM to CMakePackage, update cmake dependency version (#3940)

* Convert LLVM to CMakePackage, update cmake dependency version

* Remove unused import
This commit is contained in:
Adam J. Stewart 2017-04-21 18:38:07 -05:00 committed by GitHub
parent a90e34f4ca
commit 2a04fdca52

View file

@ -22,12 +22,10 @@
# License along with this program; if not, write to the Free Software # License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os
from spack import * from spack import *
class Llvm(Package): class Llvm(CMakePackage):
"""The LLVM Project is a collection of modular and reusable compiler and """The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do toolchain technologies. Despite its name, LLVM has little to do
with traditional virtual machines, though it does provide helpful with traditional virtual machines, though it does provide helpful
@ -37,6 +35,7 @@ class Llvm(Package):
homepage = 'http://llvm.org/' homepage = 'http://llvm.org/'
url = 'http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz' url = 'http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz'
list_url = 'http://releases.llvm.org/download.html'
family = 'compiler' # Used by lmod family = 'compiler' # Used by lmod
@ -73,7 +72,7 @@ class Llvm(Package):
"<current arch>,NVPTX,AMDGPU,CppBackend") "<current arch>,NVPTX,AMDGPU,CppBackend")
# Build dependency # Build dependency
depends_on('cmake@2.8.12.2:', type='build') depends_on('cmake@3.4.3:', type='build')
# Universal dependency # Universal dependency
depends_on('python@2.7:2.8') # Seems not to support python 3.X.Y depends_on('python@2.7:2.8') # Seems not to support python 3.X.Y
@ -322,21 +321,30 @@ class Llvm(Package):
resources[name].get('variant', "")), resources[name].get('variant', "")),
placement=resources[name].get('placement', None)) placement=resources[name].get('placement', None))
def install(self, spec, prefix): conflicts('+clang_extra', when='~clang')
env['CXXFLAGS'] = self.compiler.cxx11_flag conflicts('+lldb', when='~clang')
cmake_args = [arg for arg in std_cmake_args if 'BUILD_TYPE' not in arg]
build_type = 'RelWithDebInfo' if '+debug' in spec else 'Release' def setup_environment(self, spack_env, run_env):
cmake_args.extend([ spack_env.set('CXXFLAGS', self.compiler.cxx11_flag)
'..',
'-DCMAKE_BUILD_TYPE=' + build_type, def build_type(self):
if '+debug' in self.spec:
return 'RelWithDebInfo'
else:
return 'Release'
def cmake_args(self):
spec = self.spec
cmake_args = [
'-DLLVM_REQUIRES_RTTI:BOOL=ON', '-DLLVM_REQUIRES_RTTI:BOOL=ON',
'-DCLANG_DEFAULT_OPENMP_RUNTIME:STRING=libomp', '-DCLANG_DEFAULT_OPENMP_RUNTIME:STRING=libomp',
'-DPYTHON_EXECUTABLE:PATH=%s/bin/python' % spec['python'].prefix]) '-DPYTHON_EXECUTABLE:PATH=%s/bin/python' % spec['python'].prefix
]
if '+gold' in spec: if '+gold' in spec:
cmake_args.append('-DLLVM_BINUTILS_INCDIR=' + cmake_args.append('-DLLVM_BINUTILS_INCDIR=' +
os.path.join(spec['binutils'].prefix, 'include')) spec['binutils'].prefix.include)
if '+polly' in spec: if '+polly' in spec:
cmake_args.append('-DLINK_POLLY_INTO_TOOLS:Bool=ON') cmake_args.append('-DLINK_POLLY_INTO_TOOLS:Bool=ON')
else: else:
@ -381,19 +389,12 @@ def install(self, spec, prefix):
cmake_args.append( cmake_args.append(
'-DLLVM_TARGETS_TO_BUILD:Bool=' + ';'.join(targets)) '-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.')
if '+lldb' in spec:
raise SpackException(
'The lldb variant requires the `+clang` variant')
if spec.satisfies('@4.0.0:') and spec.satisfies('platform=linux'): if spec.satisfies('@4.0.0:') and spec.satisfies('platform=linux'):
cmake_args.append('-DCMAKE_BUILD_WITH_INSTALL_RPATH=1') cmake_args.append('-DCMAKE_BUILD_WITH_INSTALL_RPATH=1')
with working_dir('spack-build', create=True): return cmake_args
cmake(*cmake_args)
make() @run_after('install')
make("install") def post_install(self):
install_tree("bin", join_path(prefix, "libexec", "llvm")) with working_dir(self.build_directory):
install_tree('bin', join_path(self.prefix, 'libexec', 'llvm'))