From 88fbba3e1e843d6fd47d83cdc67cc7d63d98b23c Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 10 Mar 2022 23:14:17 +0100 Subject: intel-mkl: load compiler modules when querying compiler (#29439) --- lib/spack/spack/build_systems/intel.py | 22 ++++++++++++---------- lib/spack/spack/compiler.py | 8 ++++---- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py index 6e4a2a970e..ad60456fb2 100644 --- a/lib/spack/spack/build_systems/intel.py +++ b/lib/spack/spack/build_systems/intel.py @@ -686,15 +686,15 @@ class IntelPackage(PackageBase): # packages.yaml), specificially to provide the 'iomp5' libs. elif '%gcc' in self.spec: - gcc = Executable(self.compiler.cc) - omp_lib_path = gcc( - '--print-file-name', 'libgomp.%s' % dso_suffix, output=str) + with self.compiler.compiler_environment(): + omp_lib_path = Executable(self.compiler.cc)( + '--print-file-name', 'libgomp.%s' % dso_suffix, output=str) omp_libs = LibraryList(omp_lib_path.strip()) elif '%clang' in self.spec: - clang = Executable(self.compiler.cc) - omp_lib_path = clang( - '--print-file-name', 'libomp.%s' % dso_suffix, output=str) + with self.compiler.compiler_environment(): + omp_lib_path = Executable(self.compiler.cc)( + '--print-file-name', 'libomp.%s' % dso_suffix, output=str) omp_libs = LibraryList(omp_lib_path.strip()) if len(omp_libs) < 1: @@ -735,8 +735,9 @@ class IntelPackage(PackageBase): # TODO: clang(?) gcc = self._gcc_executable # must be gcc, not self.compiler.cc - cxx_lib_path = gcc( - '--print-file-name', 'libstdc++.%s' % dso_suffix, output=str) + with self.compiler.compiler_environment(): + cxx_lib_path = gcc( + '--print-file-name', 'libstdc++.%s' % dso_suffix, output=str) libs = tbb_lib + LibraryList(cxx_lib_path.rstrip()) debug_print(libs) @@ -746,8 +747,9 @@ class IntelPackage(PackageBase): def _tbb_abi(self): '''Select the ABI needed for linking TBB''' gcc = self._gcc_executable - matches = re.search(r'(gcc|LLVM).* ([0-9]+\.[0-9]+\.[0-9]+).*', - gcc('--version', output=str), re.I | re.M) + with self.compiler.compiler_environment(): + matches = re.search(r'(gcc|LLVM).* ([0-9]+\.[0-9]+\.[0-9]+).*', + gcc('--version', output=str), re.I | re.M) abi = '' if sys.platform == 'darwin': pass diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index bcbb32dd62..b8ebc622f2 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -325,7 +325,7 @@ class Compiler(object): # setup environment before verifying in case we have executable names # 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) if cmp and not accessible_exe(cmp)] if missing: @@ -407,7 +407,7 @@ class Compiler(object): compiler_exe.add_default_arg(flag) output = '' - with self._compiler_environment(): + with self.compiler_environment(): output = str(compiler_exe( self.verbose_flag, fin, '-o', fout, output=str, error=str)) # str for py2 @@ -523,7 +523,7 @@ class Compiler(object): modifications) to enable the compiler to run properly on any platform. """ cc = spack.util.executable.Executable(self.cc) - with self._compiler_environment(): + with self.compiler_environment(): output = cc(self.version_argument, output=str, error=str, ignore_errors=tuple(self.ignore_version_errors)) @@ -597,7 +597,7 @@ class Compiler(object): str(self.operating_system))))) @contextlib.contextmanager - def _compiler_environment(self): + def compiler_environment(self): # store environment to replace later backup_env = os.environ.copy() -- cgit v1.2.3-70-g09d2