From c7a3007971ee154a2ca85ce5ffc1e1a38e54a79b Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 4 Feb 2022 10:44:57 +0800 Subject: [PATCH] Don't error out on non-existent LD path Helps with https://github.com/PyO3/maturin/issues/793 --- Cargo.lock | 8 ++++---- src/lib.rs | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dacfdfc..f7c3566 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -95,9 +95,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.84" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", diff --git a/src/lib.rs b/src/lib.rs index cfaaf34..8138142 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,7 +182,7 @@ 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"); @@ -190,13 +190,15 @@ impl DependencyAnalyzer { 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) }