Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[M1 Utils] silence stderr warnings from vtool and strip #735

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

jszumski
Copy link
Collaborator

@jszumski jszumski commented Jul 10, 2023

Silence stderr from vtool and strip when updating vendored dynamic frameworks.

Hides output with pre-built xcframeworks that looks like this:

INFO: From Action Pods/Reveal-SDK/Reveal-SDK.import_middleman/RevealServer.framework:

/Applications/Xcode-14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/vtool warning: code signature will be invalid for /private/var/tmp/_bazel_jszumski/ed7e7efa198ffcfaf8285220a74bc6f4/execroot/cash-ios/bazel-out/ios-sim_arm64-min11.4-applebin_ios-ios_sim_arm64-dbg-ST-b571db90efec/bin/Pods/Reveal-SDK/Reveal-SDK.import_middleman/RevealServer.framework/RevealServer.tmp

/Applications/Xcode-14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: changes being made to the file will invalidate the code signature in: /private/var/tmp/_bazel_jszumski/ed7e7efa198ffcfaf8285220a74bc6f4/execroot/cash-ios/bazel-out/ios-sim_arm64-min11.4-applebin_ios-ios_sim_arm64-dbg-ST-b571db90efec/bin/Pods/Reveal-SDK/Reveal-SDK.import_middleman/RevealServer.framework/RevealServer.tmp

@@ -19,10 +19,12 @@ patch() {
fi

# FIXME: Versions should be input from the build system
xcrun vtool -arch arm64 -set-build-version 7 11.0 11.0 -replace -output "$OF" "OF.ar"
# stderr is ignored to silence expected warnings that the old code signatures will be invalid
xcrun vtool -arch arm64 -set-build-version 7 11.0 11.0 -replace -output "$OF" "OF.ar" 2> /dev/null
Copy link
Contributor

@jerrymarino jerrymarino Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT to just remove the sig before if it has one via codesign remove-signature?

# Remove the code sig to prevent warnings on further commands 
if ! xcrun otool -l $OF | grep -q LC_CODE_SIGNATURE; then 
    codesign remove-signature $OF
fi

Also, if these command fail for other errors it will omit the string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( may need a robust version of checking for a sig w/o verifying )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I wasn't sure if other useful output would come through stderr for these commands. I'll give this a try tomorrow

Copy link
Collaborator Author

@jszumski jszumski Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature was removed successfully but seems to have mangled the file somehow:

/Applications/Xcode-14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: fatal error: file not in an order that can be processed (link edit information does not fill the __LINKEDIT segment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If codesign --remove-signature is too messed up, WDTY to just pipe stderrr and grep --invert $CODE_SIGNATURE_ERROR, otherwise conditionally swallowing for signed ones only..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, grep --invert "warning:"🙈

@jszumski jszumski force-pushed the jszumski/silence-m1-util-warnings branch from 125dc75 to 9ffdc95 Compare July 13, 2023 19:32
@jszumski jszumski force-pushed the jszumski/silence-m1-util-warnings branch from 9ffdc95 to 46853e6 Compare July 13, 2023 20:41
Comment on lines +23 to +28
xcrun vtool -arch arm64 -set-build-version 7 11.0 11.0 -replace -output "$OF" "OF.ar" \
2> >(grep --invert 'warning: code signature will be invalid' >&2)

# Xcode 13.1-13.2.1 workaround - see update_static.sh
strip -S "$OF"
# Xcode 13.1-13.2.1 workaround - see update_static.sh
# filter stderr to ignore code signature warnings
strip -S "$OF" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future: we should revisit these soon 🙏

@jszumski jszumski merged commit fe9222d into master Jul 17, 2023
8 checks passed
@jszumski jszumski deleted the jszumski/silence-m1-util-warnings branch July 17, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants