11set -ex
22
3- cargo=cargo
4-
53# Test our implementation
6- if [ " $XARGO " = " 1" ]; then
7- # FIXME: currently these tests don't work...
4+ if [ " $NO_STD " = " 1" ]; then
85 echo nothing to do
96else
107 run=" cargo test --manifest-path testcrate/Cargo.toml --target $1 "
1613 $run --features no-asm --release
1714fi
1815
16+ if [ -d /target ]; then
17+ path=/target/${1} /debug/deps/libcompiler_builtins-* .rlib
18+ else
19+ path=target/${1} /debug/deps/libcompiler_builtins-* .rlib
20+ fi
21+
22+ # Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
23+ rm -f $path
24+
1925cargo build --target $1
2026cargo build --target $1 --release
2127cargo build --target $1 --features c
@@ -36,15 +42,15 @@ case $1 in
3642 ;;
3743esac
3844
39- NM=$( find $( rustc --print sysroot) -name llvm-nm)
45+ NM=$( find $( rustc --print sysroot) \( -name llvm-nm -o -name llvm-nm.exe \) )
4046if [ " $NM " = " " ]; then
4147 NM=${PREFIX} nm
4248fi
43-
44- if [ -d /target ] ; then
45- path=/target/ ${1} /debug/deps/libcompiler_builtins- * .rlib
46- else
47- path=target/ ${1} /debug/deps/libcompiler_builtins- * .rlib
49+ # i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with
50+ # rustup run to ensure that those are in PATH.
51+ TOOLCHAIN= $( rustup show active-toolchain | sed ' s/ (default)// ' )
52+ if [[ $TOOLCHAIN == * i686-pc-windows-gnu ]] ; then
53+ NM= " rustup run $TOOLCHAIN $NM "
4854fi
4955
5056# Look out for duplicated symbols when we include the compiler-rt (C) implementation
7985rm -f $path
8086
8187# Verify that we haven't drop any intrinsic/symbol
82- build_intrinsics=" $ cargo build --target $1 -v --example intrinsics"
83- RUSTFLAGS= " -C debug-assertions=no " $build_intrinsics
84- RUSTFLAGS= " -C debug-assertions=no " $build_intrinsics --release
85- RUSTFLAGS= " -C debug-assertions=no " $build_intrinsics --features c
86- RUSTFLAGS= " -C debug-assertions=no " $build_intrinsics --features c --release
88+ build_intrinsics=" cargo build --target $1 -v --example intrinsics"
89+ $build_intrinsics
90+ $build_intrinsics --release
91+ $build_intrinsics --features c
92+ $build_intrinsics --features c --release
8793
8894# Verify that there are no undefined symbols to `panic` within our
8995# implementations
90- #
91- # TODO(#79) fix the undefined references problem for debug-assertions+lto
92- if [ -z " $DEBUG_LTO_BUILD_DOESNT_WORK " ]; then
93- RUSTFLAGS=" -C debug-assertions=no" \
94- CARGO_INCREMENTAL=0 \
95- CARGO_PROFILE_DEV_LTO=true \
96- $cargo rustc --features " $INTRINSICS_FEATURES " --target $1 --example intrinsics
97- fi
96+ CARGO_PROFILE_DEV_LTO=true \
97+ cargo build --target $1 --example intrinsics
9898CARGO_PROFILE_RELEASE_LTO=true \
99- $cargo rustc --features " $INTRINSICS_FEATURES " --target $1 --example intrinsics --release
99+ cargo build --target $1 --example intrinsics --release
100100
101- # Ensure no references to a panicking function
101+ # Ensure no references to any symbols from core
102102for rlib in $( echo $path ) ; do
103103 set +ex
104- $NM -u $rlib 2>&1 | grep panicking
104+ echo " ================================================================"
105+ echo checking $rlib for references to core
106+ echo " ================================================================"
107+
108+ $NM --quiet -U $rlib | grep ' T _ZN4core' | awk ' {print $3}' | sort | uniq > defined_symbols.txt
109+ $NM --quiet -u $rlib | grep ' U _ZN4core' | awk ' {print $2}' | sort | uniq > undefined_symbols.txt
110+ grep -v -F -x -f defined_symbols.txt undefined_symbols.txt
105111
106112 if test $? = 0; then
107113 exit 1
0 commit comments