diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 01e5bd958a4..7c85e6aa87f 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -3456,6 +3456,9 @@ def _dup(self, other: "Spec", deps: Union[bool, dt.DepTypes, dt.DepFlag] = True) self.name = other.name self.versions = other.versions.copy() self.architecture = other.architecture.copy() if other.architecture else None + if hasattr(other, "compiler_annotation"): + self.compiler_annotation = other.compiler_annotation + self.compiler_flags = other.compiler_flags.copy() self.compiler_flags.spec = self self.variants = other.variants.copy()