Force reference consistency between Spec & Package
The correct place to set the mutual references between spec and package objects is at the end of concretization. After a call to concretize we should now be ensured that spec is the same object as spec.package.spec. Code in `build_environment.py` that was performing the same operation has been turned into an assertion to be defensive on the new behavior.
This commit is contained in:
parent
5c24370512
commit
90d50a0cee
@ -465,12 +465,8 @@ def setup_package(pkg, dirty):
|
|||||||
# code ensures that all packages in the DAG have pieces of the
|
# code ensures that all packages in the DAG have pieces of the
|
||||||
# same spec object at build time.
|
# same spec object at build time.
|
||||||
#
|
#
|
||||||
# This is safe for the build process, b/c the build process is a
|
|
||||||
# throwaway environment, but it is kind of dirty.
|
|
||||||
#
|
|
||||||
# TODO: Think about how to avoid this fix and do something cleaner.
|
|
||||||
for s in pkg.spec.traverse():
|
for s in pkg.spec.traverse():
|
||||||
s.package.spec = s
|
assert s.package.spec is s
|
||||||
|
|
||||||
# Trap spack-tracked compiler flags as appropriate.
|
# Trap spack-tracked compiler flags as appropriate.
|
||||||
# Must be before set_compiler_environment_variables
|
# Must be before set_compiler_environment_variables
|
||||||
|
@ -1791,6 +1791,15 @@ def concretize(self):
|
|||||||
Concretizing ensures that it is self-consistent and that it's
|
Concretizing ensures that it is self-consistent and that it's
|
||||||
consistent with requirements of its pacakges. See flatten() and
|
consistent with requirements of its pacakges. See flatten() and
|
||||||
normalize() for more details on this.
|
normalize() for more details on this.
|
||||||
|
|
||||||
|
It also ensures that:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
for x in self.traverse():
|
||||||
|
assert x.package.spec == x
|
||||||
|
|
||||||
|
which may not be true *during* the concretization step.
|
||||||
"""
|
"""
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise SpecError("Attempting to concretize anonymous spec")
|
raise SpecError("Attempting to concretize anonymous spec")
|
||||||
@ -1844,6 +1853,11 @@ def concretize(self):
|
|||||||
if matches:
|
if matches:
|
||||||
raise ConflictsInSpecError(self, matches)
|
raise ConflictsInSpecError(self, matches)
|
||||||
|
|
||||||
|
# At this point the spec-package mutual references should
|
||||||
|
# be self-consistent
|
||||||
|
for x in self.traverse():
|
||||||
|
x.package.spec = x
|
||||||
|
|
||||||
def _mark_concrete(self, value=True):
|
def _mark_concrete(self, value=True):
|
||||||
"""Mark this spec and its dependencies as concrete.
|
"""Mark this spec and its dependencies as concrete.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user