-
Notifications
You must be signed in to change notification settings - Fork 65
/
checkdupsym
executable file
·33 lines (28 loc) · 1.14 KB
/
checkdupsym
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
#
# This script exist because we use -Wl,--allow-multiple-definition when linking
# FFmpeg to workaround that rust staticlib exports more symbols than they need
# and causes collision with other rust staticlibs linked into the same binary.
# For details see https://github.com/rust-lang/rust/issues/104707
# Hopefully we can remove this in the future.
#
# Skip some libs that we know have colliding symbols and also some that for
# some unknown reason had duplicate symbols that ld was fine with even before
# using -Wl,--allow-multiple-definition
SKIP_LIBS="(librav1e|librsvg|libtheora|libav)"
cd "$1"
# How it works:
# - Relink FFmpeg using ld -t to get all unique input archive files (and skip some)
# - Find all unique external symbols per archive
# - Check for collisions between archives
#
DUPS=$(
for i in $(rm -f ffmpeg*; make V=1 LD="gcc -Wl,-t" | sort | grep '.a$' | uniq | grep -Ev "$SKIP_LIBS");
do nm --extern-only "$i" 2>/dev/null | awk '/^\d+ [TDB]/ {print $3}' | sort | uniq
done | sort | uniq -c | sort -n | grep -vE '^\s+1\s'
)
if [ "$DUPS" = "" ]; then
exit 0
fi
echo -e "Found duplicate symbols:\n$DUPS"
exit 1