Skip to content

Commit 39b68fa

Browse files
authored
Merge pull request #3770 from Flamefire/llvm-startdir
Use `self.start_dir` in LLVM easyblock
2 parents bd2091d + ec63e7d commit 39b68fa

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

easybuild/easyblocks/l/llvm.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ def __init__(self, *args, **kwargs):
234234
"""Initialize LLVM-specific variables."""
235235
super().__init__(*args, **kwargs)
236236

237-
self.llvm_src_dir = None
238237
self.llvm_obj_dir_stage1 = None
239238
self.llvm_obj_dir_stage2 = None
240239
self.llvm_obj_dir_stage3 = None
@@ -463,6 +462,12 @@ def __init__(self, *args, **kwargs):
463462
self._cmakeopts = {}
464463
self._cfgopts = list(filter(None, self.cfg.get('configopts', '').split()))
465464

465+
@property
466+
def llvm_src_dir(self):
467+
"""Return root source directory of LLVM (containing all components)"""
468+
# LLVM is the first source so we already have this in start_dir. Might be changed later
469+
return self.start_dir
470+
466471
def prepare_step(self, *args, **kwargs):
467472
"""Prepare step, modified to ensure install dir is deleted before building"""
468473
super(EB_LLVM, self).prepare_step(*args, **kwargs)
@@ -677,13 +682,6 @@ def configure_step(self):
677682
# ensure this easyblock can be used as a Bundle component, see
678683
# https://github.com/easybuilders/easybuild-easyblocks/issues/3680
679684
general_opts['CMAKE_INSTALL_PREFIX'] = self.installdir
680-
start_dir = self.cfg['start_dir']
681-
if start_dir:
682-
self.llvm_src_dir = os.path.join(self.builddir, start_dir)
683-
self.log.debug("Using `%s` as the source dir from start_dir", self.llvm_src_dir)
684-
else:
685-
self.llvm_src_dir = os.path.join(self.builddir, 'llvm-project-%s.src' % self.version)
686-
self.log.debug("Using `%s` as the source dir from easyblock", self.llvm_src_dir)
687685

688686
# Bootstrap
689687
self.llvm_obj_dir_stage1 = os.path.join(self.builddir, 'llvm.obj.1')
@@ -749,14 +747,14 @@ def configure_step(self):
749747
self.disable_sanitizer_tests()
750748

751749
# Remove python bindings tests causing uncaught exception in the build
752-
cmakelists_tests = os.path.join(self.llvm_src_dir, 'clang', 'CMakeLists.txt')
750+
cmakelists_tests = os.path.join(self.start_dir, 'clang', 'CMakeLists.txt')
753751
regex_subs = []
754752
regex_subs.append((r'add_subdirectory\(bindings/python/tests\)', ''))
755753
apply_regex_substitutions(cmakelists_tests, regex_subs)
756754

