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 Aug 31, 2024
1 parent 7a59f2e commit b7c1880
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 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
8 changes: 4 additions & 4 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2190,8 +2190,8 @@ fn issue_14194_deduplicate_library_path_env_var() {
.env("LEVEL", 2.to_string())
.with_stdout_data(str![[r#"
[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
[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
[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
[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
[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
"#]])
.with_stderr_data(str![[r#"
Expand All @@ -2212,8 +2212,8 @@ fn issue_14194_deduplicate_library_path_env_var() {
.env("LEVEL", 2.to_string())
.with_stdout_data(str![[r#"
[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
[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
[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
[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
[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
"#]])
.with_stderr_data(str![[r#"
Expand Down

0 comments on commit b7c1880

Please sign in to comment.