Skip to content

Commit f709c35

Browse files
committed
Auto merge of #4278 - mbrubeck:path, r=alexcrichton
Don't push empty paths in LD_LIBRARY_PATH Fixes #4277. Note: I haven't written a test for this fix yet.
2 parents 5982cf9 + 0588424 commit f709c35

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/cargo/ops/cargo_rustc/compilation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ impl<'cfg> Compilation<'cfg> {
125125

126126
let mut search_path = if is_host {
127127
let mut search_path = vec![self.plugins_dylib_path.clone()];
128-
search_path.push(self.host_dylib_path.iter().collect());
128+
search_path.extend(self.host_dylib_path.clone());
129129
search_path
130130
} else {
131131
let mut search_path =
132132
super::filter_dynamic_search_path(self.native_dirs.iter(),
133133
&self.root_output);
134134
search_path.push(self.root_output.clone());
135135
search_path.push(self.deps_output.clone());
136-
search_path.push(self.target_dylib_path.iter().collect());
136+
search_path.extend(self.target_dylib_path.clone());
137137
search_path
138138
};
139139

tests/build.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::env;
77
use std::fs::{self, File};
88
use std::io::prelude::*;
99

10+
use cargo::util::paths::dylib_path_envvar;
1011
use cargo::util::process;
1112
use cargotest::{is_nightly, rustc_host, sleep_ms};
1213
use cargotest::support::paths::{CargoPathExt,root};
@@ -984,6 +985,47 @@ fn crate_authors_env_vars() {
984985
execs().with_status(0));
985986
}
986987

988+
// Regression test for #4277
989+
#[test]
990+
fn crate_library_path_env_var() {
991+
let mut p = project("foo");
992+
993+
p = p.file("Cargo.toml", r#"
994+
[project]
995+
name = "foo"
996+
version = "0.0.1"
997+
authors = []
998+
"#)
999+
.file("src/main.rs", &format!(r##"
1000+
fn main() {{
1001+
let search_path = env!("{}");
1002+
let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
1003+
assert!(!paths.contains(&"".into()));
1004+
}}
1005+
"##, dylib_path_envvar()));
1006+
1007+
assert_that(p.cargo_process("run"), execs().with_status(0));
1008+
}
1009+
1010+
// Regression test for #4277
1011+
#[test]
1012+
fn build_with_fake_libc_not_loading() {
1013+
let p = project("foo")
1014+
.file("Cargo.toml", r#"
1015+
[package]
1016+
name = "foo"
1017+
version = "0.0.1"
1018+
authors = []
1019+
"#)
1020+
.file("src/main.rs", r#"
1021+
fn main() {}
1022+
"#)
1023+
.file("src/lib.rs", r#" "#)
1024+
.file("libc.so.6", r#""#);
1025+
1026+
assert_that(p.cargo_process("build"), execs().with_status(0));
1027+
}
1028+
9871029
// this is testing that src/<pkg-name>.rs still works (for now)
9881030
#[test]
9891031
fn many_crate_types_old_style_lib_location() {

0 commit comments

Comments
 (0)