compiler-builtins-zynq/ci/run.sh

121 lines
3.0 KiB
Bash
Raw Normal View History

set -ex
# FIXME(japarix/xargo#186) this shouldn't be necessary
export RUST_TARGET_PATH=`pwd`
2019-04-03 02:44:28 +08:00
cargo=cargo
if [ "$XARGO" = "1" ]; then
cargo=xargo
fi
2017-06-24 12:36:36 +08:00
INTRINSICS_FEATURES="c"
# Some architectures like ARM apparently seem to require the `mem` feature
# enabled to successfully compile the `intrinsics` example, and... we're not
# sure why!
2017-06-24 12:36:36 +08:00
if [ -z "$INTRINSICS_FAILS_WITH_MEM_FEATURE" ]; then
INTRINSICS_FEATURES="$INTRINSICS_FEATURES mem"
fi
2016-09-30 07:50:04 +08:00
# Test our implementation
2019-04-03 02:44:28 +08:00
if [ "$XARGO" = "1" ]; then
run="xargo test --manifest-path testcrate/Cargo.toml --target $1"
for t in $(ls testcrate/tests); do
t=${t%.rs}
2019-04-03 02:44:28 +08:00
RUSTFLAGS="-C debug-assertions=no -C lto" \
CARGO_INCREMENTAL=0 \
$run --test $t --no-default-features --features 'mem c' --no-run
qemu-arm-static target/${1}/debug/$t-*
done
2019-04-03 02:44:28 +08:00
for t in $(ls testcrate/tests); do
t=${t%.rs}
RUSTFLAGS="-C lto" \
CARGO_INCREMENTAL=0 \
$run --test $t --no-default-features --features 'mem c' --no-run --release
qemu-arm-static target/${1}/release/$t-*
done
else
run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
$run
$run --release
$run --features c
$run --features c --release
fi
2016-09-30 07:50:04 +08:00
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
2016-09-30 07:50:04 +08:00
case $1 in
armv7-*)
PREFIX=arm-linux-gnueabihf-
;;
thumb*)
PREFIX=arm-none-eabi-
;;
*86*-*)
2016-09-30 07:50:04 +08:00
PREFIX=
;;
esac
NM=nm
2016-09-30 07:50:04 +08:00
2017-06-24 12:23:52 +08:00
if [ -d /target ]; then
path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
2017-06-24 12:23:52 +08:00
else
path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
2016-10-08 03:29:34 +08:00
fi
2017-06-24 02:52:22 +08:00
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
for rlib in $(echo $path); do
2017-06-24 01:44:29 +08:00
set +x
stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
2017-06-25 01:12:17 +08:00
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
# times so ignore it
#
# FIXME(#167) - we shouldn't ignore `__builtin_cl` style symbols here.
set +e
2017-06-25 01:12:17 +08:00
echo "$stdout" | \
sort | \
uniq -d | \
grep -v __x86.get_pc_thunk | \
grep -v __builtin_cl | \
2017-07-08 02:20:04 +08:00
grep -v __builtin_ctz | \
2017-06-25 01:12:17 +08:00
grep 'T __'
2016-09-30 07:50:04 +08:00
if test $? = 0; then
exit 1
fi
2017-06-24 01:44:29 +08:00
set -ex
done
rm -f $path
# Verify that we haven't drop any intrinsic/symbol
RUSTFLAGS="-C debug-assertions=no" \
$cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
# Verify that there are no undefined symbols to `panic` within our
# implementations
#
# TODO(#79) fix the undefined references problem for debug-assertions+lto
2017-06-24 12:36:36 +08:00
if [ -z "$DEBUG_LTO_BUILD_DOESNT_WORK" ]; then
RUSTFLAGS="-C debug-assertions=no" \
CARGO_INCREMENTAL=0 \
2017-06-24 12:36:36 +08:00
$cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -- -C lto
fi
$cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics --release -- -C lto
2017-06-24 02:52:22 +08:00
# Ensure no references to a panicking function
for rlib in $(echo $path); do
set +ex
2017-06-24 02:52:22 +08:00
$PREFIX$NM -u $rlib 2>&1 | grep panicking
if test $? = 0; then
exit 1
fi
set -ex
done
true