intel-mkl: load compiler modules when querying compiler (#29439)
This commit is contained in:
parent
2cd5c00923
commit
88fbba3e1e
@ -686,14 +686,14 @@ def openmp_libs(self):
|
|||||||
# packages.yaml), specificially to provide the 'iomp5' libs.
|
# packages.yaml), specificially to provide the 'iomp5' libs.
|
||||||
|
|
||||||
elif '%gcc' in self.spec:
|
elif '%gcc' in self.spec:
|
||||||
gcc = Executable(self.compiler.cc)
|
with self.compiler.compiler_environment():
|
||||||
omp_lib_path = gcc(
|
omp_lib_path = Executable(self.compiler.cc)(
|
||||||
'--print-file-name', 'libgomp.%s' % dso_suffix, output=str)
|
'--print-file-name', 'libgomp.%s' % dso_suffix, output=str)
|
||||||
omp_libs = LibraryList(omp_lib_path.strip())
|
omp_libs = LibraryList(omp_lib_path.strip())
|
||||||
|
|
||||||
elif '%clang' in self.spec:
|
elif '%clang' in self.spec:
|
||||||
clang = Executable(self.compiler.cc)
|
with self.compiler.compiler_environment():
|
||||||
omp_lib_path = clang(
|
omp_lib_path = Executable(self.compiler.cc)(
|
||||||
'--print-file-name', 'libomp.%s' % dso_suffix, output=str)
|
'--print-file-name', 'libomp.%s' % dso_suffix, output=str)
|
||||||
omp_libs = LibraryList(omp_lib_path.strip())
|
omp_libs = LibraryList(omp_lib_path.strip())
|
||||||
|
|
||||||
@ -735,6 +735,7 @@ def tbb_libs(self):
|
|||||||
|
|
||||||
# TODO: clang(?)
|
# TODO: clang(?)
|
||||||
gcc = self._gcc_executable # must be gcc, not self.compiler.cc
|
gcc = self._gcc_executable # must be gcc, not self.compiler.cc
|
||||||
|
with self.compiler.compiler_environment():
|
||||||
cxx_lib_path = gcc(
|
cxx_lib_path = gcc(
|
||||||
'--print-file-name', 'libstdc++.%s' % dso_suffix, output=str)
|
'--print-file-name', 'libstdc++.%s' % dso_suffix, output=str)
|
||||||
|
|
||||||
@ -746,6 +747,7 @@ def tbb_libs(self):
|
|||||||
def _tbb_abi(self):
|
def _tbb_abi(self):
|
||||||
'''Select the ABI needed for linking TBB'''
|
'''Select the ABI needed for linking TBB'''
|
||||||
gcc = self._gcc_executable
|
gcc = self._gcc_executable
|
||||||
|
with self.compiler.compiler_environment():
|
||||||
matches = re.search(r'(gcc|LLVM).* ([0-9]+\.[0-9]+\.[0-9]+).*',
|
matches = re.search(r'(gcc|LLVM).* ([0-9]+\.[0-9]+\.[0-9]+).*',
|
||||||
gcc('--version', output=str), re.I | re.M)
|
gcc('--version', output=str), re.I | re.M)
|
||||||
abi = ''
|
abi = ''
|
||||||
|
@ -325,7 +325,7 @@ def accessible_exe(exe):
|
|||||||
|
|
||||||
# setup environment before verifying in case we have executable names
|
# setup environment before verifying in case we have executable names
|
||||||
# instead of absolute paths
|
# instead of absolute paths
|
||||||
with self._compiler_environment():
|
with self.compiler_environment():
|
||||||
missing = [cmp for cmp in (self.cc, self.cxx, self.f77, self.fc)
|
missing = [cmp for cmp in (self.cc, self.cxx, self.f77, self.fc)
|
||||||
if cmp and not accessible_exe(cmp)]
|
if cmp and not accessible_exe(cmp)]
|
||||||
if missing:
|
if missing:
|
||||||
@ -407,7 +407,7 @@ def _get_compiler_link_paths(self, paths):
|
|||||||
compiler_exe.add_default_arg(flag)
|
compiler_exe.add_default_arg(flag)
|
||||||
|
|
||||||
output = ''
|
output = ''
|
||||||
with self._compiler_environment():
|
with self.compiler_environment():
|
||||||
output = str(compiler_exe(
|
output = str(compiler_exe(
|
||||||
self.verbose_flag, fin, '-o', fout,
|
self.verbose_flag, fin, '-o', fout,
|
||||||
output=str, error=str)) # str for py2
|
output=str, error=str)) # str for py2
|
||||||
@ -523,7 +523,7 @@ def get_real_version(self):
|
|||||||
modifications) to enable the compiler to run properly on any platform.
|
modifications) to enable the compiler to run properly on any platform.
|
||||||
"""
|
"""
|
||||||
cc = spack.util.executable.Executable(self.cc)
|
cc = spack.util.executable.Executable(self.cc)
|
||||||
with self._compiler_environment():
|
with self.compiler_environment():
|
||||||
output = cc(self.version_argument,
|
output = cc(self.version_argument,
|
||||||
output=str, error=str,
|
output=str, error=str,
|
||||||
ignore_errors=tuple(self.ignore_version_errors))
|
ignore_errors=tuple(self.ignore_version_errors))
|
||||||
@ -597,7 +597,7 @@ def __str__(self):
|
|||||||
str(self.operating_system)))))
|
str(self.operating_system)))))
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _compiler_environment(self):
|
def compiler_environment(self):
|
||||||
# store environment to replace later
|
# store environment to replace later
|
||||||
backup_env = os.environ.copy()
|
backup_env = os.environ.copy()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user