From 96b54ec59c8419187e84b4c57b1630fdacfb5431 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 24 Oct 2024 18:45:22 +0200 Subject: [PATCH] Fix for duplicate glibc in concretization --- lib/spack/spack/solver/asp.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index e0fdd992b55..eff5258269c 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -280,12 +280,11 @@ def _create_counter(specs: List[spack.spec.Spec], tests: bool): def all_libcs() -> Set[spack.spec.Spec]: """Return a set of all libc specs targeted by any configured compiler. If none, fall back to libc determined from the current Python process if dynamically linked.""" - - libcs = { - CompilerPropertyDetector(c).default_libc() - for c in spack.compilers.config.all_compilers_from(spack.config.CONFIG) - } - libcs.discard(None) + libcs = set() + for c in spack.compilers.config.all_compilers_from(spack.config.CONFIG): + candidate = CompilerPropertyDetector(c).default_libc() + if candidate is not None: + libcs.add(candidate) if libcs: return libcs @@ -598,9 +597,11 @@ def _external_config_with_implicit_externals(configuration): if not using_libc_compatibility(): return packages_yaml + seen = set() for compiler in spack.compilers.config.all_compilers_from(configuration): libc = CompilerPropertyDetector(compiler).default_libc() - if libc: + if libc and libc not in seen: + seen.add(libc) entry = {"spec": f"{libc}", "prefix": libc.external_path} packages_yaml.setdefault(libc.name, {}).setdefault("externals", []).append(entry) return packages_yaml @@ -1804,8 +1805,6 @@ def emit_facts_from_requirement_rules(self, rules: List[RequirementRule]): def external_packages(self): """Facts on external packages, from packages.yaml and implicit externals.""" - packages_yaml = _external_config_with_implicit_externals(spack.config.CONFIG) - self.gen.h1("External packages") spec_filters = [] concretizer_yaml = spack.config.get("concretizer") @@ -1813,7 +1812,6 @@ def external_packages(self): if isinstance(reuse_yaml, typing.Mapping): default_include = reuse_yaml.get("include", []) default_exclude = reuse_yaml.get("exclude", []) - libc_externals = list(all_libcs()) for source in reuse_yaml.get("from", []): if source["type"] != "external": continue @@ -1821,7 +1819,7 @@ def external_packages(self): include = source.get("include", default_include) if include: # Since libcs are implicit externals, we need to implicitly include them - include = include + libc_externals + include = include + self.libcs exclude = source.get("exclude", default_exclude) spec_filters.append( SpecFilter( @@ -1832,6 +1830,7 @@ def external_packages(self): ) ) + packages_yaml = _external_config_with_implicit_externals(spack.config.CONFIG) for pkg_name, data in packages_yaml.items(): if pkg_name == "all": continue @@ -2997,7 +2996,10 @@ def possible_compilers(*, configuration) -> List["spack.spec.Spec"]: continue result.add(c) - return sorted(result) + + result = list(result) + result.sort() + return result class RuntimePropertyRecorder: