From aac02c4cf0d24213c42d22665eba52037ca39a4c Mon Sep 17 00:00:00 2001 From: Thomas Roeblitz Date: Fri, 7 Jun 2024 09:10:32 +0200 Subject: [PATCH] hook to set LD_PRELOAD --- eb_hooks.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/eb_hooks.py b/eb_hooks.py index 58523f160b..5b7bad5b76 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -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: @@ -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, @@ -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,