Allow using compilers from build caches
This commit is contained in:
parent
476f2a63e2
commit
7800c4c51b
@ -3186,7 +3186,15 @@ def define_runtime_constraints(self):
|
|||||||
if not using_libc_compatibility():
|
if not using_libc_compatibility():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
current_libc = None
|
||||||
|
if compiler.external or compiler.installed:
|
||||||
current_libc = CompilerPropertyDetector(compiler).default_libc()
|
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
|
# If this is a compiler yet to be built infer libc from the Python process
|
||||||
# FIXME (compiler as nodes): recover this use case
|
# FIXME (compiler as nodes): recover this use case
|
||||||
# if not current_libc and compiler.compiler_obj.cc is None:
|
# 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}",
|
description=f"Add libc when using {compiler}",
|
||||||
)
|
)
|
||||||
recorder("*").depends_on(
|
recorder("*").depends_on(
|
||||||
str(current_libc),
|
f"{current_libc.name}@={current_libc.version}",
|
||||||
when=f"%{compiler.name}@{compiler.versions}",
|
when=f"%{compiler.name}@{compiler.versions}",
|
||||||
type="link",
|
type="link",
|
||||||
description=f"Libc is {current_libc} when using {compiler}",
|
description=f"Libc is {current_libc} when using {compiler}",
|
||||||
@ -3439,9 +3447,18 @@ def possible_compilers(*, configuration) -> List["spack.spec.Spec"]:
|
|||||||
result.add(c)
|
result.add(c)
|
||||||
|
|
||||||
# Compilers from the local store
|
# 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))
|
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 = list(result)
|
||||||
result.sort()
|
result.sort()
|
||||||
return result
|
return result
|
||||||
@ -4219,6 +4236,9 @@ def _is_reusable(spec: spack.spec.Spec, packages, local: bool) -> bool:
|
|||||||
if "dev_path" in spec.variants:
|
if "dev_path" in spec.variants:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if spec.name == "compiler-wrapper":
|
||||||
|
return False
|
||||||
|
|
||||||
if not spec.external:
|
if not spec.external:
|
||||||
return _has_runtime_dependencies(spec)
|
return _has_runtime_dependencies(spec)
|
||||||
|
|
||||||
|
@ -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
|
% 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.
|
% 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"),
|
hash_attr(Hash, "depends_on", PackageName, DepName, "link"),
|
||||||
not hash_attr(Hash, "depends_on", PackageName, DepName, "run"),
|
not hash_attr(Hash, "depends_on", PackageName, DepName, "run"),
|
||||||
hash_attr(Hash, "hash", DepName, DepHash),
|
hash_attr(Hash, "hash", DepName, DepHash),
|
||||||
@ -1520,24 +1520,24 @@ avoid_compiler_link_dependency(Hash, DepName) :-
|
|||||||
imposed_constraint(ParentHash, "hash", ChildName, ChildHash) :-
|
imposed_constraint(ParentHash, "hash", ChildName, ChildHash) :-
|
||||||
hash_attr(ParentHash, "hash", ChildName, ChildHash),
|
hash_attr(ParentHash, "hash", ChildName, ChildHash),
|
||||||
ChildHash != ParentHash,
|
ChildHash != ParentHash,
|
||||||
not avoid_compiler_link_dependency(ParentHash, ChildName),
|
not avoid_link_dependency(ParentHash, ChildName),
|
||||||
not abi_splice_conditions_hold(_, _, ChildName, ChildHash).
|
not abi_splice_conditions_hold(_, _, ChildName, ChildHash).
|
||||||
|
|
||||||
imposed_constraint(Hash, "depends_on", PackageName, DepName, Type) :-
|
imposed_constraint(Hash, "depends_on", PackageName, DepName, Type) :-
|
||||||
hash_attr(Hash, "depends_on", PackageName, DepName, Type),
|
hash_attr(Hash, "depends_on", PackageName, DepName, Type),
|
||||||
hash_attr(Hash, "hash", DepName, DepHash),
|
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).
|
not attr("splice_at_hash", _, _, DepName, DepHash).
|
||||||
|
|
||||||
imposed_constraint(Hash, "virtual_on_edge", PackageName, DepName, VirtName) :-
|
imposed_constraint(Hash, "virtual_on_edge", PackageName, DepName, VirtName) :-
|
||||||
hash_attr(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,_).
|
not attr("splice_at_hash", _, _, DepName,_).
|
||||||
|
|
||||||
imposed_constraint(Hash, "virtual_node", VirtName) :-
|
imposed_constraint(Hash, "virtual_node", VirtName) :-
|
||||||
hash_attr(Hash, "virtual_on_edge", PackageName, DepName, VirtName),
|
hash_attr(Hash, "virtual_on_edge", PackageName, DepName, VirtName),
|
||||||
hash_attr(Hash, "virtual_node", 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,_).
|
not attr("splice_at_hash", _, _, DepName,_).
|
||||||
|
|
||||||
|
|
||||||
|
@ -3018,7 +3018,7 @@ def test_filtering_reused_specs(
|
|||||||
@pytest.mark.usefixtures("mutable_database", "mock_store")
|
@pytest.mark.usefixtures("mutable_database", "mock_store")
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"reuse_yaml,expected_length",
|
"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")
|
@pytest.mark.not_on_windows("Expected length is different on Windows")
|
||||||
def test_selecting_reused_sources(
|
def test_selecting_reused_sources(
|
||||||
@ -3031,6 +3031,9 @@ def test_selecting_reused_sources(
|
|||||||
specs = selector.reusable_specs(["mpileaks"])
|
specs = selector.reusable_specs(["mpileaks"])
|
||||||
assert len(specs) == expected_length
|
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(
|
@pytest.mark.parametrize(
|
||||||
"specs,include,exclude,expected",
|
"specs,include,exclude,expected",
|
||||||
|
Loading…
Reference in New Issue
Block a user