]> git.proxmox.com Git - rustc.git/blame - src/ci/pgo.sh
New upstream version 1.50.0+dfsg1
[rustc.git] / src / ci / pgo.sh
CommitLineData
fc512014
XL
1#!/bin/bash
2
3set -euxo pipefail
4
5export RUSTC_BOOTSTRAP=1
6
7rm -rf /tmp/rustc-pgo
8
9python2.7 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
10 --stage 2 library/std --rust-profile-generate=/tmp/rustc-pgo
11
12./build/$PGO_HOST/stage2/bin/rustc --edition=2018 \
13 --crate-type=lib ../library/core/src/lib.rs
14
15# Download and build a single-file stress test benchmark on perf.rust-lang.org.
16function pgo_perf_benchmark {
17 local PERF=e095f5021bf01cf3800f50b3a9f14a9683eb3e4e
18 local github_prefix=https://raw.githubusercontent.com/rust-lang/rustc-perf/$PERF
19 local name=$1
20 curl -o /tmp/$name.rs $github_prefix/collector/benchmarks/$name/src/lib.rs
21 ./build/$PGO_HOST/stage2/bin/rustc --edition=2018 --crate-type=lib /tmp/$name.rs
22}
23
24pgo_perf_benchmark externs
25pgo_perf_benchmark ctfe-stress-4
26
27cp -pri ../src/tools/cargo /tmp/cargo
28
29# Build cargo (with some flags)
30function pgo_cargo {
31 RUSTC=./build/$PGO_HOST/stage2/bin/rustc \
32 ./build/$PGO_HOST/stage0/bin/cargo $@ \
33 --manifest-path /tmp/cargo/Cargo.toml
34}
35
36# Build a couple different variants of Cargo
37CARGO_INCREMENTAL=1 pgo_cargo check
38echo 'pub fn barbarbar() {}' >> /tmp/cargo/src/cargo/lib.rs
39CARGO_INCREMENTAL=1 pgo_cargo check
40touch /tmp/cargo/src/cargo/lib.rs
41CARGO_INCREMENTAL=1 pgo_cargo check
42pgo_cargo build --release
43
44# Merge the profile data we gathered
45./build/$PGO_HOST/llvm/bin/llvm-profdata \
46 merge -o /tmp/rustc-pgo.profdata /tmp/rustc-pgo
47
48# This produces the actual final set of artifacts.
49$@ --rust-profile-use=/tmp/rustc-pgo.profdata