From 900c526df43096080ef628f4bfc2dd0fa04c1aeb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 28 Sep 2024 19:53:09 -0400 Subject: [PATCH] Fix some warnings from shellcheck --- ci/run-docker.sh | 8 ++++---- ci/run.sh | 30 ++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 50ae9dc83..a4fa5e367 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -14,7 +14,7 @@ run() { # will be owned by root mkdir -p target - if [ $(uname -s) = "Linux" ] && [ -z "${DOCKER_BASE_IMAGE:-}" ]; then + if [ "$(uname -s)" = "Linux" ] && [ -z "${DOCKER_BASE_IMAGE:-}" ]; then # Share the host rustc and target. Do this only on Linux and if the image # isn't overridden run_args=( @@ -53,9 +53,9 @@ run() { ) fi - docker ${build_cmd[@]:-build} \ + docker "${build_cmd[@]:-build}" \ -t "builtins-$target" \ - ${build_args[@]:-} \ + "${build_args[@]:-}" \ "ci/docker/$target" docker run \ --rm \ @@ -64,7 +64,7 @@ run() { -e "CARGO_TARGET_DIR=/builtins-target" \ -v "$(pwd):/checkout:ro" \ -w /checkout \ - ${run_args[@]:-} \ + "${run_args[@]:-}" \ --init \ "builtins-$target" \ sh -c "$run_cmd" diff --git a/ci/run.sh b/ci/run.sh index dcbe1caf4..675609072 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -38,17 +38,24 @@ fi if [ "${TEST_VERBATIM:-}" = "1" ]; then verb_path=$(cmd.exe //C echo \\\\?\\%cd%\\testcrate\\target2) - cargo build --manifest-path testcrate/Cargo.toml --target $target --target-dir $verb_path --features c + cargo build --manifest-path testcrate/Cargo.toml \ + --target "$target" --target-dir "$verb_path" --features c fi -if [ -d /builtins-target ]; then - rlib_paths=/builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib -else - rlib_paths=target/"${target}"/debug/deps/libcompiler_builtins-*.rlib -fi +declare -a rlib_paths + +# Set the `rlib_paths` global array to a list of all compiler-builtins rlibs +update_rlib_paths() { + if [ -d /builtins-target ]; then + rlib_paths=( /builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) + else + rlib_paths=( target/"${target}"/debug/deps/libcompiler_builtins-*.rlib ) + fi +} # Remove any existing artifacts from previous tests that don't set #![compiler_builtins] -rm -f $rlib_paths +update_rlib_paths +rm -f "${rlib_paths[@]}" cargo build --target "$target" cargo build --target "$target" --release @@ -76,6 +83,7 @@ NM=$(find "$(rustc --print sysroot)" \( -name llvm-nm -o -name llvm-nm.exe \) ) if [ "$NM" = "" ]; then NM="${PREFIX}nm" fi + # i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with # rustup run to ensure that those are in PATH. TOOLCHAIN="$(rustup show active-toolchain | sed 's/ (default)//')" @@ -84,7 +92,8 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then fi # Look out for duplicated symbols when we include the compiler-rt (C) implementation -for rlib in $rlib_paths; do +update_rlib_paths +for rlib in "${rlib_paths[@]}"; do set +x echo "================================================================" echo "checking $rlib for duplicate symbols" @@ -108,7 +117,7 @@ for rlib in $rlib_paths; do fi done -rm -f $rlib_paths +rm -f "${rlib_paths[@]}" build_intrinsics() { cargo build --target "$target" -v --example intrinsics "$@" @@ -128,7 +137,8 @@ CARGO_PROFILE_RELEASE_LTO=true \ cargo build --target "$target" --example intrinsics --release # Ensure no references to any symbols from core -for rlib in $(echo $rlib_paths); do +update_rlib_paths +for rlib in "${rlib_paths[@]}"; do set +x echo "================================================================" echo "checking $rlib for references to core"