Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/cargo-codspeed/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ impl BuildOptions<'_> {
// Use --config to set rustflags
// Our rust integration has an msrv of 1.74, --config is available since 1.63
// https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-163-2022-08-11
// Note: We have to use `target.cfg(all())` since `build` has a lower precedence.
let config_value = format!(
"build.rustflags=[{}]",
"target.'cfg(all())'.rustflags=[{}]",
flags.into_iter().map(|f| format!("\"{f}\"")).join(",")
);
cargo.arg("--config").arg(config_value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Note: This does nothing since `target.<cfg>.rustflags` takes precedence over `build.rustflags`
# See: https://doc.rust-lang.org/nightly/cargo/reference/config.html#buildrustflags
[build]
rustflags = ["--cfg", "this_does_nothing"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["--cfg", "target_feature_flag"]

[target.'cfg(all())']
rustflags = ["--cfg", "custom_feature_flag"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ fn bench_failing_without_custom_flag(c: &mut Criterion) {
compile_error!(
"custom_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
);

#[cfg(not(target_feature_flag))]
compile_error!(
"target_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
);
})
});
}
Expand Down
Loading