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