Skip to content

Commit 59c51b7

Browse files
committed
Add some more shellcheck fixes
1 parent c4a5cd0 commit 59c51b7

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
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

+37-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
set -eux
1+
#!/bin/bash
2+
3+
set -euxo pipefail
24

35
target="$1"
46

@@ -22,14 +24,15 @@ else
2224
$run --features no-asm --release
2325
fi
2426

27+
shopt -s nullglob
2528
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)
2730
else
28-
path=target/${target}/debug/deps/libcompiler_builtins-*.rlib
31+
rlib_paths=(target/"${target}"/debug/deps/libcompiler_builtins-*.rlib)
2932
fi
3033

3134
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
32-
rm -f $path
35+
rm -f "${rlib_paths[@]}"
3336

3437
cargo build --target "$target"
3538
cargo build --target "$target" --release
@@ -38,7 +41,7 @@ cargo build --target "$target" --release --features c
3841
cargo build --target "$target" --features no-asm
3942
cargo build --target "$target" --release --features no-asm
4043

41-
PREFIX=$(echo "$target" | sed -e 's/unknown-//')-
44+
PREFIX=${target//unknown-/}-
4245
case "$target" in
4346
armv7-*)
4447
PREFIX=arm-linux-gnueabihf-
@@ -51,7 +54,7 @@ case "$target" in
5154
;;
5255
esac
5356

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 \) )
5558
if [ "$NM" = "" ]; then
5659
NM="${PREFIX}nm"
5760
fi
@@ -63,37 +66,41 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
6366
fi
6467

6568
# 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
6770
set +x
6871
echo "================================================================"
6972
echo "checking $rlib for duplicate symbols"
7073
echo "================================================================"
74+
75+
duplicates_found=0
7176

72-
stdout=$($NM -g --defined-only $rlib 2>&1)
7377
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
7478
# 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"
8387
exit 1
88+
else
89+
echo "success; no duplicate symbols found"
8490
fi
85-
86-
set -ex
8791
done
8892

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

9199
# 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
97104

98105
# Verify that there are no undefined symbols to `panic` within our
99106
# implementations
@@ -103,7 +110,7 @@ CARGO_PROFILE_RELEASE_LTO=true \
103110
cargo build --target "$target" --example intrinsics --release
104111

105112
# Ensure no references to any symbols from core
106-
for rlib in $(echo $path); do
113+
for rlib in "${rlib_paths[@]}"; do
107114
set +x
108115
echo "================================================================"
109116
echo "checking $rlib for references to core"
@@ -115,14 +122,14 @@ for rlib in $(echo $path); do
115122
defined="$tmpdir/defined_symbols.txt"
116123
undefined="$tmpdir/defined_symbols.txt"
117124

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
122129

123130
if [ "$target" = "powerpc64-unknown-linux-gnu" ]; then
124131
echo "FIXME: powerpc64 fails these tests"
125-
elif [ "$grep_failed" != 0 ]; then
132+
elif [ "$grep_has_results" != 0 ]; then
126133
echo "error: found unexpected references to core"
127134
exit 1
128135
else

0 commit comments

Comments
 (0)