Skip to content

Commit

Permalink
hook to set LD_PRELOAD
Browse files Browse the repository at this point in the history
  • Loading branch information
truib committed Jun 7, 2024
1 parent 4814e24 commit aac02c4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ def pre_single_extension_testthat(ext, *args, **kwargs):
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "


def pre_sanitycheck_hook(self, *args, **kwargs):
"""Main pre-sanity-check hook: trigger custom functions based on software name."""
if self.name in PRE_SANITYCHECK_HOOKS:
PRE_SANITYCHECK_HOOKS[self.name](self, *args, **kwargs)


def post_sanitycheck_hook(self, *args, **kwargs):
"""Main post-sanity-check hook: trigger custom functions based on software name."""
if self.name in POST_SANITYCHECK_HOOKS:
Expand Down Expand Up @@ -718,6 +724,22 @@ def replace_non_distributable_files_with_symlinks(log, install_dir, package, all
symlink(host_inj_path, full_path)


def pre_sanitycheck_sentence_piece_ld_preload_aarch64(self, *args, **kwargs):
"""
Use LD_PRELOAD before sanity check to work around
error 'cannot allocate memory in static TLS block'
"""
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')

if self.name == 'SentencePiece' and self.version in ['0.2.0'] and cpu_target == CPU_TARGET_AARCH64_GENERIC:
ebrootgperftools = os.environ('EBROOTGPERFTOOLS')
lib_tcmalloc_minimal = os.path.join(ebrootgperftools, 'lib64', 'libtcmalloc_minimal.so')
env.setvar('LD_PRELOAD', lib_tcmalloc_minimal)
print_msg("Set LD_PRELOAD env var to '%s'", os.environ('LD_PRELOAD'))
else:
raise EasyBuildError("SentencePiece-specific hook triggered for non-SentencePiece easyconfig?!")


def post_sanitycheck_cuda(self, *args, **kwargs):
"""
Remove files from CUDA installation that we are not allowed to ship,
Expand Down Expand Up @@ -959,6 +981,10 @@ def pre_module_hook_librosa_augment_modluafooter(self, *args, **kwargs):
'numpy': post_single_extension_numpy,
}

PRE_SANITYCHECK_HOOKS = {
'SentencePiece': pre_sanitycheck_sentence_piece_ld_preload_aarch64,
}

POST_SANITYCHECK_HOOKS = {
'CUDA': post_sanitycheck_cuda,
'cuDNN': post_sanitycheck_cudnn,
Expand Down

0 comments on commit aac02c4

Please sign in to comment.