summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Koyama <koysean@gmail.com>2022-12-15 10:52:09 -0600
committerGitHub <noreply@github.com>2022-12-15 17:52:09 +0100
commit8a02463d7d14de275d5090fdf07a29af26d44e0e (patch)
tree910364eb1c12c09e5125441cd9599e9deab2b029
parentc6465bd9bd7a7b688f59d6a5f39adce943314fda (diff)
downloadspack-8a02463d7d14de275d5090fdf07a29af26d44e0e.tar.gz
spack-8a02463d7d14de275d5090fdf07a29af26d44e0e.tar.bz2
spack-8a02463d7d14de275d5090fdf07a29af26d44e0e.tar.xz
spack-8a02463d7d14de275d5090fdf07a29af26d44e0e.zip
IntelOneApiPackage: add envmods variant to toggle environment modifications by oneapi packages (#34253)
Co-authored-by: Sean Koyama <skoyama@anl.gov> Co-authored-by: Robert Cohn <robert.s.cohn@intel.com>
-rw-r--r--lib/spack/spack/build_systems/oneapi.py19
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py6
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py
index 9f009918fd..b7456a5775 100644
--- a/lib/spack/spack/build_systems/oneapi.py
+++ b/lib/spack/spack/build_systems/oneapi.py
@@ -10,7 +10,7 @@ from os.path import basename, dirname, isdir
from llnl.util.filesystem import find_headers, find_libraries, join_path
-from spack.directives import conflicts
+from spack.directives import conflicts, variant
from spack.util.environment import EnvironmentModifications
from spack.util.executable import Executable
@@ -36,6 +36,13 @@ class IntelOneApiPackage(Package):
]:
conflicts(c, msg="This package in only available for x86_64 and Linux")
+ # Add variant to toggle environment modifications from vars.sh
+ variant(
+ "envmods",
+ default=True,
+ description="Toggles environment modifications",
+ )
+
@staticmethod
def update_description(cls):
"""Updates oneapi package descriptions with common text."""
@@ -114,11 +121,13 @@ class IntelOneApiPackage(Package):
$ source {prefix}/{component}/{version}/env/vars.sh
"""
- env.extend(
- EnvironmentModifications.from_sourcing_file(
- join_path(self.component_prefix, "env", "vars.sh")
+ # Only if environment modifications are desired (default is +envmods)
+ if "+envmods" in self.spec:
+ env.extend(
+ EnvironmentModifications.from_sourcing_file(
+ join_path(self.component_prefix, "env", "vars.sh")
+ )
)
- )
class IntelOneApiLibraryPackage(IntelOneApiPackage):
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 41b8f12b12..62befb387d 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
@@ -131,8 +131,10 @@ class IntelOneapiMkl(IntelOneApiLibraryPackage):
env.append_path("__INTEL_POST_FFLAGS", flag, separator=" ")
def setup_dependent_build_environment(self, env, dependent_spec):
- env.set("MKLROOT", self.component_prefix)
- env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig)
+ # Only if environment modifications are desired (default is +envmods)
+ if "+envmods" in self.spec:
+ env.set("MKLROOT", self.component_prefix)
+ env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig)
def _find_mkl_libs(self, shared):
libs = []