diff --git a/ci/check_diff.sh b/ci/check_diff.sh index 66b4b26a88c..42fdcaa6424 100755 --- a/ci/check_diff.sh +++ b/ci/check_diff.sh @@ -2,9 +2,6 @@ set -e -# https://github.com/rust-lang/rustfmt/issues/5675 -export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH - function print_usage() { echo "usage check_diff REMOTE_REPO FEATURE_BRANCH [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" } @@ -117,6 +114,11 @@ function compile_rustfmt() { CARGO_VERSON=$(cargo --version) echo -e "\ncompiling with $CARGO_VERSON\n" + # Because we're building standalone binaries we need to set `LD_LIBRARY_PATH` so each + # binary can find it's runtime dependencies. See https://github.com/rust-lang/rustfmt/issues/5675 + # This will prepend the `LD_LIBRARY_PATH` for the master rustfmt binary + export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH + echo "Building rustfmt from src" cargo build -q --release --bin rustfmt && cp target/release/rustfmt $1/rustfmt @@ -126,9 +128,18 @@ function compile_rustfmt() { git switch $OPTIONAL_COMMIT_HASH --detach fi + # This will prepend the `LD_LIBRARY_PATH` for the feature branch rustfmt binary. + # In most cases the `LD_LIBRARY_PATH` should be the same for both rustfmt binaries that we build + # in `compile_rustfmt`, however, there are scenarios where each binary has different runtime + # dependencies. For example, during subtree syncs we bump the nightly toolchain required to build + # rustfmt, and therefore the feature branch relies on a newer set of runtime dependencies. + export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH + echo "Building feature rustfmt from src" cargo build -q --release --bin rustfmt && cp target/release/rustfmt $1/feature_rustfmt + echo -e "\nRuntime dependencies for rustfmt -- LD_LIBRARY_PATH: $LD_LIBRARY_PATH" + RUSFMT_BIN=$1/rustfmt RUSTFMT_VERSION=$($RUSFMT_BIN --version) echo -e "\nRUSFMT_BIN $RUSTFMT_VERSION\n"