-
Notifications
You must be signed in to change notification settings - Fork 11
/
mod.rs
35 lines (30 loc) · 1.01 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::pgo::optimize::{get_pgo_env, prepare_pgo_optimization_flags};
use crate::workspace::CargoContext;
use cargo_metadata::Artifact;
use std::path::{Path, PathBuf};
pub mod cli;
pub(crate) mod env;
pub mod instrument;
pub mod optimize;
pub fn llvm_bolt_install_hint() -> &'static str {
"Build LLVM with BOLT and add its `bin` directory to PATH."
}
fn bolt_common_rustflags() -> &'static str {
"-C link-args=-Wl,-q"
}
fn bolt_pgo_rustflags(ctx: &CargoContext, with_pgo: bool) -> anyhow::Result<String> {
let flags = match with_pgo {
true => {
let pgo_env = get_pgo_env()?;
let pgo_dir = ctx.get_pgo_directory()?;
let flags = prepare_pgo_optimization_flags(&pgo_env, &pgo_dir)?;
format!("{} {}", flags, bolt_common_rustflags())
}
false => bolt_common_rustflags().to_string(),
};
Ok(flags)
}
fn get_binary_profile_dir(bolt_dir: &Path, artifact: &Artifact) -> PathBuf {
let name = &artifact.target.name;
bolt_dir.join(name)
}