diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index be3e16a0437..f1227f3dca5 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -125,7 +125,7 @@ impl<'cfg> Compilation<'cfg> { let mut search_path = if is_host { let mut search_path = vec![self.plugins_dylib_path.clone()]; - search_path.push(self.host_dylib_path.iter().collect()); + search_path.extend(self.host_dylib_path.clone()); search_path } else { let mut search_path = @@ -133,7 +133,7 @@ impl<'cfg> Compilation<'cfg> { &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.extend(self.target_dylib_path.clone()); search_path }; diff --git a/tests/build.rs b/tests/build.rs index 05db15e757e..8c7b0c59bd4 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -7,6 +7,7 @@ use std::env; use std::fs::{self, File}; use std::io::prelude::*; +use cargo::util::paths::dylib_path_envvar; use cargo::util::process; use cargotest::{is_nightly, rustc_host, sleep_ms}; use cargotest::support::paths::{CargoPathExt,root}; @@ -984,6 +985,47 @@ fn crate_authors_env_vars() { execs().with_status(0)); } +// Regression test for #4277 +#[test] +fn crate_library_path_env_var() { + let mut p = project("foo"); + + p = p.file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/main.rs", &format!(r##" + fn main() {{ + let search_path = env!("{}"); + let paths = std::env::split_paths(&search_path).collect::>(); + assert!(!paths.contains(&"".into())); + }} + "##, dylib_path_envvar())); + + assert_that(p.cargo_process("run"), execs().with_status(0)); +} + +// Regression test for #4277 +#[test] +fn build_with_fake_libc_not_loading() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() {} + "#) + .file("src/lib.rs", r#" "#) + .file("libc.so.6", r#""#); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +} + // this is testing that src/.rs still works (for now) #[test] fn many_crate_types_old_style_lib_location() {