Update how LD_LIBRARY_PATH
is set for rustfmt binaries in diff check
rustfmt currently has a runtime dependency on the sysroot. So when we build a standalone rustfmt binary we need to set `LD_LIBRARY_PATH` so each rustfmt binary knows where to find it's dependencies. When running our Diff-Check job to test PRs for breaking changes it's often the case that both the master rustfmt binary and the feature branch binary have the same runtime dependencies so we only need to set `LD_LIBRARY_PATH` once. However, when running the diff-check job against a subtree sync PR that assumption doesn't hold. The subtree sync PR bumps the required toolchain used to build rustfmt and therefore the binary that gets built for the subtree sync PR has a different runtime dependency than the master rustfmt binary. Now we set `LD_LIBRARY_PATH` twice to account for this potential difference.
This commit is contained in:
parent
b446e8eee5
commit
37489e43b6
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user