diff --git a/build.rs b/build.rs index d1093c747..f8f66901a 100644 --- a/build.rs +++ b/build.rs @@ -36,6 +36,15 @@ fn main() { println!("cargo:rustc-cfg=has_coverage_attribute"); } println!("cargo:rustc-check-cfg=cfg(has_coverage_attribute)"); + + if std::env::var("RUSTFLAGS") + .unwrap_or_default() + .contains("-Cprofile-use=") + { + println!("cargo:rustc-cfg=specified_profile_use"); + } + println!("cargo:rustc-check-cfg=cfg(specified_profile_use)"); + generate_self_schema(); println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap()); } diff --git a/src/lib.rs b/src/lib.rs index eb598424b..eb486da66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,10 @@ pub fn build_info() -> String { format!( "profile={} pgo={}", env!("PROFILE"), - option_env!("RUSTFLAGS").unwrap_or("").contains("-Cprofile-use="), + // We use a `cfg!` here not `env!`/`option_env!` as those would + // embed `RUSTFLAGS` into the generated binary which causes problems + // with reproducable builds. + cfg!(specified_profile_use), ) }