}
}
+fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
+ let mut cfg = cc::Build::new();
+ cfg.cargo_metadata(false)
+ .opt_level(2)
+ .warnings(false)
+ .debug(false)
+ .target(&target.triple)
+ .host(&build.build.triple);
+ match build.crt_static(target) {
+ Some(a) => {
+ cfg.static_crt(a);
+ }
+ None => {
+ if target.contains("msvc") {
+ cfg.static_crt(true);
+ }
+ if target.contains("musl") {
+ cfg.static_flag(true);
+ }
+ }
+ }
+ cfg
+}
+
pub fn find(build: &mut Build) {
// For all targets we're going to need a C compiler for building some shims
// and such as well as for being a linker for Rust code.
.chain(iter::once(build.build))
.collect::<HashSet<_>>();
for target in targets.into_iter() {
- let mut cfg = cc::Build::new();
- cfg.cargo_metadata(false)
- .opt_level(2)
- .warnings(false)
- .debug(false)
- .target(&target.triple)
- .host(&build.build.triple);
- match build.crt_static(target) {
- Some(a) => {
- cfg.static_crt(a);
- }
- None => {
- if target.contains("msvc") {
- cfg.static_crt(true);
- }
- if target.contains("musl") {
- cfg.static_flag(true);
- }
- }
- }
-
+ let mut cfg = new_cc_build(build, target);
let config = build.config.target_config.get(&target);
if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
cfg.compiler(cc);
// If we use llvm-libunwind, we will need a C++ compiler as well for all targets
// We'll need one anyways if the target triple is also a host triple
- let mut cfg = cc::Build::new();
- cfg.cargo_metadata(false)
- .opt_level(2)
- .warnings(false)
- .debug(false)
- .cpp(true)
- .target(&target.triple)
- .host(&build.build.triple);
-
+ let mut cfg = new_cc_build(build, target);
+ cfg.cpp(true);
let cxx_configured = if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
cfg.compiler(cxx);
true