Always use llvm-nm in mk/check-symbol-prefixes.sh.

Don't try to use binutils `nm` or the Android SDK `llvm-nm`, since they don't
support LLVM's "opaque pointers".
This commit is contained in:
Brian Smith 2022-10-20 23:27:15 -07:00
parent 371377d41d
commit 0d18da865a
2 changed files with 20 additions and 36 deletions

View File

@ -17,32 +17,16 @@
set -eux -o pipefail
IFS=$'\n\t'
llvm_version=15
for arg in $*; do
case $arg in
--target=*)
target=${arg#*=}
;;
*)
;;
esac
done
nm_exe=nm
case $target in
--target=aarch64-unknown-linux-gnu|*-musl*|wasm32-*)
case "$OSTYPE" in
darwin*)
nm_exe=nm
;;
*)
llvm_version=15
nm_exe=llvm-nm-$llvm_version
;;
--target=*-android*)
ndk_version=25.1.8937393
ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version}
android_tools=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin
nm_exe=$android_tools/llvm-nm
;;
esac
# TODO: This should only look in one target directory.
# TODO: This isn't as strict as it should be.
#
@ -51,14 +35,9 @@ esac
#
# This is very liberal in filtering out symbols that "look like"
# Rust-compiler-generated symbols.
find target/$target -type f -name libring-*.rlib | while read -r infile; do
tmpfile=$infile-without-lib-rmeta
cp "$infile" "$tmpfile"
# `nm` doesn't understand `lib.rmeta`.
ar d "$tmpfile" lib.rmeta
bad=$($nm_exe --defined-only --extern-only --print-file-name "$tmpfile" \
| ( grep -v -E " . _?(ring_core_|__rustc|_ZN|DW.ref.rust_eh_personality)" || [[ $? == 1 ]] ))
rm "$tmpfile"
find target -type f -name libring-*.rlib | while read -r infile; do
bad=$($nm_exe --defined-only --extern-only --print-file-name "$infile" \
| ( grep -v -E " . _?(__imp__ZN4ring|ring_core_|__rustc|_ZN|DW.ref.rust_eh_personality)" || [[ $? == 1 ]] ))
if [ ! -z "${bad-}" ]; then
echo "$bad"
exit 1

View File

@ -82,12 +82,17 @@ case $target in
;;
esac
if [ -n "$use_clang" ]; then
# https://github.com/rustls/rustls/pull/1009 upgraded Rust's LLVM version to
# 14
case "$OSTYPE" in
linux*)
ubuntu_codename=$(lsb_release --codename --short)
llvm_version=15
sudo apt-key add mk/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$llvm_version main"
sudo add-apt-repository "deb http://apt.llvm.org/$ubuntu_codename/ llvm-toolchain-$ubuntu_codename-$llvm_version main"
sudo apt-get update
install_packages clang-$llvm_version llvm-$llvm_version
fi
# We need to use `llvm-nm` in `mk/check-symbol-prefixes.sh`.
install_packages llvm-$llvm_version
if [ -n "$use_clang" ]; then
install_packages clang-$llvm_version
fi
;;
esac