[go: up one dir, main page]

Skip to content

Commit

Permalink
Auto merge of rust-lang#4281 - alexcrichton:backport3, r=alexcrichton
Browse files Browse the repository at this point in the history
[beta] Don't push empty paths in LD_LIBRARY_PATH

Fixes rust-lang#4277.
  • Loading branch information
bors committed Jul 13, 2017
2 parents e7a185b + ca0a127 commit a60d185
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_rustc/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ 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 =
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.extend(self.target_dylib_path.clone());
search_path
};

Expand Down
42 changes: 42 additions & 0 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -977,6 +978,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::<Vec<_>>();
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/<pkg-name>.rs still works (for now)
#[test]
fn many_crate_types_old_style_lib_location() {
Expand Down

0 comments on commit a60d185

Please sign in to comment.