summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py')
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py63
1 files changed, 38 insertions, 25 deletions
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
index 2f47cf3fb7..bbd0e2b350 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
@@ -74,41 +74,54 @@ class IntelOneapiMkl(IntelOneApiLibraryPackage):
def component_dir(self):
return 'mkl'
- def xlp64_lib(self, lib):
- return lib + ('_ilp64'
- if '+ilp64' in self.spec
- else '_lp64')
-
@property
def headers(self):
- include_path = join_path(self.component_path, 'include')
- return find_headers('*', include_path)
-
- # provide cluster libraries if +cluster variant is used or
- # the scalapack virtual package was requested
- def cluster(self):
- return '+cluster' in self.spec
+ return find_headers('*', self.component_prefix.include)
@property
def libs(self):
shared = '+shared' in self.spec
- mkl_libs = []
- if self.cluster():
- mkl_libs += [self.xlp64_lib('libmkl_scalapack'),
- 'libmkl_cdft_core']
- mkl_libs += [self.xlp64_lib('libmkl_intel'),
- 'libmkl_sequential',
- 'libmkl_core']
- if self.cluster():
- mkl_libs += [self.xlp64_lib('libmkl_blacs_intelmpi')]
- libs = find_libraries(mkl_libs,
- join_path(self.component_path, 'lib', 'intel64'),
- shared=shared)
+
+ libs = self._find_mkl_libs(shared)
+
system_libs = find_system_libraries(['libpthread', 'libm', 'libdl'])
if shared:
return libs + system_libs
else:
return IntelOneApiStaticLibraryList(libs, system_libs)
+ def setup_run_environment(self, env):
+ super(IntelOneapiMkl, self).setup_run_environment(env)
+
+ # Support RPATH injection to the library directories when the '-mkl' or '-qmkl'
+ # flag of the Intel compilers are used outside the Spack build environment. We
+ # should not try to take care of other compilers because the users have to
+ # provide the linker flags anyway and are expected to take care of the RPATHs
+ # flags too. We prefer the __INTEL_POST_CFLAGS/__INTEL_POST_FFLAGS flags over
+ # the PRE ones so that any other RPATHs provided by the users on the command
+ # line come before and take precedence over the ones we inject here.
+ for d in self._find_mkl_libs('+shared' in self.spec).directories:
+ flag = '-Wl,-rpath,{0}'.format(d)
+ env.append_path('__INTEL_POST_CFLAGS', flag, separator=' ')
+ env.append_path('__INTEL_POST_FFLAGS', flag, separator=' ')
+
def setup_dependent_build_environment(self, env, dependent_spec):
- env.set('MKLROOT', self.component_path)
+ env.set('MKLROOT', self.component_prefix)
+
+ def _find_mkl_libs(self, shared):
+ libs = []
+
+ if '+cluster' in self.spec:
+ libs.extend([self._xlp64_lib('libmkl_scalapack'), 'libmkl_cdft_core'])
+
+ libs.extend([self._xlp64_lib('libmkl_intel'),
+ 'libmkl_sequential', 'libmkl_core'])
+
+ if '+cluster' in self.spec:
+ libs.append(self._xlp64_lib('libmkl_blacs_intelmpi'))
+
+ return find_libraries(
+ libs, self.component_prefix.lib.intel64, shared=shared)
+
+ def _xlp64_lib(self, lib):
+ return lib + ('_ilp64' if '+ilp64' in self.spec else '_lp64')