]> git.proxmox.com Git - cargo.git/commitdiff
Pass `-C prefer-dynamic` for dylib dependencies
authorAlex Crichton <alex@alexcrichton.com>
Thu, 6 Nov 2014 16:58:01 +0000 (08:58 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 6 Nov 2014 16:58:01 +0000 (08:58 -0800)
src/cargo/ops/cargo_rustc/mod.rs
tests/test_cargo_compile.rs
tests/test_cargo_profiles.rs

index 9b2c3bf78406b3204b629b1b9fcc32af35d8bbe0..ad7ef689066108da4836ea497a794d8ac63774f0 100644 (file)
@@ -491,7 +491,10 @@ fn build_base_args(cx: &Context,
                          .rpath(root_profile.get_rpath())
     }
 
-    if profile.is_for_host() {
+    let prefer_dynamic = profile.is_for_host() ||
+                         (crate_types.contains(&"dylib") &&
+                          pkg.get_package_id() != cx.resolve.root());
+    if prefer_dynamic {
         cmd = cmd.arg("-C").arg("prefer-dynamic");
     }
 
index 7b40945142cd415014e37db0608f9f6d329677b4..d8b034f4d29a24ca1b3e99fdd106142d0fee3e15 100644 (file)
@@ -819,7 +819,7 @@ test!(verbose_release_build_deps {
                 execs().with_status(0).with_stdout(format!("\
 {compiling} foo v0.0.0 ({url})
 {running} `rustc {dir}{sep}foo{sep}src{sep}lib.rs --crate-name foo \
-        --crate-type dylib --crate-type rlib \
+        --crate-type dylib --crate-type rlib -C prefer-dynamic \
         --opt-level 3 \
         --cfg ndebug \
         -C metadata=[..] \
index f7e5024cb850b9d2fef2a39e95bda318e9799809..8813a4994b0a06824f8c06383d6267bf5acd6be6 100644 (file)
@@ -82,7 +82,7 @@ test!(top_level_overrides_deps {
                 execs().with_status(0).with_stdout(format!("\
 {compiling} foo v0.0.0 ({url})
 {running} `rustc {dir}{sep}foo{sep}src{sep}lib.rs --crate-name foo \
-        --crate-type dylib --crate-type rlib \
+        --crate-type dylib --crate-type rlib -C prefer-dynamic \
         --opt-level 1 \
         -g \
         -C metadata=[..] \