intel compiler: fix link time error with LLVMgold.so (#28731)
				
					
				
			The Intel compiler will, at link time, call `ld -plugin LLVMgold.so`, which expects libraries like `libimfo.so` to be found either in the `LD_LIBRARY_PATH` or in `LLVMgold.so`s RPATH. As `LLVMgold.so` already uses RUNPATH, I used that to extend this to the necessary library locations. This PR should fix issues: https://github.com/spack/spack/issues/10308 https://github.com/spack/spack/issues/18606 https://github.com/spack/spack/issues/17100 https://github.com/spack/spack/issues/21237 https://github.com/spack/spack/issues/4261 Co-authored-by: Stephen Sachs <stesachs@amazon.com>
This commit is contained in:
		| @@ -24,6 +24,7 @@ | ||||
|     install, | ||||
| ) | ||||
| 
 | ||||
| import spack.error | ||||
| from spack.build_environment import dso_suffix | ||||
| from spack.package import InstallError, PackageBase, run_after | ||||
| from spack.util.environment import EnvironmentModifications | ||||
| @@ -1333,5 +1334,42 @@ def uninstall_ism(self): | ||||
|         debug_print(os.getcwd()) | ||||
|         return | ||||
| 
 | ||||
|     @property | ||||
|     def base_lib_dir(self): | ||||
|         """Provide the library directory located in the base of Intel installation. | ||||
|         """ | ||||
|         d = self.normalize_path('') | ||||
|         d = os.path.join(d, 'lib') | ||||
| 
 | ||||
|         debug_print(d) | ||||
|         return d | ||||
| 
 | ||||
|     @run_after('install') | ||||
|     def modify_LLVMgold_rpath(self): | ||||
|         """Add libimf.so and other required libraries to the RUNPATH of LLVMgold.so. | ||||
| 
 | ||||
|         These are needed explicitly at dependent link time when | ||||
|         `ld -plugin LLVMgold.so` is called by the compiler. | ||||
|         """ | ||||
|         if self._has_compilers: | ||||
|             LLVMgold_libs = find_libraries('LLVMgold', self.base_lib_dir, | ||||
|                                            shared=True, recursive=True) | ||||
|             # Ignore ia32 entries as they mostly ignore throughout the rest | ||||
|             # of the file. | ||||
|             # The first entry in rpath preserves the original, the seconds entry | ||||
|             # is the location of libimf.so. If this relative location is changed | ||||
|             # in compiler releases, then we need to search for libimf.so instead | ||||
|             # of this static path. | ||||
|             for lib in LLVMgold_libs: | ||||
|                 if not self.spec.satisfies('^patchelf'): | ||||
|                     raise spack.error.SpackError( | ||||
|                         'Attempting to patch RPATH in LLVMgold.so.' | ||||
|                         + '`patchelf` dependency should be set in package.py' | ||||
|                     ) | ||||
|                 patchelf = Executable('patchelf') | ||||
|                 rpath = ':'.join([patchelf('--print-rpath', lib, output=str).strip(), | ||||
|                                   '$ORIGIN/../compiler/lib/intel64_lin']) | ||||
|                 patchelf('--set-rpath', rpath, lib) | ||||
| 
 | ||||
|     # Check that self.prefix is there after installation | ||||
|     run_after('install')(PackageBase.sanity_check_prefix) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stephen Sachs
					Stephen Sachs