Skip to content

Commit c9ed7b2

Browse files
committed
Auto merge of #6355 - MarcusCalhoun-Lopez:dyld_fix, r=alexcrichton
use DYLD_FALLBACK_LIBRARY_PATH for dylib_path_envvar on macOS See https://users.rust-lang.org/t/subprocess-and-dynamic-library-linking-problem-interaction/7873/10 See https://trac.macports.org/ticket/57692
2 parents 3c65c40 + b7516d3 commit c9ed7b2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/cargo/util/paths.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ pub fn dylib_path_envvar() -> &'static str {
3434
if cfg!(windows) {
3535
"PATH"
3636
} else if cfg!(target_os = "macos") {
37-
"DYLD_LIBRARY_PATH"
37+
// When loading and linking a dynamic library or bundle, dlopen
38+
// searches in LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, PWD, and
39+
// DYLD_FALLBACK_LIBRARY_PATH.
40+
// In the Mach-O format, a dynamic library has an "install path."
41+
// Clients linking against the library record this path, and the
42+
// dynamic linker, dyld, uses it to locate the library.
43+
// dyld searches DYLD_LIBRARY_PATH *before* the install path.
44+
// dyld searches DYLD_FALLBACK_LIBRARY_PATH only if it cannot
45+
// find the library in the install path.
46+
// Setting DYLD_LIBRARY_PATH can easily have unintended
47+
// consequences.
48+
"DYLD_FALLBACK_LIBRARY_PATH"
3849
} else {
3950
"LD_LIBRARY_PATH"
4051
}

0 commit comments

Comments
 (0)