diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index f997110b4c96b220cb78db60f12783d1e74ada46..8a063377a7fb98968dafe06e59fbc7f72f6cd26b 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -162,6 +162,18 @@ def clean_environment(): if 'PKGCONF' in varname: env.unset(varname) + # Unset the following variables because they can affect installation of + # Autotools and CMake packages. + build_system_vars = [ + 'CC', 'CFLAGS', 'CPP', 'CPPFLAGS', # C variables + 'CXX', 'CCC', 'CXXFLAGS', 'CXXCPP', # C++ variables + 'F77', 'FFLAGS', 'FLIBS', # Fortran77 variables + 'FC', 'FCFLAGS', 'FCLIBS', # Fortran variables + 'LDFLAGS', 'LIBS' # linker variables + ] + for v in build_system_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 diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index 8069f5143190fbf768812eeae0cc750190617309..3d69efa5ca558d5772c30119bd7ddd18222d827d 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -376,7 +376,7 @@ def unset(self, name, **kwargs): """Stores a request to unset an environment variable. Args: - name: name of the environment variable to be set + name: name of the environment variable to be unset """ kwargs.update(self._get_outside_caller_attributes()) item = UnsetEnv(name, **kwargs)