Skip to content

Commit a5b0ee0

Browse files
committed
fix(cargo-codspeed): use target.rustflags config so it's merged with the .cargo/config.toml
When using build.rustflags, it won't be merged because it has a lower precedence. See: https://doc.rust-lang.org/nightly/cargo/reference/config.html#buildrustflags
1 parent 2d80483 commit a5b0ee0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/cargo-codspeed/src/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ impl BuildOptions<'_> {
145145
// Use --config to set rustflags
146146
// Our rust integration has an msrv of 1.74, --config is available since 1.63
147147
// https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-163-2022-08-11
148+
// Note: We have to use `cfg(all())` since `build` has a lower precedence.
148149
let config_value = format!(
149-
"build.rustflags=[{}]",
150+
"target.'cfg(all())'.rustflags=[{}]",
150151
flags.into_iter().map(|f| format!("\"{f}\"")).join(",")
151152
);
152153
cargo.arg("--config").arg(config_value);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
# Note: This does nothing since `target.<cfg>.rustflags` takes precedence over `build.rustflags`
2+
# See: https://doc.rust-lang.org/nightly/cargo/reference/config.html#buildrustflags
13
[build]
4+
rustflags = ["--cfg", "this_does_nothing"]
5+
6+
[target.'cfg(all())']
27
rustflags = ["--cfg", "custom_feature_flag"]

0 commit comments

Comments
 (0)