Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 51 additions & 4 deletions easybuild/easyblocks/l/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
from easybuild.easyblocks.generic.cmakemake import CMakeMake, get_cmake_python_config_dict

BUILD_TARGET_AMDGPU = 'AMDGPU'
RUNTIME_TARGET_AMDGPU = 'amdgcn-amd-amdhsa'
BUILD_TARGET_NVPTX = 'NVPTX'
RUNTIME_TARGET_NVPTX = 'nvptx64-nvidia-cuda'

LLVM_TARGETS = [
'AArch64', BUILD_TARGET_AMDGPU, 'ARM', 'AVR', 'BPF', 'Hexagon', 'Lanai', 'LoongArch', 'Mips', 'MSP430',
Expand Down Expand Up @@ -584,7 +586,7 @@ def remove_unsupported_flang_opts(self):
options are removed from F90FLAGS and FFLAGS."""
unsupported_flang_opts = set()
if self.version >= '21':
if self.version < '22':
if self.version < '23':
unsupported_flang_opts.update([
'-fmath-errno', '-fno-math-errno',
'-fno-unsafe-math-optimizations',
Expand All @@ -594,6 +596,39 @@ def remove_unsupported_flang_opts(self):
self._remove_iterable_from_envvar('F90FLAGS', unsupported_flang_opts)
self._remove_iterable_from_envvar('FFLAGS', unsupported_flang_opts)

def _configure_target_runtimes(self):
"""
Configure target runtime options for LLVM, required for LLVM 22+.
Comment thread
Crivella marked this conversation as resolved.
Related to changes in https://github.com/llvm/llvm-project/pull/136729 where te build of openmp device runtimes
has been moved to `openmp/device` from `offload`
Should only be called from _configure_final_build.
"""
if LooseVersion(self.version) < '22':
return

# First, select which targets will be built.
# We'll add this as a CMake argument, together with the default args, last.
target_archs = []
if self.amdgpu_target_cond:
target_archs.append(RUNTIME_TARGET_AMDGPU)
if self.nvptx_target_cond:
target_archs.append(RUNTIME_TARGET_NVPTX)

# Then, enable runtime targets per accelerator arch
# Supported options are 'compiler-rt', 'libc', 'openmp', 'libcxx', 'libcxxabi'
# In LLVM 22, only OpenMP is fully supported, therefore skip remainder
per_target_runtimes = {'openmp'}
per_target_runtimes &= set(self.final_runtimes)

for target_arch in target_archs:
self._cmakeopts[f'RUNTIMES_{target_arch}_LLVM_ENABLE_RUNTIMES'] = \
self.list_to_cmake_arg(per_target_runtimes)
self._cmakeopts[f'RUNTIMES_{target_arch}_CMAKE_CXX_FLAGS'] = ""
Comment thread
Thyre marked this conversation as resolved.

# Always add default last, since its runtimes are defined through LLVM_ENABLE_RUNTIMES
target_archs.append('default')
self._cmakeopts['LLVM_RUNTIME_TARGETS'] = self.list_to_cmake_arg(target_archs)

def _configure_final_build(self):
"""Configure the final stage of the build."""
self._cmakeopts['LLVM_ENABLE_PROJECTS'] = self.list_to_cmake_arg(self.final_projects)
Expand Down Expand Up @@ -644,6 +679,8 @@ def _configure_final_build(self):
self._cmakeopts[cmake_flag] = include_benchmarks
self.runtimes_cmake_args[cmake_flag] = include_benchmarks

self._configure_target_runtimes()

# Make sure tests are not running with more than 'parallel' tasks
parallel = self.cfg.parallel
if not build_option('mpi_tests'):
Expand Down Expand Up @@ -1692,7 +1729,7 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, *args, **kw
if version < '19':
check_bin_files += ['bbc', 'flang-new', 'flang-to-external-fc', 'f18-parse-demo', 'fir-opt', 'tco']
else:
check_bin_files += ['bbc', 'flang-new', 'f18-parse-demo', 'fir-opt', 'tco']
check_bin_files += ['bbc', 'f18-parse-demo', 'fir-opt', 'tco']
check_lib_files += [
'libFortranSemantics.a', 'libFortranLower.a', 'libFortranParser.a',
'libFIRCodeGen.a', 'libflangFrontend.a', 'libFortranDecimal.a',
Expand All @@ -1703,8 +1740,18 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, *args, **kw
'libFortranRuntime.a', 'libFortranCommon.a'
]
check_dirs += ['lib/cmake/flang', 'include/flang']
custom_commands += ['bbc --help', 'mlir-tblgen --help', 'flang-new --help']
gcc_prefix_compilers += ['flang-new']
custom_commands += ['bbc --help', 'mlir-tblgen --help']

# Starting with LLVM 22, some implementations, e.g. AMD ROCm,
# omit flang-new. Therefore, adapt the check to look for flang instead.
if version < '22':
check_bin_files += ['flang-new']
custom_commands += ['flang-new --help']
gcc_prefix_compilers += ['flang-new']
else:
check_bin_files += ['flang']
custom_commands += ['flang --help']
gcc_prefix_compilers += ['flang']

if 'lld' in self.final_projects:
check_bin_files += ['ld.lld', 'lld', 'lld-link', 'wasm-ld']
Expand Down