Skip to content

Fix bug where patches specified by dependents were not applied#8272

Merged
scheibelp merged 5 commits intospack:developfrom
scheibelp:bugfix/missing-dependency-patches
Jun 7, 2018
Merged

Fix bug where patches specified by dependents were not applied#8272
scheibelp merged 5 commits intospack:developfrom
scheibelp:bugfix/missing-dependency-patches

Conversation

@scheibelp
Copy link
Copy Markdown
Member

@scheibelp scheibelp commented May 25, 2018

Fixes #7885

#7193 added the patches_to_apply function to collect patches which are then applied in Package.do_patch. However this only collects patches that are associated with the Package object and does not include Spec-related patches (which are applied by dependents, added in #5476). This updates the Package.patches_to_apply function to add Spec patches.

EDIT: turns out Spec.patches already collects patches from the package so the Package.patches_to_apply function isn't necessary. All uses of Package.patches_to_apply are replaced with Package.spec.patches.

@scheibelp
Copy link
Copy Markdown
Member Author

Note: this was not detected because unit tests access dependency patches in the spec (which works) but do not check the collection of patches in do_patch (which does not work).

@scheibelp
Copy link
Copy Markdown
Member Author

As a consequence of swapping to using Spec.patches, Package.do_patch now uses the same code path to retrieve patches as the patch tests. Arguably adding a test to check that patches have been applied would still be useful.

@adamjstewart
Copy link
Copy Markdown
Member

Was just hit by this in #8207/#8263. GDAL requires a hacked version of JasPer, but the patch wasn't being applied.

@aprokop
Copy link
Copy Markdown
Contributor

aprokop commented May 25, 2018

This works (checked with flang).

@junghans
Copy link
Copy Markdown
Contributor

@scheibelp: why didn't the test catch that problem?

@adamjstewart
Copy link
Copy Markdown
Member

turns out Spec.patches already collects patches from the package so the Package.patches_to_apply function isn't necessary. All uses of Package.patches_to_apply are replaced with Package.spec.patches.

The only thing to be careful of is that patches_to_apply returns the patches in the correct order. You'll want to make sure that spec.patches does the same. See #7558 for details. This function was introduced in #7193 but I don't know the internals well enough to understand why it was necessary.

@junghans
Copy link
Copy Markdown
Contributor

@scheibelp can we merge this some when soon?

@scheibelp
Copy link
Copy Markdown
Member Author

The only thing to be careful of is that patches_to_apply returns the patches in the correct order. You'll want to make sure that spec.patches does the same. See #7558 for details. This function was introduced in #7193 but I don't know the internals well enough to understand why it was necessary.

This doesn't actually change anything about the consistency of patch ordering: You are right that #7193 did enforce an order, but that part was reverted in #7558. Patch order is still arbitrary and it remains as unfinished business to enforce the patch declaration order as the consistent ordering - see: #7193 (review)

@adamjstewart
Copy link
Copy Markdown
Member

I wouldn't say the order is arbitrary, my understanding is that the order is that of the patches in the package.py, which seems intuitive. I just want to make sure this behavior is preserved.

@scheibelp
Copy link
Copy Markdown
Member Author

my understanding is that the order is that of the patches in the package.py

I think that is agreed upon as what we want to guarantee, but we do not guarantee it right now: Patch ordering has not changed since #7193 (comment) which mentions:

Before this PR we were granted that patch3 would be applied after patch1, but we had no guarantee on the order of application for patch2 with respect to the other two. After this PR we are granted that we apply patches sorted by their path or urls. I think both strategies are wrong and we should apply patches in the order they are declared, if they match the constraint.

That being said, Spec.patches is constructed with Package class patches using the same logic as Package.patches_to_apply. This may seem like duplication of effort, which it is: #7193 was started before merging #5476. In the future, when enforcing the agreed-upon patch order, it will be a matter of modifying the logic which creates Spec.patches.

@aprokop
Copy link
Copy Markdown
Contributor

aprokop commented Jun 6, 2018

Can this be merged? Or are there remaining issues to be addressed?

@scheibelp scheibelp merged commit c97d058 into spack:develop Jun 7, 2018
@aprokop
Copy link
Copy Markdown
Contributor

aprokop commented Jun 7, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants