7 python3 ..
/x.py build
--target=$PGO_HOST --host=$PGO_HOST \
8 --stage 2 library
/std
--rust-profile-generate=/tmp
/rustc-pgo
10 RUSTC_BOOTSTRAP
=1 .
/build
/$PGO_HOST/stage
2/bin
/rustc
--edition=2018 \
11 --crate-type=lib ..
/library
/core
/src
/lib.rs
13 # Download and build a single-file stress test benchmark on perf.rust-lang.org.
14 function pgo_perf_benchmark
{
15 local PERF
=1e19fc4c6168d2f7596e512f42f358f245d8f09d
16 local github_prefix
=https
://raw.githubusercontent.com
/rust-lang
/rustc-perf
/$PERF
19 curl
-o /tmp
/$name.rs
$github_prefix/collector
/benchmarks
/$name/src
/lib.rs
21 RUSTC_BOOTSTRAP
=1 .
/build
/$PGO_HOST/stage
2/bin
/rustc
--edition=$edition \
22 --crate-type=lib
/tmp
/$name.rs
25 pgo_perf_benchmark externs
2018
26 pgo_perf_benchmark ctfe-stress-4
2018
27 pgo_perf_benchmark inflate
2015
29 cp -pri ..
/src
/tools
/cargo
/tmp
/cargo
31 # The Cargo repository does not have a Cargo.lock in it, as it relies on the
32 # lockfile already present in the rust-lang/rust monorepo. This decision breaks
33 # down when Cargo is built outside the monorepo though (like in this case),
34 # resulting in a build without any dependency locking.
36 # To ensure Cargo is built with locked dependencies even during PGO profiling
37 # the following command copies the monorepo's lockfile into the Cargo temporary
38 # directory. Cargo will *not* keep that lockfile intact, as it will remove all
39 # the dependencies Cargo itself doesn't rely on. Still, it will prevent
40 # building Cargo with arbitrary dependency versions.
42 # See #81378 for the bug that prompted adding this.
43 cp -p ..
/Cargo.lock
/tmp
/cargo
45 # Build cargo (with some flags)
47 RUSTC
=.
/build
/$PGO_HOST/stage
2/bin
/rustc \
48 .
/build
/$PGO_HOST/stage
0/bin
/cargo $@ \
49 --manifest-path /tmp
/cargo
/Cargo.toml
52 # Build a couple different variants of Cargo
53 CARGO_INCREMENTAL
=1 pgo_cargo check
54 echo 'pub fn barbarbar() {}' >> /tmp
/cargo
/src
/cargo
/lib.rs
55 CARGO_INCREMENTAL
=1 pgo_cargo check
56 touch /tmp
/cargo
/src
/cargo
/lib.rs
57 CARGO_INCREMENTAL
=1 pgo_cargo check
58 pgo_cargo build
--release
60 # Merge the profile data we gathered
61 .
/build
/$PGO_HOST/llvm
/bin
/llvm-profdata \
62 merge
-o /tmp
/rustc-pgo.profdata
/tmp
/rustc-pgo
64 # This produces the actual final set of artifacts.
65 $@
--rust-profile-use=/tmp
/rustc-pgo.profdata