1
1
set -ex
2
2
3
- cargo=cargo
4
-
5
3
# Test our implementation
6
- if [ " $XARGO " = " 1" ]; then
7
- # FIXME: currently these tests don't work...
4
+ if [ " $NO_STD " = " 1" ]; then
8
5
echo nothing to do
9
6
else
10
7
run=" cargo test --manifest-path testcrate/Cargo.toml --target $1 "
16
13
$run --features no-asm --release
17
14
fi
18
15
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
+
19
25
cargo build --target $1
20
26
cargo build --target $1 --release
21
27
cargo build --target $1 --features c
@@ -36,15 +42,15 @@ case $1 in
36
42
;;
37
43
esac
38
44
39
- NM=$( find $( rustc --print sysroot) -name llvm-nm)
45
+ NM=$( find $( rustc --print sysroot) \( -name llvm-nm -o -name llvm-nm.exe \) )
40
46
if [ " $NM " = " " ]; then
41
47
NM=${PREFIX} nm
42
48
fi
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 "
48
54
fi
49
55
50
56
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
79
85
rm -f $path
80
86
81
87
# 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
87
93
88
94
# Verify that there are no undefined symbols to `panic` within our
89
95
# 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
98
98
CARGO_PROFILE_RELEASE_LTO=true \
99
- $cargo rustc --features " $INTRINSICS_FEATURES " --target $1 --example intrinsics --release
99
+ cargo build --target $1 --example intrinsics --release
100
100
101
- # Ensure no references to a panicking function
101
+ # Ensure no references to any symbols from core
102
102
for rlib in $( echo $path ) ; do
103
103
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
105
111
106
112
if test $? = 0; then
107
113
exit 1
0 commit comments