Workaround apple silicon codesigning cache bug #2543
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a hack to work around a codesigning problem on Apple Silicon where overwriting a binary that has already been executed doesn't cause the corresponding codesign entry in the OS cache to update. Mac then prevents the updated binary from running because the signature doesn't match. Removing the file first clears the cache so that we don't run into "zsh: killed ..."
I've updated the magefile so that when we run the install target, the original binaries are removed before we copy. I considered fixing this directly in shx.Copy but lots of people use that and this is a bug in just regular old cp too. So I don't want shx.Copy to do stuff that even cp doesn't.
See: