Skip to content

Commit b7c1880

Browse files
committed
fix: Avoid inserting search_path again.
1 parent 7a59f2e commit b7c1880

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ impl<'gctx> Compilation<'gctx> {
323323

324324
let dylib_path = paths::dylib_path();
325325
let dylib_path_is_empty = dylib_path.is_empty();
326-
search_path.extend(dylib_path.into_iter());
326+
if dylib_path.starts_with(&search_path) {
327+
search_path = dylib_path;
328+
} else {
329+
search_path.extend(dylib_path.into_iter());
330+
}
327331
if cfg!(target_os = "macos") && dylib_path_is_empty {
328332
// These are the defaults when DYLD_FALLBACK_LIBRARY_PATH isn't
329333
// set or set to an empty string. Since Cargo is explicitly setting

tests/testsuite/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,8 +2190,8 @@ fn issue_14194_deduplicate_library_path_env_var() {
21902190
.env("LEVEL", 2.to_string())
21912191
.with_stdout_data(str![[r#"
21922192
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2193-
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2194-
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2193+
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2194+
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
21952195
21962196
"#]])
21972197
.with_stderr_data(str![[r#"
@@ -2212,8 +2212,8 @@ fn issue_14194_deduplicate_library_path_env_var() {
22122212
.env("LEVEL", 2.to_string())
22132213
.with_stdout_data(str![[r#"
22142214
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2215-
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2216-
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2215+
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2216+
[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
22172217
22182218
"#]])
22192219
.with_stderr_data(str![[r#"

0 commit comments

Comments
 (0)