Skip to content

Commit b99d69d

Browse files
committed
Apply some more fixes suggested by Shellcheck
1 parent c4a5cd0 commit b99d69d

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

ci/run-docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Small script to run tests for a target (or all targets) inside all the
44
# respective docker images.
55

6-
set -eux
6+
set -euxo pipefail
77

88
run() {
99
local target="$1"

ci/run.sh

+35-29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
set -eux
24

35
target="$1"
@@ -23,13 +25,13 @@ else
2325
fi
2426

2527
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
2729
else
28-
path=target/${target}/debug/deps/libcompiler_builtins-*.rlib
30+
rlib_paths=target/"${target}"/debug/deps/libcompiler_builtins-*.rlib
2931
fi
3032

3133
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
32-
rm -f $path
34+
rm -f $rlib_paths
3335

3436
cargo build --target "$target"
3537
cargo build --target "$target" --release
@@ -38,7 +40,7 @@ cargo build --target "$target" --release --features c
3840
cargo build --target "$target" --features no-asm
3941
cargo build --target "$target" --release --features no-asm
4042

41-
PREFIX=$(echo "$target" | sed -e 's/unknown-//')-
43+
PREFIX=${target//unknown-/}-
4244
case "$target" in
4345
armv7-*)
4446
PREFIX=arm-linux-gnueabihf-
@@ -51,7 +53,7 @@ case "$target" in
5153
;;
5254
esac
5355

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 \) )
5557
if [ "$NM" = "" ]; then
5658
NM="${PREFIX}nm"
5759
fi
@@ -63,37 +65,41 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
6365
fi
6466

6567
# 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
6769
set +x
6870
echo "================================================================"
6971
echo "checking $rlib for duplicate symbols"
7072
echo "================================================================"
73+
74+
duplicates_found=0
7175

72-
stdout=$($NM -g --defined-only $rlib 2>&1)
7376
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
7477
# 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"
8386
exit 1
87+
else
88+
echo "success; no duplicate symbols found"
8489
fi
85-
86-
set -ex
8790
done
8891

89-
rm -f $path
92+
rm -f $rlib_paths
93+
94+
build_intrinsics() {
95+
cargo build --target "$target" -v --example intrinsics "$@"
96+
}
9097

9198
# 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
97103

98104
# Verify that there are no undefined symbols to `panic` within our
99105
# implementations
@@ -103,7 +109,7 @@ CARGO_PROFILE_RELEASE_LTO=true \
103109
cargo build --target "$target" --example intrinsics --release
104110

105111
# Ensure no references to any symbols from core
106-
for rlib in $(echo $path); do
112+
for rlib in $(echo $rlib_paths); do
107113
set +x
108114
echo "================================================================"
109115
echo "checking $rlib for references to core"
@@ -115,14 +121,14 @@ for rlib in $(echo $path); do
115121
defined="$tmpdir/defined_symbols.txt"
116122
undefined="$tmpdir/defined_symbols.txt"
117123

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
122128

123129
if [ "$target" = "powerpc64-unknown-linux-gnu" ]; then
124130
echo "FIXME: powerpc64 fails these tests"
125-
elif [ "$grep_failed" != 0 ]; then
131+
elif [ "$grep_has_results" != 0 ]; then
126132
echo "error: found unexpected references to core"
127133
exit 1
128134
else

0 commit comments

Comments
 (0)