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