mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-23 20:03:31 +01:00
eecd137c1b
This patch changes how combine_libs works on Darwin like platforms to make sure we don't include any `__.SYMDEF` and `__.SYMDEF SORTED` symbols on the archive before we repack and run ${RANLIB} on the archive. See: tpo/core/tor#40683.
41 lines
847 B
Bash
Executable File
41 lines
847 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
|
|
ORIGDIR="$(pwd)"
|
|
|
|
trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
|
|
|
|
abspath() {
|
|
echo "$(cd "$(dirname "$1")" >/dev/null && pwd)/$(basename "$1")"
|
|
}
|
|
|
|
apple_symdef_fix() {
|
|
# On modern macOS and iOS we need to remove the "__.SYMDEF" and "__.SYMDEF
|
|
# SORTED" before we repack the archive.
|
|
# See: tor#40683.
|
|
if [ "$(uname -s)" = "Darwin" ] ; then
|
|
find . -name "__.SYMDEF*" -delete
|
|
fi
|
|
}
|
|
|
|
TARGET=$(abspath "$1")
|
|
|
|
shift
|
|
|
|
for input in "$@"; do
|
|
cd "$ORIGDIR"
|
|
abs=$(abspath "$input")
|
|
dir="$TMPDIR"/$(basename "$input" .a)
|
|
mkdir "$dir"
|
|
cd "$dir" >/dev/null
|
|
"${AR:-ar}" x "$abs"
|
|
done
|
|
|
|
cd "$TMPDIR" >/dev/null
|
|
apple_symdef_fix
|
|
"${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
|
|
"${RANLIB:-ranlib}" library.tmp.a
|
|
mv -f library.tmp.a "$TARGET"
|