Browse Source

Add enviroment variable to disable default flags: `CRATE_CC_NO_DEFAULTS`

urgh
George Hahn 6 years ago
parent
commit
2f1b83daa5
  1. 1
      README.md
  2. 7
      src/lib.rs

1
README.md

@ -77,6 +77,7 @@ number of different environment variables.
certain `TARGET`s, it also is assumed to know about other flags (most
common is `-fPIC`).
* `AR` - the `ar` (archiver) executable to use to build the static library.
* `CRATE_CC_NO_DEFAULTS` - the default compiler flags may cause conflicts in some cross compiling scenarios. Setting this variable will disable the generation of default compiler flags.
Each of these variables can also be supplied with certain prefixes and suffixes,
in the following prioritized order:

7
src/lib.rs

@ -1098,6 +1098,10 @@ impl Build {
cmd.push_cc_arg(arg.into());
}
// Disable default flag generation via environment variable
let use_defaults = self.getenv("CRATE_CC_NO_DEFAULTS").is_none();
if use_defaults {
// Non-target flags
// If the flag is not conditioned on target variable, it belongs here :)
match cmd.family {
@ -1372,6 +1376,9 @@ impl Build {
}
}
}
} else {
println!("Info: default compiler flags are disabled");
}
for directory in self.include_directories.iter() {
cmd.args.push(cmd.family.include_flag().into());

Loading…
Cancel
Save