rust/library/compiler-builtins/ci/run.sh

114 lines
3.1 KiB
Bash
Raw Normal View History

set -ex
2016-09-29 23:50:04 +00:00
# Test our implementation
2024-03-24 20:27:38 +00:00
if [ "$NO_STD" = "1" ]; then
echo nothing to do
2019-04-02 18:44:28 +00:00
else
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
$run
$run --release
$run --features c
$run --features c --release
$run --features no-asm
$run --features no-asm --release
2019-04-02 18:44:28 +00:00
fi
2016-09-29 23:50:04 +00:00
2024-03-24 20:27:38 +00:00
if [ -d /target ]; then
path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
else
path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
fi
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
rm -f $path
cargo build --target $1
cargo build --target $1 --release
cargo build --target $1 --features c
cargo build --target $1 --release --features c
cargo build --target $1 --features no-asm
cargo build --target $1 --release --features no-asm
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
2016-09-29 23:50:04 +00:00
case $1 in
armv7-*)
PREFIX=arm-linux-gnueabihf-
;;
thumb*)
PREFIX=arm-none-eabi-
;;
*86*-*)
2016-09-29 23:50:04 +00:00
PREFIX=
;;
esac
2024-03-24 20:27:38 +00:00
NM=$(find $(rustc --print sysroot) \( -name llvm-nm -o -name llvm-nm.exe \) )
if [ "$NM" = "" ]; then
NM=${PREFIX}nm
fi
2024-03-24 20:27:38 +00:00
# i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with
# rustup run to ensure that those are in PATH.
TOOLCHAIN=$(rustup show active-toolchain | sed 's/ (default)//')
if [[ $TOOLCHAIN == *i686-pc-windows-gnu ]]; then
NM="rustup run $TOOLCHAIN $NM"
2016-10-07 19:29:34 +00:00
fi
2017-06-23 18:52:22 +00:00
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
for rlib in $(echo $path); do
2017-06-23 17:44:29 +00:00
set +x
echo "================================================================"
echo checking $rlib for duplicate symbols
echo "================================================================"
stdout=$($NM -g --defined-only $rlib 2>&1)
2017-06-24 17:12:17 +00:00
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
# times so ignore it
set +e
2017-06-24 17:12:17 +00:00
echo "$stdout" | \
sort | \
uniq -d | \
grep -v __x86.get_pc_thunk | \
grep 'T __'
2016-09-29 23:50:04 +00:00
if test $? = 0; then
exit 1
fi
2017-06-23 17:44:29 +00:00
set -ex
done
rm -f $path
# Verify that we haven't drop any intrinsic/symbol
2024-03-24 20:27:38 +00:00
build_intrinsics="cargo build --target $1 -v --example intrinsics"
$build_intrinsics
$build_intrinsics --release
$build_intrinsics --features c
$build_intrinsics --features c --release
# Verify that there are no undefined symbols to `panic` within our
# implementations
2024-03-24 20:27:38 +00:00
CARGO_PROFILE_DEV_LTO=true \
cargo build --target $1 --example intrinsics
CARGO_PROFILE_RELEASE_LTO=true \
2024-03-24 20:27:38 +00:00
cargo build --target $1 --example intrinsics --release
2024-03-24 20:27:38 +00:00
# Ensure no references to any symbols from core
2017-06-23 18:52:22 +00:00
for rlib in $(echo $path); do
set +ex
2024-03-24 20:27:38 +00:00
echo "================================================================"
echo checking $rlib for references to core
echo "================================================================"
$NM --quiet -U $rlib | grep 'T _ZN4core' | awk '{print $3}' | sort | uniq > defined_symbols.txt
$NM --quiet -u $rlib | grep 'U _ZN4core' | awk '{print $2}' | sort | uniq > undefined_symbols.txt
grep -v -F -x -f defined_symbols.txt undefined_symbols.txt
2017-06-23 18:52:22 +00:00
if test $? = 0; then
exit 1
fi
set -ex
done
true