about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-25 12:38:03 +0000
committerbors <bors@rust-lang.org>2021-01-25 12:38:03 +0000
commit84864bfea9c00fb90a1fa6e3af1d8ad52ce8f9ec (patch)
treedf999148f56c83acfc278c61dc9efa42024e1c93
parentd3163e96553ae8cb1fca0e62084b124e8b98310b (diff)
parentb2e6f333e9d22a882b5b30219789065e03278840 (diff)
downloadrust-84864bfea9c00fb90a1fa6e3af1d8ad52ce8f9ec.tar.gz
rust-84864bfea9c00fb90a1fa6e3af1d8ad52ce8f9ec.zip
Auto merge of #81380 - pietroalbini:cargo-pgo-lockfile, r=Mark-Simulacrum
Use the monorepo's lockfile when building cargo for PGO profiling

Fixes https://github.com/rust-lang/rust/issues/81378. The description of the problem and the reasoning for the fix is in the source code comments.

r? `@Mark-Simulacrum`
-rwxr-xr-xsrc/ci/pgo.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ci/pgo.sh b/src/ci/pgo.sh
index 13b8ca91f89..a5f47ca78ff 100755
--- a/src/ci/pgo.sh
+++ b/src/ci/pgo.sh
@@ -24,6 +24,20 @@ pgo_perf_benchmark ctfe-stress-4
 
 cp -pri ../src/tools/cargo /tmp/cargo
 
+# The Cargo repository does not have a Cargo.lock in it, as it relies on the
+# lockfile already present in the rust-lang/rust monorepo. This decision breaks
+# down when Cargo is built outside the monorepo though (like in this case),
+# resulting in a build without any dependency locking.
+#
+# To ensure Cargo is built with locked dependencies even during PGO profiling
+# the following command copies the monorepo's lockfile into the Cargo temporary
+# directory. Cargo will *not* keep that lockfile intact, as it will remove all
+# the dependencies Cargo itself doesn't rely on. Still, it will prevent
+# building Cargo with arbitrary dependency versions.
+#
+# See #81378 for the bug that prompted adding this.
+cp -p ../Cargo.lock /tmp/cargo
+
 # Build cargo (with some flags)
 function pgo_cargo {
     RUSTC=./build/$PGO_HOST/stage2/bin/rustc \