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