diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 95d14279dc5..d6461752573 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -3544,6 +3544,10 @@ def _dup(self, other, deps: Union[bool, dt.DepTypes, dt.DepFlag] = True, clearde if cleardeps: self._dependents = _EdgeMap(store_by_child=False) self._dependencies = _EdgeMap(store_by_child=True) + + 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()