diff --git a/easybuild/easyblocks/c/cuda.py b/easybuild/easyblocks/c/cuda.py index d5d6489bd0..32629aab40 100644 --- a/easybuild/easyblocks/c/cuda.py +++ b/easybuild/easyblocks/c/cuda.py @@ -234,6 +234,17 @@ def create_wrapper(wrapper_name, wrapper_comp): raise EasyBuildError("Unable to find 'ldconfig' in $PATH (%s), nor in any of %s", path, sbin_dirs) stubs_dir = os.path.join(self.installdir, 'lib64', 'stubs') + + # Remove stubs which are not required as the full library is in $EBROOTCUDA/lib64 because this duplication + # causes issues (e.g. CMake warnings) when using this module (see $LIBRARY_PATH & $LD_LIBRARY_PATH) + for stub_lib in expand_glob_paths([os.path.join(stubs_dir, '*.*')]): + real_lib = os.path.join(self.installdir, 'lib64', os.path.basename(stub_lib)) + if os.path.exists(real_lib): + self.log.debug("Removing unnecessary stub library %s", stub_lib) + remove_file(stub_lib) + else: + self.log.debug("Keeping stub library %s", stub_lib) + # Run ldconfig to create missing symlinks in the stubs directory (libcuda.so.1, etc) cmd = ' '.join([ldconfig, '-N', stubs_dir]) run_cmd(cmd) @@ -243,7 +254,7 @@ def create_wrapper(wrapper_name, wrapper_comp): # See e.g. https://github.com/easybuilders/easybuild-easyconfigs/issues/12348 # Workaround: Create a copy that matches this pattern new_stubs_dir = os.path.join(self.installdir, 'stubs') - copy_dir(stubs_dir, os.path.join(new_stubs_dir, 'lib64')) + copy_dir(stubs_dir, os.path.join(new_stubs_dir, 'lib64'), symlinks=True) # Also create the lib dir as a symlink symlink('lib64', os.path.join(new_stubs_dir, 'lib'), use_abspath_source=False)