Skip to content
Open
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
36 changes: 33 additions & 3 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def get_eessi_envvar(eessi_envvar):
return eessi_envvar_value


def get_rpath_override_dirs(software_name):
def get_rpath_override_dirs(software_name, toolchain_version):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure this is what you want, the toolchain version is not specific enough since you also need to cover CUDA versions.

Copy link
Copy Markdown
Collaborator Author

@TopRichard TopRichard May 13, 2026

Choose a reason for hiding this comment

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

True, while this does not directly address #220, it does make it possible to use a different CUDA version for each toolchain version.

# determine path to installations in software layer via $EESSI_SOFTWARE_PATH
eessi_software_path = get_eessi_envvar('EESSI_SOFTWARE_PATH')

Expand All @@ -251,6 +251,36 @@ def get_rpath_override_dirs(software_name):

# Allow for libraries in lib or lib64
rpath_injection_dirs = [os.path.join(rpath_injection_stub, x) for x in ('lib', 'lib64')]

# Add toolchain specific RPATH that precedes the host_injections RPATH
# by adding toolchain version before the second software occurence.

# Split the path into segments based on the word "software"
search_string = "software"
replace_string = toolchain_version + "/software"
eessi_software_path_parts = eessi_software_path.split(search_string)

# Ensure that the second occurrence of "software" is replaced.
toolchain_rpath_injection_prefix = eessi_software_path_parts[0] + search_string + eessi_software_path_parts[1]
toolchain_rpath_injection_suffix = os.path.normpath(search_string.join(eessi_software_path_parts[2:]))
# Add the subdirectory for the specific software
toolchain_rpath_injection_stub = os.path.join(
# Make sure we are looking inside the `host_injections` directory
toolchain_rpath_injection_prefix.replace('versions', 'host_injections', 1),
replace_string + toolchain_rpath_injection_suffix,
# Add the subdirectory for the specific software
'rpath_overrides',
software_name,
# We can't know the version, but this allows the use of a symlink
# to facilitate version upgrades without removing files
'system',
)

# Allow for libraries in lib or lib64
toolchain_rpath_injection_dirs = [os.path.join(toolchain_rpath_injection_stub, x) for x in ('lib', 'lib64')]

# Prepend toolchain version based RPATHs before host_injections RPATHs
rpath_injection_dirs = toolchain_rpath_injection_dirs + rpath_injection_dirs

return rpath_injection_dirs

Expand Down Expand Up @@ -421,11 +451,11 @@ def pre_prepare_hook(self, *args, **kwargs):

# Check if we have an MPI family in the toolchain (returns None if there is not)
mpi_family = self.toolchain.mpi_family()

tcversion = self.toolchain.version
# Inject an RPATH override for MPI (if needed)
if mpi_family:
# Get list of override directories
mpi_rpath_override_dirs = get_rpath_override_dirs(mpi_family)
mpi_rpath_override_dirs = get_rpath_override_dirs(mpi_family, tcversion)

# update the relevant option (but keep the original value so we can reset it later)
if hasattr(self, EESSI_RPATH_OVERRIDE_ATTR):
Expand Down
Loading