From: Alex Crichton Date: Tue, 1 Sep 2015 02:49:41 +0000 (-0700) Subject: Don't link build scripts dynamically X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~17^2~90^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=13d509407fe8808aed2f60b46dc6ecf13465107f;p=cargo.git Don't link build scripts dynamically There's no real reason to eagerly link build scripts dynamically as they're not going to benefit that much from dynamic linking. Most of the time they only have one dynamic dependency, libstd, and most other Rust programs don't link it dynamically so there's not really many space savings either. --- diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 25d9f2a02..f7a749bb9 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -600,7 +600,7 @@ fn build_base_args(cx: &Context, cmd.arg("--crate-type").arg(crate_type); } - let prefer_dynamic = target.for_host() || + let prefer_dynamic = (target.for_host() && !target.is_custom_build()) || (crate_types.contains(&"dylib") && pkg.package_id() != cx.resolve.root()); if prefer_dynamic { diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 28aed813b..f172e34be 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -761,7 +761,7 @@ test!(build_cmd_with_a_build_cmd { -L [..]target[..]deps -L [..]target[..]deps` {compiling} foo v0.5.0 (file://[..]) {running} `rustc build.rs --crate-name build_script_build --crate-type bin \ - -C prefer-dynamic -g \ + -g \ --out-dir [..]build[..]foo-[..] --emit=dep-info,link \ -L [..]target[..]debug -L [..]target[..]deps \ --extern a=[..]liba-[..].rlib` @@ -1109,6 +1109,7 @@ test!(build_script_with_dynamic_native_dependency { [lib] name = "builder" crate-type = ["dylib"] + plugin = true "#) .file("src/lib.rs", r#" #[no_mangle]