Skip to content

Commit

Permalink
Only set rustflags when necessary (#1978)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 5, 2024
1 parent 7bd229d commit 7f1df2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ fn cargo_build_command(
let mut rustflags = cargo_config2::Config::load_with_cwd(manifest_dir)?
.rustflags(target_triple)?
.unwrap_or_default();
let original_rustflags = rustflags.flags.clone();

// We need to pass --bin / --lib
let bridge_model = &compile_target.bridge_model;
Expand Down Expand Up @@ -358,7 +359,7 @@ fn cargo_build_command(
// but forwarding stderr is still useful in case there some non-json error
.stderr(Stdio::inherit());

if !rustflags.flags.is_empty() {
if !rustflags.flags.is_empty() && rustflags.flags != original_rustflags {
build_command.env("CARGO_ENCODED_RUSTFLAGS", rustflags.encode()?);
}

Expand Down

0 comments on commit 7f1df2b

Please sign in to comment.