Skip to content

Commit

Permalink
Auto merge of #1960 - alexcrichton:build-static, r=huonw
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Sep 1, 2015
2 parents 7336523 + 13d5094 commit 71240c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,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 {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cargo_compile_custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 71240c3

Please sign in to comment.