From d92c21ec9709589e20abdd4eaadcda0697a594ed Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 19 Apr 2023 00:47:52 +0200 Subject: Fix compilation on Cray (target: any) (#37011) fixes #36628 Fix using compilers that declare "target: any" in their configuration. This should happen only on Cray with the module based programming environment. --- lib/spack/spack/solver/asp.py | 3 +++ lib/spack/spack/test/concretize.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 8e843d60eb..7c5d409ca0 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -968,6 +968,9 @@ class SpackSolverSetup(object): if compiler.operating_system: self.gen.fact(fn.compiler_os(compiler_id, compiler.operating_system)) + if compiler.target == "any": + compiler.target = None + if compiler.target is not None: self.gen.fact(fn.compiler_target(compiler_id, compiler.target)) diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index bf492b93d1..8671e5288f 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -2150,3 +2150,29 @@ class TestConcretize(object): spack.config.set("compilers", compiler_configuration) s = spack.spec.Spec("a %gcc@foo").concretized() assert s.compiler.version == ver("foo") + + @pytest.mark.regression("36628") + def test_concretization_with_compilers_supporting_target_any(self): + """Tests that a compiler with 'target: any' can satisfy any target, and is a viable + candidate for concretization. + """ + compiler_configuration = [ + { + "compiler": { + "spec": "gcc@12.1.0", + "paths": { + "cc": "/some/path/gcc", + "cxx": "/some/path/g++", + "f77": None, + "fc": None, + }, + "operating_system": "debian6", + "target": "any", + "modules": [], + } + } + ] + + with spack.config.override("compilers", compiler_configuration): + s = spack.spec.Spec("a").concretized() + assert s.satisfies("%gcc@12.1.0") -- cgit v1.2.3-60-g2f50