diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 70da3ca2c42..72b2a340fd3 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -334,6 +334,40 @@ def __init__( # used for version checks for API, e.g. C++11 flag self._real_version = None + def __eq__(self, other): + return ( + self.cc == other.cc + and self.cxx == other.cxx + and self.fc == other.fc + and self.f77 == other.f77 + and self.spec == other.spec + and self.operating_system == other.operating_system + and self.target == other.target + and self.flags == other.flags + and self.modules == other.modules + and self.environment == other.environment + and self.extra_rpaths == other.extra_rpaths + and self.enable_implicit_rpaths == other.enable_implicit_rpaths + ) + + def __hash__(self): + return hash( + ( + self.cc, + self.cxx, + self.fc, + self.f77, + self.spec, + self.operating_system, + self.target, + str(self.flags), + str(self.modules), + str(self.environment), + str(self.extra_rpaths), + self.enable_implicit_rpaths, + ) + ) + def verify_executables(self): """Raise an error if any of the compiler executables is not valid. diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 67438aaf38d..c089164aade 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -208,7 +208,7 @@ def _compiler_config_from_external(config): "modules": config.get("modules", []), "environment": extra_attributes.get("environment", {}), "extra_rpaths": extra_attributes.get("extra_rpaths", []), - "implicit_rpaths": extra_attributes.get("implicit_rpaths", True), + "implicit_rpaths": extra_attributes.get("implicit_rpaths", None), } } return compiler_entry @@ -315,7 +315,9 @@ def all_compilers_config(scope=None, init_config=True): """ from_compilers_yaml = get_compiler_config(scope, init_config) from_packages_yaml = get_compiler_config_from_packages(scope) - return from_compilers_yaml + from_packages_yaml + result = from_compilers_yaml + from_packages_yaml + key = lambda c: _compiler_from_config_entry(c["compiler"]) + return list(llnl.util.lang.dedupe(result, key=key)) def all_compiler_specs(scope=None, init_config=True):