Skip to content

Commit 65736c7

Browse files
committed
check-for-missing-dlls: also check for unneeded DLLs
At the same time when we verify that all `.exe` files bundled in Git for Windows are accompanied by their `.dll` dependencies, we can also ensure that we do not include `.dll` files that are not actually needed. Note that we need to filter the generated list manually, as .NET dependencies are not handled correctly by `objdump`, and the `.dll` files associated with Perl/Tcl modules are obviously needed to keep those modules working even if no `.exe` file depends on them directly. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 69c1610 commit 65736c7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

check-for-missing-dlls.sh

+21
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ else
3030
next_line='\n'
3131
fi
3232

33+
used_dlls_file=/tmp/used-dlls.$$.txt
34+
trap "rm \"$used_dlls_file\"" EXIT
35+
3336
all_files="$(export ARCH BITNESS && "$thisdir"/make-file-list.sh | tr A-Z a-z)" &&
3437
usr_bin_dlls="$(echo "$all_files" | grep '^usr/bin/[^/]*\.dll$')" &&
3538
mingw_bin_dlls="$(echo "$all_files" | grep '^mingw'$BITNESS'/bin/[^/]*\.dll$')" &&
@@ -52,12 +55,14 @@ do
5255
case "$a,$b" in
5356
*.exe:,*|*.dll:,*) current="${a%:}";;
5457
*.dll,"=>") # `ldd` output
58+
echo "$a" >>"$used_dlls_file"
5559
case "$dlls" in
5660
*"/$a$LF"*) ;; # okay, it's included
5761
*) echo "$current is missing $a" >&2;;
5862
esac
5963
;;
6064
dll,name:) # `objdump -p` output
65+
echo "$c" >>"$used_dlls_file"
6166
case "$dlls" in
6267
*"/$c$LF"*) ;; # okay, it's included
6368
*) echo "$current is missing $c" >&2;;
@@ -67,3 +72,19 @@ do
6772
done
6873
done
6974
printf "$next_line" >&2
75+
76+
used_dlls_regex="/\\($(sort <"$used_dlls_file" |
77+
uniq |
78+
sed -e 's/+x/\\+/g' -e 's/\.dll$/\\|/' -e '$s/\\|//' |
79+
tr -d '\n')\\)\\.dll\$"
80+
echo "$all_files" |
81+
grep '\.dll$' |
82+
grep -v \
83+
-e "$used_dlls_regex" \
84+
-e '^usr/lib/perl5/' \
85+
-e '^usr/lib/gawk/' \
86+
-e '^usr/lib/openssl/engines' \
87+
-e '^usr/lib/sasl2/' \
88+
-e '^mingw../libexec/git-core/\(atlassian\|azuredevops\|bitbucket\|github\|microsoft\|newtonsoft\)\.' \
89+
-e '^mingw../lib/\(engines\|reg\|thread\)' |
90+
sed 's/^/unused dll: /' >&2

0 commit comments

Comments
 (0)