diff --git a/easybuild/easyblocks/l/llvm.py b/easybuild/easyblocks/l/llvm.py index 4a024cdcd51..3c7f863e007 100644 --- a/easybuild/easyblocks/l/llvm.py +++ b/easybuild/easyblocks/l/llvm.py @@ -237,6 +237,9 @@ def __init__(self, *args, **kwargs): """Initialize LLVM-specific variables.""" super().__init__(*args, **kwargs) + # List of (lower-case) dependencies + self.deps = [dep['name'].lower() for dep in self.cfg.dependencies(runtime_only=True)] + if self.cfg['usepolly'] is not None: self.log.deprecated("Use of easyconfig parameter 'usepolly', replace by 'use_polly'", '6.0') if self.cfg['use_polly'] is None: @@ -434,9 +437,6 @@ def _configure_build_targets(self): print_warning("Both 'amd_gfx_list' and build option 'amdgcn_capabilities' " "are set, please use only the build option 'amdgcn_capabilities'") - # List of (lower-case) dependencies - self.deps = [dep['name'].lower() for dep in self.cfg.dependencies()] - # Build targets build_targets = self.cfg['build_targets'] or [] if not build_targets: @@ -522,6 +522,10 @@ def _configure_build_targets(self): self.general_opts['CMAKE_BUILD_TYPE'] = self.build_type self.general_opts['LLVM_TARGETS_TO_BUILD'] = self.list_to_cmake_arg(build_targets) + def get_dependency_root(self, name: str): + """Get software root of dependency. Return None if it is not a dependecy.""" + return get_software_root(name) if name.lower() in self.deps else None + def prepare_step(self, *args, **kwargs): """Prepare step, modified to ensure install dir is deleted before building""" super().prepare_step(*args, **kwargs) @@ -555,7 +559,7 @@ def _configure_final_build(self): self._cmakeopts['LLVM_ENABLE_PROJECTS'] = self.list_to_cmake_arg(self.final_projects) self._cmakeopts['LLVM_ENABLE_RUNTIMES'] = self.list_to_cmake_arg(self.final_runtimes) - hwloc_root = get_software_root('hwloc') + hwloc_root = self.get_dependency_root('hwloc') if hwloc_root: self.log.info("Using %s as hwloc root", hwloc_root) self._cmakeopts['LIBOMP_USE_HWLOC'] = 'ON' @@ -870,7 +874,7 @@ def configure_step(self): # Dependencies based persistent options (should be reused across stages) # Libxml2 - xml2_root = get_software_root('libxml2') + xml2_root = self.get_dependency_root('libxml2') # Explicitly disable libxml2 if not found to avoid linking against system libxml2 if xml2_root: if self.full_llvm: @@ -881,7 +885,7 @@ def configure_step(self): else: self.general_opts['LLVM_ENABLE_LIBXML2'] = 'OFF' - libffi_root = get_software_root('libffi') + libffi_root = self.get_dependency_root('libffi') self.general_opts['LLVM_ENABLE_FFI'] = 'ON' if libffi_root else 'OFF' if libffi_root: self.general_opts['FFI_INCLUDE_DIR'] = os.path.join(libffi_root, 'include') @@ -889,16 +893,16 @@ def configure_step(self): # If 'ON', risk finding a system zlib or zstd leading to including /usr/include as -isystem that can lead # to errors during compilation of 'offload.tools.kernelreplay' due to the inclusion of LLVMSupport (19.x) - self.general_opts['LLVM_ENABLE_ZLIB'] = 'ON' if get_software_root('zlib') else 'OFF' - self.general_opts['LLVM_ENABLE_ZSTD'] = 'ON' if get_software_root('zstd') else 'OFF' + self.general_opts['LLVM_ENABLE_ZLIB'] = 'ON' if 'zlib' in self.deps else 'OFF' + self.general_opts['LLVM_ENABLE_ZSTD'] = 'ON' if 'zstd' in self.deps else 'OFF' # Should not use system SWIG if present - self.general_opts['LLDB_ENABLE_SWIG'] = 'ON' if get_software_root('SWIG') else 'OFF' + self.general_opts['LLDB_ENABLE_SWIG'] = 'ON' if 'swig' in self.deps else 'OFF' # Avoid using system `gdb` in case it is not provided as a dependency # This could cause the wrong sysroot/dynamic linker being picked up in a sysroot build causing tests to fail - self.general_opts['LIBOMP_OMPD_GDB_SUPPORT'] = 'ON' if get_software_root('GDB') else 'OFF' + self.general_opts['LIBOMP_OMPD_GDB_SUPPORT'] = 'ON' if 'gdb' in self.deps else 'OFF' - z3_root = get_software_root("Z3") + z3_root = self.get_dependency_root("Z3") if z3_root: self.log.info("Using %s as Z3 root", z3_root) self.general_opts['LLVM_ENABLE_Z3_SOLVER'] = 'ON' @@ -947,7 +951,7 @@ def configure_step(self): # If we don't want to build with CUDA (not in dependencies) trick CMakes FindCUDA module into not finding it by # using the environment variable which is used as-is and later checked for a falsy value when determining # whether CUDA was found - if not get_software_root('CUDA'): + if 'cuda' not in self.deps: setvar('CUDA_NVCC_EXECUTABLE', 'IGNORE') # 20.1+ uses a generic IR for OpenMP DeviceRTL @@ -1000,6 +1004,8 @@ def disable_sanitizer_tests(self): cmakelists_tests = os.path.join(self.start_dir, 'compiler-rt', 'test', 'CMakeLists.txt') regex_subs = [(r'compiler_rt_test_runtime.*san.*', '')] apply_regex_substitutions(cmakelists_tests, regex_subs) + if LooseVersion(self.version) >= '20.1.0': + self.general_opts['OPENMP_TEST_ENABLE_TSAN'] = 'OFF' def add_cmake_opts(self): """Add LLVM-specific CMake options."""