Skip to content

Commit

Permalink
Attempt to solve rust-lang#3366, regarding spurious shared library se…
Browse files Browse the repository at this point in the history
…arch paths.

This drops `native_dirs` entries that are not within the target directory when
modifying the (DY)LD_LIBRARY_PATH environment variable before running
programs.
  • Loading branch information
pkgw committed Feb 5, 2017
1 parent d710222 commit ff68a27
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cargo/ops/cargo_rustc/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Compilation<'cfg> {
/// An array of all binaries created.
pub binaries: Vec<PathBuf>,

/// All directires for the output of native build commands.
/// All directories for the output of native build commands.
///
/// This is currently used to drive some entries which are added to the
/// LD_LIBRARY_PATH as appropriate.
Expand Down Expand Up @@ -104,7 +104,10 @@ impl<'cfg> Compilation<'cfg> {
} else {
let mut search_path = vec![];

// Add -L arguments, after stripping off prefixes like "native=" or "framework=".
// 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) => {
Expand All @@ -120,7 +123,10 @@ impl<'cfg> Compilation<'cfg> {
}
None => dir.clone(),
};
search_path.push(dir);

if dir.starts_with(&self.root_output) {
search_path.push(dir);
}
}
search_path.push(self.root_output.clone());
search_path.push(self.deps_output.clone());
Expand Down

0 comments on commit ff68a27

Please sign in to comment.