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 8, 2024
1 parent e888c13 commit 54dbc2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 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
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ fn issue_14194_deduplicate_library_path_env_var() {
let prev_lib_path = std::fs::read_to_string(txt).unwrap();
// Ensure no duplicate insertion to dylib search paths
// when calling `cargo run` recursively.
assert_ne!(lib_path, prev_lib_path);
assert_eq!(lib_path, prev_lib_path);
}}
if level == 0 {{
Expand Down

0 comments on commit 54dbc2b

Please sign in to comment.