Skip to content

Commit

Permalink
Exclude specs without runtimes from reuse
Browse files Browse the repository at this point in the history
This should ensure that we do not reuse specs that
could be broken, as they expect the compiler to be
installed in a specific place.
  • Loading branch information
alalazo committed Mar 25, 2024
1 parent 3c58119 commit ed006df
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion lib/spack/spack/solver/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3359,7 +3359,7 @@ def _is_reusable(spec: spack.spec.Spec, packages, local: bool) -> bool:
return False

if not spec.external:
return True
return _has_runtime_dependencies(spec)

# Cray external manifest externals are always reusable
if local:
Expand All @@ -3384,6 +3384,19 @@ def _is_reusable(spec: spack.spec.Spec, packages, local: bool) -> bool:
return False


def _has_runtime_dependencies(spec: spack.spec.Spec) -> bool:
if not WITH_RUNTIME:
return True

if spec.satisfies("%gcc") and not spec.satisfies("^gcc-runtime"):
return False

if spec.satisfies("%oneapi") and not spec.satisfies("^intel-oneapi-runtime"):
return False

return True


class Solver:
"""This is the main external interface class for solving.
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/cmd/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_spec():


@pytest.mark.only_clingo("Known failure of the original concretizer")
def test_spec_concretizer_args(mutable_config, mutable_database):
def test_spec_concretizer_args(mutable_config, mutable_database, do_not_check_runtimes_on_reuse):
"""End-to-end test of CLI concretizer prefs.
It's here to make sure that everything works from CLI
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/concretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def change(self, changes=None):
# This must use the mutable_config fixture because the test
# adjusting_default_target_based_on_compiler uses the current_host fixture,
# which changes the config.
@pytest.mark.usefixtures("mutable_config", "mock_packages")
@pytest.mark.usefixtures("mutable_config", "mock_packages", "do_not_check_runtimes_on_reuse")
class TestConcretize:
def test_concretize(self, spec):
check_concretize(spec)
Expand Down
5 changes: 5 additions & 0 deletions lib/spack/spack/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,3 +1986,8 @@ def create_test_repo(tmpdir, pkg_name_content_tuples):
f.write(pkg_str)

return spack.repo.Repo(repo_path)


@pytest.fixture()
def do_not_check_runtimes_on_reuse(monkeypatch):
monkeypatch.setattr(spack.solver.asp, "_has_runtime_dependencies", lambda x: True)

0 comments on commit ed006df

Please sign in to comment.