757755
# Remove flags disabling the use of configuration files during compiler-rt tests as we in general rely on them
758756
# (see https://github.com/easybuilders/easybuild-easyblocks/pull/3741#issuecomment-2939404304)
759-
lit_cfg_file = os.path.join(self.llvm_src_dir, 'compiler-rt', 'test', 'lit.common.cfg.py')
757+
lit_cfg_file = os.path.join(self.start_dir, 'compiler-rt', 'test', 'lit.common.cfg.py')
760758
regex_subs = [
761759
(r'^if config.has_no_default_config_flag:', ''),
762760
(r'^\s*config.environment\["CLANG_NO_DEFAULT_CONFIG"\] = "1"', '')
@@ -781,7 +779,7 @@ def configure_step(self):
781779
self._configure_general_build()
782780
self.add_cmake_opts()
783781

784-
src_dir = os.path.join(self.llvm_src_dir, 'llvm')
782+
src_dir = os.path.join(self.start_dir, 'llvm')
785783
output = super().configure_step(builddir=self.llvm_obj_dir_stage1, srcdir=src_dir)
786784

787785
# Get LLVM_HOST_TRIPLE (e.g. x86_64-unknown-linux-gnu) from the output
@@ -813,7 +811,7 @@ def configure_step(self):
813811

814812
def disable_sanitizer_tests(self):
815813
"""Disable the tests of all the sanitizers by removing the test directories from the build system"""
816-
cmakelists_tests = os.path.join(self.llvm_src_dir, 'compiler-rt', 'test', 'CMakeLists.txt')
814+
cmakelists_tests = os.path.join(self.start_dir, 'compiler-rt', 'test', 'CMakeLists.txt')
817815
regex_subs = [(r'compiler_rt_test_runtime.*san.*', '')]
818816
apply_regex_substitutions(cmakelists_tests, regex_subs)
819817

@@ -941,7 +939,6 @@ def build_with_prev_stage(self, prev_dir, stage_dir):
941939

942940
# Also runs of the intermediate step compilers should be made aware of the GCC installation
943941
if LooseVersion(self.version) >= LooseVersion('19'):
944-
self._set_gcc_prefix()
945942
self._create_compiler_config_file(prev_dir)
946943
# also pre-create the CFG files in the `build_stage/bin` directory to enforce using the correct dynamic
947944
# linker in case of sysroot builds, and to ensure the correct GCC installation is used also for the
@@ -952,7 +949,7 @@ def build_with_prev_stage(self, prev_dir, stage_dir):
952949

953950
change_dir(stage_dir)
954951
self.log.debug("Configuring %s", stage_dir)
955-
cmd = ' '.join(['cmake', self.cfg['configopts'], os.path.join(self.llvm_src_dir, 'llvm')])
952+
cmd = ' '.join(['cmake', self.cfg['configopts'], os.path.join(self.start_dir, 'llvm')])
956953
run_shell_cmd(cmd)
957954

958955
self.log.debug("Building %s", stage_dir)
@@ -1135,7 +1132,6 @@ def test_step(self):
11351132
if not self.cfg['skip_all_tests']:
11361133
# Also runs of test suite compilers should be made aware of the GCC installation
11371134
if LooseVersion(self.version) >= LooseVersion('19'):
1138-
self._set_gcc_prefix()
11391135
self._create_compiler_config_file(self.final_dir)
11401136

11411137
# For nvptx64 tests, find out if 'ptxas' exists in $PATH. If not, ignore all nvptx64 test failures
@@ -1184,17 +1180,16 @@ def install_step(self):
11841180

11851181
# copy Python bindings here in post-install step so that it is not done more than once in multi_deps context
11861182
if self.cfg['python_bindings']:
1187-
python_bindings_source_dir = os.path.join(self.llvm_src_dir, 'clang', 'bindings', 'python')
1183+
python_bindings_source_dir = os.path.join(self.start_dir, 'clang', 'bindings', 'python')
11881184
python_bindins_target_dir = os.path.join(self.installdir, 'lib', 'python')
11891185
copy_dir(python_bindings_source_dir, python_bindins_target_dir, dirs_exist_ok=True)
11901186

1191-
python_bindings_source_dir = os.path.join(self.llvm_src_dir, 'mlir', 'python')
1187+
python_bindings_source_dir = os.path.join(self.start_dir, 'mlir', 'python')
11921188
copy_dir(python_bindings_source_dir, python_bindins_target_dir, dirs_exist_ok=True)
11931189

11941190
if LooseVersion(self.version) >= LooseVersion('19'):
11951191
# For GCC aware installation create config files in order to point to the correct GCC installation
11961192
# Required as GCC_INSTALL_PREFIX was removed (see https://github.com/llvm/llvm-project/pull/87360)
1197-
self._set_gcc_prefix()
11981193
self._create_compiler_config_file(self.installdir)
11991194

12001195
# This is needed as some older build system will select a different naming scheme for the library leading to

0 commit comments

Comments
 (0)