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,17 +42,11 @@ 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
4349
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
48- fi
49-
5050# Look out for duplicated symbols when we include the compiler-rt (C) implementation
5151for rlib in $( echo $path ) ; do
5252 set +x
7979rm -f $path
8080
8181# 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
82+ build_intrinsics=" cargo build --target $1 -v --example intrinsics"
83+ $build_intrinsics
84+ $build_intrinsics --release
85+ $build_intrinsics --features c
86+ $build_intrinsics --features c --release
8787
8888# Verify that there are no undefined symbols to `panic` within our
8989# 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
90+ CARGO_PROFILE_DEV_LTO=true \
91+ cargo build --target $1 --example intrinsics
9892CARGO_PROFILE_RELEASE_LTO=true \
99- $cargo rustc --features " $INTRINSICS_FEATURES " --target $1 --example intrinsics --release
93+ cargo build --target $1 --example intrinsics --release
10094
101- # Ensure no references to a panicking function
95+ # Ensure no references to any symbols from core
10296for rlib in $( echo $path ) ; do
10397 set +ex
104- $NM -u $rlib 2>&1 | grep panicking
98+ echo " ================================================================"
99+ echo checking $rlib for references to core
100+ echo " ================================================================"
101+
102+ $NM --quiet -U $rlib | grep ' T _ZN4core' | awk ' {print $3}' | sort | uniq > defined_symbols.txt
103+ $NM --quiet -u $rlib | grep ' U _ZN4core' | awk ' {print $2}' | sort | uniq > undefined_symbols.txt
104+ grep -v -F -x -f defined_symbols.txt undefined_symbols.txt
105105
106106 if test $? = 0; then
107107 exit 1
0 commit comments