Skip to content

Commit

Permalink
fix: Avoid inserting search_path again.
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Oct 5, 2024
1 parent 4abbeac commit f5bf972
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ impl<'gctx> Compilation<'gctx> {

let dylib_path = paths::dylib_path();
let dylib_path_is_empty = dylib_path.is_empty();
search_path.extend(dylib_path.into_iter());
if dylib_path.starts_with(&search_path) {
search_path = dylib_path;
} else {
search_path.extend(dylib_path.into_iter());
}
if cfg!(target_os = "macos") && dylib_path_is_empty {
// These are the defaults when DYLD_FALLBACK_LIBRARY_PATH isn't
// set or set to an empty string. Since Cargo is explicitly setting
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2173,9 +2173,8 @@ fn issue_14194_deduplicate_library_path_env_var() {
let lib_path = std::env::var("{}").unwrap();
let paths: Vec<_> = std::env::split_paths(&lib_path).collect();
if paths.len() > 1 {{
// The first path will be prepended to the search path in the next run
let first = &paths[0];
assert!(paths[1..].contains(&first));
assert!(!paths[1..].contains(&first));
}}
return;
}}
Expand Down

0 comments on commit f5bf972

Please sign in to comment.