1
- set -eux
1
+ #! /bin/bash
2
+
3
+ set -euxo pipefail
2
4
3
5
target=" $1 "
4
6
22
24
$run --features no-asm --release
23
25
fi
24
26
27
+ shopt -s nullglob
25
28
if [ -d /builtins-target ]; then
26
- path= /builtins-target/${target} /debug/deps/libcompiler_builtins-* .rlib
29
+ rlib_paths=( /builtins-target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib)
27
30
else
28
- path= target/${target} /debug/deps/libcompiler_builtins-* .rlib
31
+ rlib_paths=( target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib)
29
32
fi
30
33
31
34
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
32
- rm -f $path
35
+ rm -f " ${rlib_paths[@]} "
33
36
34
37
cargo build --target " $target "
35
38
cargo build --target " $target " --release
@@ -38,7 +41,7 @@ cargo build --target "$target" --release --features c
38
41
cargo build --target " $target " --features no-asm
39
42
cargo build --target " $target " --release --features no-asm
40
43
41
- PREFIX=$( echo " $ target" | sed -e ' s/ unknown-// ' ) -
44
+ PREFIX=${ target// unknown-/ } -
42
45
case " $target " in
43
46
armv7-* )
44
47
PREFIX=arm-linux-gnueabihf-
@@ -51,7 +54,7 @@ case "$target" in
51
54
;;
52
55
esac
53
56
54
- NM=$( find $( rustc --print sysroot) \( -name llvm-nm -o -name llvm-nm.exe \) )
57
+ NM=$( find " $( rustc --print sysroot) " \( -name llvm-nm -o -name llvm-nm.exe \) )
55
58
if [ " $NM " = " " ]; then
56
59
NM=" ${PREFIX} nm"
57
60
fi
@@ -63,37 +66,41 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
63
66
fi
64
67
65
68
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
66
- for rlib in $( echo $path ) ; do
69
+ for rlib in " ${rlib_paths[@]} " ; do
67
70
set +x
68
71
echo " ================================================================"
69
72
echo " checking $rlib for duplicate symbols"
70
73
echo " ================================================================"
74
+
75
+ duplicates_found=0
71
76
72
- stdout=$( $NM -g --defined-only $rlib 2>&1 )
73
77
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
74
78
# times so ignore it
75
- set +e
76
- echo " $stdout " | \
77
- sort | \
78
- uniq -d | \
79
- grep -v __x86.get_pc_thunk | \
80
- grep ' T __ '
81
-
82
- if test $? = 0 ; then
79
+ $NM -g --defined-only " $rlib " 2>&1 |
80
+ sort |
81
+ uniq -d |
82
+ grep -v __x86.get_pc_thunk --quiet |
83
+ grep ' T __ ' && duplicates_found=1
84
+
85
+ if [ " $duplicates_found " != 0 ] ; then
86
+ echo " error: found duplicate symbols "
83
87
exit 1
88
+ else
89
+ echo " success; no duplicate symbols found"
84
90
fi
85
-
86
- set -ex
87
91
done
88
92
89
- rm -f $path
93
+ rm -f " ${rlib_paths[@]} "
94
+
95
+ build_intrinsics () {
96
+ cargo build --target " $target " -v --example intrinsics " $@ "
97
+ }
90
98
91
99
# Verify that we haven't drop any intrinsic/symbol
92
- build_intrinsics=" cargo build --target " $target " -v --example intrinsics"
93
- $build_intrinsics
94
- $build_intrinsics --release
95
- $build_intrinsics --features c
96
- $build_intrinsics --features c --release
100
+ build_intrinsics
101
+ build_intrinsics --release
102
+ build_intrinsics --features cr
103
+ build_intrinsics --features c --release
97
104
98
105
# Verify that there are no undefined symbols to `panic` within our
99
106
# implementations
@@ -103,7 +110,7 @@ CARGO_PROFILE_RELEASE_LTO=true \
103
110
cargo build --target " $target " --example intrinsics --release
104
111
105
112
# Ensure no references to any symbols from core
106
- for rlib in $( echo $path ) ; do
113
+ for rlib in " ${rlib_paths[@]} " ; do
107
114
set +x
108
115
echo " ================================================================"
109
116
echo " checking $rlib for references to core"
@@ -115,14 +122,14 @@ for rlib in $(echo $path); do
115
122
defined=" $tmpdir /defined_symbols.txt"
116
123
undefined=" $tmpdir /defined_symbols.txt"
117
124
118
- $NM --quiet -U $rlib | grep ' T _ZN4core' | awk ' {print $3}' | sort | uniq > " $defined "
119
- $NM --quiet -u $rlib | grep ' U _ZN4core' | awk ' {print $2}' | sort | uniq > " $undefined "
120
- grep_failed =0
121
- grep -v -F -x -f " $defined " " $undefined " && grep_failed =1
125
+ $NM --quiet -U " $rlib " | grep ' T _ZN4core' | awk ' {print $3}' | sort | uniq > " $defined "
126
+ $NM --quiet -u " $rlib " | grep ' U _ZN4core' | awk ' {print $2}' | sort | uniq > " $undefined "
127
+ grep_has_results =0
128
+ grep -v -F -x -f " $defined " " $undefined " && grep_has_results =1
122
129
123
130
if [ " $target " = " powerpc64-unknown-linux-gnu" ]; then
124
131
echo " FIXME: powerpc64 fails these tests"
125
- elif [ " $grep_failed " != 0 ]; then
132
+ elif [ " $grep_has_results " != 0 ]; then
126
133
echo " error: found unexpected references to core"
127
134
exit 1
128
135
else
0 commit comments