Filter valid compilers

This excludes, e.g. llvm~clang etc. if found
This commit is contained in:
Massimiliano Culpo 2024-06-10 09:05:42 +02:00
parent e59c64ca20
commit a51fc1a4a3
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -291,11 +291,20 @@ def find_compilers(
if sys.platform == "win32": if sys.platform == "win32":
default_paths.extend(windows_os.WindowsOs().compiler_search_paths) default_paths.extend(windows_os.WindowsOs().compiler_search_paths)
compiler_pkgs = spack.repo.PATH.packages_with_tags(COMPILER_TAG, full=True) compiler_pkgs = spack.repo.PATH.packages_with_tags(COMPILER_TAG, full=True)
detected_packages = spack.detection.by_path( detected_packages = spack.detection.by_path(
compiler_pkgs, path_hints=default_paths, max_workers=max_workers compiler_pkgs, path_hints=default_paths, max_workers=max_workers
) )
valid_compilers = {}
for name, detected in detected_packages.items():
compilers = [x for x in detected if CompilerConfigFactory.from_external_spec(x.spec)]
if not compilers:
continue
valid_compilers[name] = compilers
new_compilers = spack.detection.update_configuration( new_compilers = spack.detection.update_configuration(
detected_packages, buildable=True, scope=scope valid_compilers, buildable=True, scope=scope
) )
return [ return [
_compiler_from_config_entry(c["compiler"]) _compiler_from_config_entry(c["compiler"])
@ -730,7 +739,7 @@ def from_specs(specs: List["spack.spec.Spec"]) -> List[dict]:
if s.name not in compiler_package_names: if s.name not in compiler_package_names:
continue continue
candidate = CompilerConfigFactory._from_external_spec(s) candidate = CompilerConfigFactory.from_external_spec(s)
if candidate is None: if candidate is None:
continue continue
@ -776,7 +785,7 @@ def _spec_from_external_config(config):
return result return result
@staticmethod @staticmethod
def _from_external_spec(spec: "spack.spec.Spec") -> Optional[dict]: def from_external_spec(spec: "spack.spec.Spec") -> Optional[dict]:
spec = spack.spec.parse_with_version_concrete(spec) spec = spack.spec.parse_with_version_concrete(spec)
extra_attributes = getattr(spec, _EXTRA_ATTRIBUTES_KEY, None) extra_attributes = getattr(spec, _EXTRA_ATTRIBUTES_KEY, None)
if extra_attributes is None: if extra_attributes is None: