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

140 lines
4.1 KiB
Bash
Raw Normal View History

set -eux
target="${1:-}"
if [ -z "${1:-}" ]; then
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
echo "Defaulted to host target $host_target"
target="$host_target"
fi
if [ "${USING_CONTAINER_RUSTC:-}" = 1 ]; then
# Install nonstandard components if we have control of the environment
rustup target list --installed |
grep -E "^$target\$" ||
rustup target add "$target"
fi
2016-09-29 23:50:04 +00:00
# Test our implementation
if [ "${NO_STD:-}" = "1" ]; then
echo "nothing to do for no_std"
2019-04-02 18:44:28 +00:00
else
run="cargo test --manifest-path testcrate/Cargo.toml --target $target"
2019-04-02 18:44:28 +00:00
$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
if [ -d /builtins-target ]; then
path=/builtins-target/${target}/debug/deps/libcompiler_builtins-*.rlib
2024-03-24 20:27:38 +00:00
else
path=target/${target}/debug/deps/libcompiler_builtins-*.rlib
2024-03-24 20:27:38 +00:00
fi
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
rm -f $path
cargo build --target "$target"
cargo build --target "$target" --release
cargo build --target "$target" --features c
cargo build --target "$target" --release --features c
cargo build --target "$target" --features no-asm
cargo build --target "$target" --release --features no-asm
PREFIX=$(echo "$target" | sed -e 's/unknown-//')-
case "$target" in
2016-09-29 23:50:04 +00:00
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
2024-03-24 20:27:38 +00:00
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
build_intrinsics="cargo build --target "$target" -v --example intrinsics"
2024-03-24 20:27:38 +00:00
$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 "$target" --example intrinsics
CARGO_PROFILE_RELEASE_LTO=true \
cargo build --target "$target" --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 +x
2024-03-24 20:27:38 +00:00
echo "================================================================"
echo "checking $rlib for references to core"
2024-03-24 20:27:38 +00:00
echo "================================================================"
set -x
tmpdir="${CARGO_TARGET_DIR:-target}/tmp"
test -d "$tmpdir" || mkdir "$tmpdir"
defined="$tmpdir/defined_symbols.txt"
undefined="$tmpdir/defined_symbols.txt"
$NM --quiet -U $rlib | grep 'T _ZN4core' | awk '{print $3}' | sort | uniq > "$defined"
$NM --quiet -u $rlib | grep 'U _ZN4core' | awk '{print $2}' | sort | uniq > "$undefined"
grep_failed=0
grep -v -F -x -f "$defined" "$undefined" && grep_failed=1
if [ "$target" = "powerpc64-unknown-linux-gnu" ]; then
echo "FIXME: powerpc64 fails these tests"
elif [ "$grep_failed" != 0 ]; then
echo "error: found unexpected references to core"
2017-06-23 18:52:22 +00:00
exit 1
else
echo "success; no references to core found"
2017-06-23 18:52:22 +00:00
fi
done
true