Skip to content

Commit 162365e

Browse files
committed
Fix loading of dylibs not in the search path in jit mode
Reported in rust-lang#1249
1 parent 9e7c646 commit 162365e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/driver/jit.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,11 @@ fn dep_symbol_lookup_fn(
311311
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
312312
.unwrap()
313313
.1;
314-
for &cnum in &crate_info.used_crates {
314+
// `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to
315+
// get a postorder which ensures that all dependencies of a dylib are loaded before the dylib
316+
// itself. This helps the dynamic linker to find dylibs not in the regular dynamic library
317+
// search path.
318+
for &cnum in crate_info.used_crates.iter().rev() {
315319
let src = &crate_info.used_crate_source[&cnum];
316320
match data[cnum.as_usize() - 1] {
317321
Linkage::NotLinked | Linkage::IncludedFromDylib => {}

0 commit comments

Comments
 (0)