From e7c86259bd513a6623d1e9ba71e63f52c7f23e61 Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Thu, 23 May 2024 17:13:36 -0700 Subject: [PATCH] bugfix: external detection for compilers with os but not target (#44156) avoid calling `spec.target` when None. When an external compiler package has an `os` set but no `target` set, Spack currently falls into a codepath that calls `spec.target` (which itself calls `spec.architecture.target.Microarchitecture`) when `spec.architecture.target` is None, throwing an error. e.g. ``` packages: gcc: externals: - spec: gcc@12.3.1 os=rhel7 prefix: /usr ``` --------- Co-authored-by: Todd Gamblin --- lib/spack/spack/compilers/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 8ce9d81120..88e5e7b998 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -220,10 +220,10 @@ def _compiler_config_from_external(config): operating_system = host_platform.operating_system("default_os") target = host_platform.target("default_target").microarchitecture else: - target = spec.target + target = spec.architecture.target if not target: - host_platform = spack.platforms.host() - target = host_platform.target("default_target").microarchitecture + target = spack.platforms.host().target("default_target") + target = target.microarchitecture operating_system = spec.os if not operating_system: