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
16 changes: 13 additions & 3 deletions easybuild/easyblocks/l/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def __init__(self, *args, **kwargs):
self.final_runtimes += ['compiler-rt', 'libunwind', 'libcxx', 'libcxxabi']

if self.cfg['build_openmp']:
self.final_projects.append('openmp')
self.final_runtimes.append('openmp')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Crivella This isn't only for newer LLVM versions as the PR title suggests, but for all LLVM versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically all we support. I had wrote newer originally also because i was not sure this would work with 18.x but it ended up working there as well

Copy link
Collaborator

@Thyre Thyre Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to limit that, yeah (at least if we allow building libomp.so without building a full LLVM).
LLVM supports openmp for LLVM_ENABLE_RUNTIMES since LLVM 12.0.0-rc1. Prior versions only accept this as a project.

Choosing between LLVM_ENABLE_RUNTIMES and LLVM_ENABLE_PROJECTS matters the most for builds involving OpenMP offload. If we only focus on the OpenMP Tools Interface, which this PR aims to fix, only LLVM 17+ has support for the offload part. Any version before that could still use LLVM_ENABLE_PROJECTS.

So basically... all versions we build a full LLVM with can work with openmp being a runtime argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to limit that, yeah (at least if we allow building libomp.so without building a full LLVM).
LLVM supports openmp for LLVM_ENABLE_RUNTIMES since LLVM 12.0.0-rc1. Prior versions only accept this as a project.

Anything before 18.1.6 will build with minimal only, which includes only base llvm without any of the projects.
So i think this will be safe on that aspect

else:
errors = []
# check for all options that depend on OpenMP being enabled
Expand Down Expand Up @@ -540,7 +540,7 @@ def _configure_final_build(self):
self._cmakeopts['LIBOMP_USE_HWLOC'] = 'ON'
self._cmakeopts['LIBOMP_HWLOC_INSTALL_DIR'] = hwloc_root

if 'openmp' in self.final_projects:
if 'openmp' in self.final_runtimes:
if self.cfg['build_openmp_offload']:
# Force dlopen of the GPU libraries at runtime, not using existing libraries
if LooseVersion(self.version) >= '19':
Expand Down Expand Up @@ -1124,6 +1124,16 @@ def _para_test_step(self, parallel=1):
gcc_lib = self._get_gcc_libpath(strict=True)
lib_path = ':'.join(filter(None, [gcc_lib, lib_path]))

# After switching `openmp` to a runtime build, libomp.so is not produced inside `<builddir>/lib` anymore but
# in `<builddir>/runtimes/runtimes-bins/openmp/runtime/src/libomp.so`
# This causes the `libomptarget` tests to fail because the compiler cannot find `libomp.so`.
check_libomp = os.path.join(basedir, 'runtimes', 'runtimes-bins', 'openmp', 'runtime', 'src', 'libomp.so')
needed_libomp = os.path.join(basedir, 'lib', 'libomp.so')
if os.path.exists(check_libomp) and not os.path.exists(needed_libomp):
# Create a symlink to the libomp.so in the runtimes directory
mkdir(os.path.dirname(needed_libomp), parents=True)
symlink(check_libomp, needed_libomp)

with _wrap_env(os.path.join(basedir, 'bin'), lib_path):
cmd = f"make -j {parallel} check-all"
res = run_shell_cmd(cmd, fail_on_error=False)
Expand Down Expand Up @@ -1456,7 +1466,7 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, *args, **kw
check_bin_files += ['llvm-bolt', 'llvm-boltdiff', 'llvm-bolt-heatmap']
check_lib_files += ['libbolt_rt_instr.a']
custom_commands += ['llvm-bolt --help']
if 'openmp' in self.final_projects:
if 'openmp' in self.final_runtimes:
omp_lib_files = ['libomp.so', 'libompd.so']
if self.cfg['build_openmp_offload']:
omp_lib_files += ['libomptarget.so']
Expand Down