diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index c28c1c3087d..14e9e17a50d 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -3186,7 +3186,15 @@ def define_runtime_constraints(self): if not using_libc_compatibility(): continue - current_libc = CompilerPropertyDetector(compiler).default_libc() + current_libc = None + if compiler.external or compiler.installed: + current_libc = CompilerPropertyDetector(compiler).default_libc() + else: + try: + current_libc = compiler["libc"] + except (KeyError, RuntimeError) as e: + tty.debug(f"{compiler} cannot determine libc because: {e}") + # If this is a compiler yet to be built infer libc from the Python process # FIXME (compiler as nodes): recover this use case # if not current_libc and compiler.compiler_obj.cc is None: @@ -3200,7 +3208,7 @@ def define_runtime_constraints(self): description=f"Add libc when using {compiler}", ) recorder("*").depends_on( - str(current_libc), + f"{current_libc.name}@={current_libc.version}", when=f"%{compiler.name}@{compiler.versions}", type="link", description=f"Libc is {current_libc} when using {compiler}", @@ -3439,9 +3447,18 @@ def possible_compilers(*, configuration) -> List["spack.spec.Spec"]: result.add(c) # Compilers from the local store - for pkg_name in spack.compilers.config.supported_compilers(): + supported_compilers = spack.compilers.config.supported_compilers() + for pkg_name in supported_compilers: result.update(spack.store.STORE.db.query(pkg_name)) + # Compilers from build cache + from_buildcache = [ + x + for x in spack.binary_distribution.update_cache_and_get_specs() + if x.name in supported_compilers and not x.external + ] + result.update(from_buildcache) + result = list(result) result.sort() return result @@ -4219,6 +4236,9 @@ def _is_reusable(spec: spack.spec.Spec, packages, local: bool) -> bool: if "dev_path" in spec.variants: return False + if spec.name == "compiler-wrapper": + return False + if not spec.external: return _has_runtime_dependencies(spec) diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 0bd9f09fb15..ab10ecbc905 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -1509,7 +1509,7 @@ imposed_constraint(Hash, "hash", PackageName, Hash) :- installed_hash(PackageNam % If a compiler is not used as a library, we just enforce "run" dependency, so we % can get by with a much smaller search space. -avoid_compiler_link_dependency(Hash, DepName) :- +avoid_link_dependency(Hash, DepName) :- hash_attr(Hash, "depends_on", PackageName, DepName, "link"), not hash_attr(Hash, "depends_on", PackageName, DepName, "run"), hash_attr(Hash, "hash", DepName, DepHash), @@ -1520,24 +1520,24 @@ avoid_compiler_link_dependency(Hash, DepName) :- imposed_constraint(ParentHash, "hash", ChildName, ChildHash) :- hash_attr(ParentHash, "hash", ChildName, ChildHash), ChildHash != ParentHash, - not avoid_compiler_link_dependency(ParentHash, ChildName), + not avoid_link_dependency(ParentHash, ChildName), not abi_splice_conditions_hold(_, _, ChildName, ChildHash). imposed_constraint(Hash, "depends_on", PackageName, DepName, Type) :- hash_attr(Hash, "depends_on", PackageName, DepName, Type), hash_attr(Hash, "hash", DepName, DepHash), - not avoid_compiler_link_dependency(Hash, DepName), + not avoid_link_dependency(Hash, DepName), not attr("splice_at_hash", _, _, DepName, DepHash). imposed_constraint(Hash, "virtual_on_edge", PackageName, DepName, VirtName) :- hash_attr(Hash, "virtual_on_edge", PackageName, DepName, VirtName), - not avoid_compiler_link_dependency(Hash, DepName), + not avoid_link_dependency(Hash, DepName), not attr("splice_at_hash", _, _, DepName,_). imposed_constraint(Hash, "virtual_node", VirtName) :- hash_attr(Hash, "virtual_on_edge", PackageName, DepName, VirtName), hash_attr(Hash, "virtual_node", VirtName), - not avoid_compiler_link_dependency(Hash, DepName), + not avoid_link_dependency(Hash, DepName), not attr("splice_at_hash", _, _, DepName,_). diff --git a/lib/spack/spack/test/concretization/core.py b/lib/spack/spack/test/concretization/core.py index df3ef609036..232ad9c3e90 100644 --- a/lib/spack/spack/test/concretization/core.py +++ b/lib/spack/spack/test/concretization/core.py @@ -3018,7 +3018,7 @@ def test_filtering_reused_specs( @pytest.mark.usefixtures("mutable_database", "mock_store") @pytest.mark.parametrize( "reuse_yaml,expected_length", - [({"from": [{"type": "local"}]}, 20), ({"from": [{"type": "buildcache"}]}, 0)], + [({"from": [{"type": "local"}]}, 19), ({"from": [{"type": "buildcache"}]}, 0)], ) @pytest.mark.not_on_windows("Expected length is different on Windows") def test_selecting_reused_sources( @@ -3031,6 +3031,9 @@ def test_selecting_reused_sources( specs = selector.reusable_specs(["mpileaks"]) assert len(specs) == expected_length + # Compiler wrapper is not reused, as it might have changed from previous installations + assert not [x for x in specs if x.name == "compiler-wrapper"] + @pytest.mark.parametrize( "specs,include,exclude,expected",