Skip to content

Commit e07c41b

Browse files
authored
dont embed RUSTFLAGS in final binary (#1396)
1 parent 6e96b85 commit e07c41b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

build.rs

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ fn main() {
3636
println!("cargo:rustc-cfg=has_coverage_attribute");
3737
}
3838
println!("cargo:rustc-check-cfg=cfg(has_coverage_attribute)");
39+
40+
if std::env::var("RUSTFLAGS")
41+
.unwrap_or_default()
42+
.contains("-Cprofile-use=")
43+
{
44+
println!("cargo:rustc-cfg=specified_profile_use");
45+
}
46+
println!("cargo:rustc-check-cfg=cfg(specified_profile_use)");
47+
3948
generate_self_schema();
4049
println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap());
4150
}

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ pub fn build_info() -> String {
9898
format!(
9999
"profile={} pgo={}",
100100
env!("PROFILE"),
101-
option_env!("RUSTFLAGS").unwrap_or("").contains("-Cprofile-use="),
101+
// We use a `cfg!` here not `env!`/`option_env!` as those would
102+
// embed `RUSTFLAGS` into the generated binary which causes problems
103+
// with reproducable builds.
104+
cfg!(specified_profile_use),
102105
)
103106
}
104107

0 commit comments

Comments
 (0)