diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 1b8aae31dc..7ef2126766 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -174,6 +174,14 @@ def clean_environment(): for v in build_system_vars: env.unset(v) + # Unset mpi environment vars. These flags should only be set by + # mpi providers for packages with mpi dependencies + mpi_vars = [ + 'MPICC', 'MPICXX', 'MPIFC', 'MPIF77', 'MPIF90' + ] + for v in mpi_vars: + env.unset(v) + build_lang = spack.config.get('config:build_language') if build_lang: # Override language-related variables. This can be used to force