From 2077b3a006fbeceb83042bb11d9e94396cc11229 Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Thu, 11 Apr 2024 11:39:27 -0700 Subject: invalid compiler: warn instead of error (#43491) --- lib/spack/spack/compilers/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index ed3244da2e..678c1773ab 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -10,6 +10,7 @@ import collections import itertools import multiprocessing.pool import os +import warnings from typing import Dict, List, Optional, Tuple import archspec.cpu @@ -341,7 +342,9 @@ def all_compilers_config( from_compilers_yaml = get_compiler_config(configuration, scope=scope, init_config=init_config) result = from_compilers_yaml + from_packages_yaml - key = lambda c: _compiler_from_config_entry(c["compiler"]) + # Dedupe entries by the compiler they represent + # If the entry is invalid, treat it as unique for deduplication + key = lambda c: _compiler_from_config_entry(c["compiler"] or id(c)) return list(llnl.util.lang.dedupe(result, key=key)) @@ -520,7 +523,9 @@ def all_compilers_from(configuration, scope=None, init_config=True): configuration=configuration, scope=scope, init_config=init_config ): items = items["compiler"] - compilers.append(_compiler_from_config_entry(items)) + compiler = _compiler_from_config_entry(items) # can be None in error case + if compiler: + compilers.append(compiler) return compilers @@ -627,7 +632,10 @@ def _compiler_from_config_entry(items): compiler = _compiler_cache.get(config_id, None) if compiler is None: - compiler = compiler_from_dict(items) + try: + compiler = compiler_from_dict(items) + except UnknownCompilerError as e: + warnings.warn(e.message) _compiler_cache[config_id] = compiler return compiler @@ -680,7 +688,9 @@ def get_compilers(config, cspec=None, arch_spec=None): raise ValueError(msg) continue - compilers.append(_compiler_from_config_entry(items)) + compiler = _compiler_from_config_entry(items) + if compiler: + compilers.append(compiler) return compilers -- cgit v1.2.3-70-g09d2