Skip to content

Commit

Permalink
Fix a bug preventing to set platform= on externals (#43758)
Browse files Browse the repository at this point in the history
closes #43406
  • Loading branch information
alalazo committed Apr 22, 2024
1 parent 7c1a309 commit a450dd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/spack/spack/solver/asp.py
Expand Up @@ -1610,6 +1610,7 @@ def external_imposition(input_spec, requirements):
self.gen.newline()

self.trigger_rules()
self.effect_rules()

def preferred_variants(self, pkg_name):
"""Facts on concretization preferences, as read from packages.yaml"""
Expand Down
13 changes: 6 additions & 7 deletions lib/spack/spack/solver/concretize.lp
Expand Up @@ -993,14 +993,13 @@ pkg_fact(Package, variant_single_value("dev_path"))
% Platform semantics
%-----------------------------------------------------------------------------

% if no platform is set, fall back to the default
error(100, "platform '{0}' is not allowed on the current host", Platform)
:- attr("node_platform", _, Platform), not allowed_platform(Platform).
% NOTE: Currently we have a single allowed platform per DAG, therefore there is no
% need to have additional optimization criteria. If we ever add cross-platform dags,
% this needs to be changed.
:- 2 { allowed_platform(Platform) }, internal_error("More than one allowed platform detected").

attr("node_platform", PackageNode, Platform)
:- attr("node", PackageNode),
not attr("node_platform_set", PackageNode),
node_platform_default(Platform).
1 { attr("node_platform", PackageNode, Platform) : allowed_platform(Platform) } 1
:- attr("node", PackageNode).

% setting platform on a node is a hard constraint
attr("node_platform", PackageNode, Platform)
Expand Down
13 changes: 13 additions & 0 deletions lib/spack/spack/test/concretize.py
Expand Up @@ -2398,6 +2398,19 @@ def test_reuse_specs_from_non_available_compilers(self, mutable_config, mutable_
for s in root.traverse(root=False):
assert s.satisfies("%gcc@10.2.1")

@pytest.mark.regression("43406")
def test_externals_with_platform_explicitly_set(self, tmp_path):
"""Tests that users can specify platform=xxx in an external spec"""
external_conf = {
"mpich": {
"buildable": False,
"externals": [{"spec": "mpich@=2.0.0 platform=test", "prefix": str(tmp_path)}],
}
}
spack.config.set("packages", external_conf)
s = Spec("mpich").concretized()
assert s.external


@pytest.fixture()
def duplicates_test_repository():
Expand Down

0 comments on commit a450dd3

Please sign in to comment.