]> git.proxmox.com Git - cargo.git/commitdiff
Auto merge of #4006 - mcgoo:cargo_test_dylib, r=alexcrichton
authorbors <bors@rust-lang.org>
Tue, 9 May 2017 17:15:40 +0000 (17:15 +0000)
committerbors <bors@rust-lang.org>
Tue, 9 May 2017 17:15:40 +0000 (17:15 +0000)
fix `cargo test` of dylib projects for end user runs too

Fixes running `cargo test` and `cargo test --target <target>` for dylib projects.

Moves the logic just landed in https://github.com/rust-lang/cargo/pull/3996 into cargo itself, so cargo sets the dylib path for anyone running `cargo test` or `cargo run`. Current master sets the dylib path only for  `cargo test` on cargo itself.

This PR pins to rustup 1.2.0 for the purposes of testing. If https://github.com/rust-lang-nursery/rustup.rs/pull/1093 ends up working out, then this PR would only be important for non-rustup users and people doing cross testing, `cargo test --target <target>`.

Arguably https://github.com/mcgoo/cargo/blob/ed273851f8bc76f726eda4a2e2a7bb470c3718bc/src/cargo/ops/cargo_rustc/context.rs#L249-L253 should point to lib/rustlib/\<host triple\>/lib instead of sysroot/lib, because I think if the libs are different, you will never be able to compile a working plugin anyway, and for the host=target case you get the  lib/rustlib/\<host triple\>/lib anyhow. Is there ever a case where the lib/rustlib/\<host triple\>/lib and sysroot/lib versions of the libs would be expected to differ?

This is not a huge deal for me one way or the other - it doesn't impact my workflow at all. I nearly dropped it when I saw @alexcrichton had made it all work in 3996, but I think it's worth doing because it removes a surprise. It certainly would have saved me a couple of days of confusion. Either way, thanks for looking it over.

1  2 
src/cargo/ops/cargo_rustc/compilation.rs
src/cargo/ops/cargo_rustc/context.rs

index 286c0edc973645bd9e61ab2c55b8fb1f849a82d8,cbdb29baa93bd1f5eb92625231582bd5c5b7fb65..b34850a7978f5320feaf5c36d120dee6c195fc4f
@@@ -98,13 -106,39 +106,16 @@@ impl<'cfg> Compilation<'cfg> 
                  -> CargoResult<ProcessBuilder> {
  
          let mut search_path = if is_host {
-             vec![self.plugins_dylib_path.clone()]
+             let mut search_path = vec![self.plugins_dylib_path.clone()];
+             search_path.push(self.host_dylib_path.iter().collect());
+             search_path
          } else {
 -            let mut search_path = vec![];
 -
 -            // Add -L arguments, after stripping off prefixes like "native="
 -            // or "framework=" and filtering out directories *not* inside our
 -            // output directory, since they are likely spurious and can cause
 -            // clashes with system shared libraries (issue #3366).
 -            for dir in self.native_dirs.iter() {
 -                let dir = match dir.to_str() {
 -                    Some(s) => {
 -                        let mut parts = s.splitn(2, '=');
 -                        match (parts.next(), parts.next()) {
 -                            (Some("native"), Some(path)) |
 -                            (Some("crate"), Some(path)) |
 -                            (Some("dependency"), Some(path)) |
 -                            (Some("framework"), Some(path)) |
 -                            (Some("all"), Some(path)) => path.into(),
 -                            _ => dir.clone(),
 -                        }
 -                    }
 -                    None => dir.clone(),
 -                };
 -
 -                if dir.starts_with(&self.root_output) {
 -                    search_path.push(dir);
 -                }
 -            }
 +            let mut search_path =
 +                super::filter_dynamic_search_path(self.native_dirs.iter(),
 +                                                  &self.root_output);
              search_path.push(self.root_output.clone());
              search_path.push(self.deps_output.clone());
+             search_path.push(self.target_dylib_path.iter().collect());
              search_path
          };
  
Simple merge