Skip to content

Commit c694bae

Browse files
committed
Disable default args when they may conflict with CFLAGS/CXXFLAGS
1 parent 2f1b83d commit c694bae

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,13 @@ impl Build {
10981098
cmd.push_cc_arg(arg.into());
10991099
}
11001100

1101-
// Disable default flag generation via environment variable
1102-
let use_defaults = self.getenv("CRATE_CC_NO_DEFAULTS").is_none();
1101+
// Disable default flag generation via environment variable or when
1102+
// certain cross compiling arguments are set
1103+
let use_defaults = self.getenv("CRATE_CC_NO_DEFAULTS").is_none()
1104+
&& !(cmd.args.iter().any(|ref a| {
1105+
let arg = a.to_str().unwrap_or("");
1106+
arg.starts_with("-m") || arg.starts_with("/arch") || arg.starts_with("--target")
1107+
}));
11031108

11041109
if use_defaults {
11051110
// Non-target flags

0 commit comments

Comments
 (0)