File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff 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 `target.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) ;
Original file line number Diff line number Diff line change 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 .x86_64-unknown-linux-gnu ]
7+ rustflags = [" --cfg" , " target_feature_flag" ]
8+
9+ [target .'cfg(all())' ]
210rustflags = [" --cfg" , " custom_feature_flag" ]
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ fn bench_failing_without_custom_flag(c: &mut Criterion) {
88 compile_error ! (
99 "custom_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
1010 ) ;
11+
12+ #[ cfg( not( target_feature_flag) ) ]
13+ compile_error ! (
14+ "target_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
15+ ) ;
1116 } )
1217 } ) ;
1318}
You can’t perform that action at this time.
0 commit comments