Skip to content

Commit

Permalink
Don't error out on non-existent LD path
Browse files Browse the repository at this point in the history
Helps with PyO3/maturin#793
  • Loading branch information
messense committed Feb 4, 2022
1 parent 09d9cef commit c7a3007
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,23 @@ impl DependencyAnalyzer {
for path in ld_path.split(':') {
let normpath = if path.is_empty() {
// The ldso treats empty paths as the current directory
env::current_dir()?
env::current_dir()
} else if path.contains("$ORIGIN") || path.contains("${ORIGIN}") {
let elf_path = elf_path.canonicalize()?;
let elf_dir = elf_path.parent().expect("no parent");
let replacement = elf_dir.to_str().unwrap();
let path = path
.replace("${ORIGIN}", replacement)
.replace("$ORIGIN", replacement);
PathBuf::from(path).canonicalize()?
PathBuf::from(path).canonicalize()
} else {
self.root
.join(path.strip_prefix('/').unwrap_or(path))
.canonicalize()?
.canonicalize()
};
paths.push(normpath.display().to_string());
if let Ok(normpath) = normpath {
paths.push(normpath.display().to_string());
}
}
Ok(paths)
}
Expand Down

0 comments on commit c7a3007

Please sign in to comment.