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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions tools/m1_utils/update_dynamic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@ set -e
# Note: this program is the simplest version of patching a dynamic library
# Other code should handle making frameworks, etc
patch() {
EXTDIR="$(mktemp -d "${TMPDIR:-/tmp}/bazel_m1_utils.XXXXXXXX")"
pushd $EXTDIR > /dev/null
trap "rm -rf $EXTDIR" EXIT
EXTDIR="$(mktemp -d "${TMPDIR:-/tmp}/bazel_m1_utils.XXXXXXXX")"
pushd $EXTDIR > /dev/null
trap "rm -rf $EXTDIR" EXIT

# Attempt lipo if it's a fat binary
ARCHS=()
while read ARCH; do
ARCHS+=($ARCH)
done < <(lipo -archs "$FWF")
if test "${#ARCHS[@]}" -gt 1; then
lipo "$FWF" -thin arm64 -output "OF.ar" || cp "$FWF" "OF.ar"
else
cp "$FWF" "OF.ar"
fi
# Attempt lipo if it's a fat binary
ARCHS=()
while read ARCH; do
ARCHS+=($ARCH)
done < <(lipo -archs "$FWF")
if test "${#ARCHS[@]}" -gt 1; then
lipo "$FWF" -thin arm64 -output "OF.ar" || cp "$FWF" "OF.ar"
else
cp "$FWF" "OF.ar"
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"
# FIXME: Versions should be input from the build system
# filter stderr to ignore code signature warnings
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" \
Comment on lines +23 to +28
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 🙏

2> >(grep --invert 'warning: changes being made to the file will invalidate the code signature' >&2)
}

# Framework file
# Framework file
export FWF="$1"

# Output file
Expand Down