Skip to content

Commit 42e19dd

Browse files
authored
Merge pull request #2065 from branfosj/20200524140124_new_pr_qgVufebUzT
new easyblock for LLVM
2 parents a07a41b + 515612f commit 42e19dd

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

easybuild/easyblocks/l/llvm.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
##
2+
# Copyright 2020 Ghent University
3+
#
4+
# This file is part of EasyBuild,
5+
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
6+
# with support of Ghent University (http://ugent.be/hpc),
7+
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
8+
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
9+
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
10+
#
11+
# https://github.com/easybuilders/easybuild
12+
#
13+
# EasyBuild is free software: you can redistribute it and/or modify
14+
# it under the terms of the GNU General Public License as published by
15+
# the Free Software Foundation v2.
16+
#
17+
# EasyBuild is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
24+
##
25+
"""
26+
EasyBuild support for building and installing LLVM, implemented as an easyblock
27+
28+
@author: Simon Branford (University of Birmingham)
29+
"""
30+
from easybuild.easyblocks.clang import CLANG_TARGETS, DEFAULT_TARGETS_MAP
31+
from easybuild.easyblocks.generic.cmakemake import CMakeMake
32+
from easybuild.framework.easyconfig import CUSTOM
33+
from easybuild.tools.build_log import EasyBuildError
34+
from easybuild.tools.modules import get_software_root
35+
from easybuild.tools.systemtools import get_cpu_architecture
36+
37+
38+
class EB_LLVM(CMakeMake):
39+
"""
40+
Support for building and installing LLVM
41+
"""
42+
43+
@staticmethod
44+
def extra_options():
45+
extra_vars = CMakeMake.extra_options()
46+
extra_vars.update({
47+
'build_targets': [None, "Build targets for LLVM (host architecture if None). Possible values: " +
48+
', '.join(CLANG_TARGETS), CUSTOM],
49+
'enable_rtti': [True, "Enable RTTI", CUSTOM],
50+
})
51+
return extra_vars
52+
53+
def configure_step(self):
54+
"""
55+
Install extra tools in bin/; enable zlib if it is a dep; optionally enable rtti; and set the build target
56+
"""
57+
self.cfg.update('configopts', '-DLLVM_INSTALL_UTILS=ON')
58+
59+
if get_software_root('zlib'):
60+
self.cfg.update('configopts', '-DLLVM_ENABLE_ZLIB=ON')
61+
62+
if self.cfg["enable_rtti"]:
63+
self.cfg.update('configopts', '-DLLVM_ENABLE_RTTI=ON')
64+
65+
build_targets = self.cfg['build_targets']
66+
if build_targets is None:
67+
arch = get_cpu_architecture()
68+
default_targets = DEFAULT_TARGETS_MAP.get(arch, None)
69+
if default_targets:
70+
self.cfg['build_targets'] = build_targets = default_targets
71+
self.log.debug("Using %s as default build targets for CPU architecture %s.", default_targets, arch)
72+
else:
73+
raise EasyBuildError("No default build targets defined for CPU architecture %s.", arch)
74+
75+
unknown_targets = [target for target in build_targets if target not in CLANG_TARGETS]
76+
77+
if unknown_targets:
78+
raise EasyBuildError("Some of the chosen build targets (%s) are not in %s.",
79+
', '.join(unknown_targets), ', '.join(CLANG_TARGETS))
80+
81+
self.cfg.update('configopts', '-DLLVM_TARGETS_TO_BUILD="%s"' % ';'.join(build_targets))
82+
83+
super(EB_LLVM, self).configure_step()

0 commit comments

Comments
 (0)