about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/driver/jit.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-03-15 14:41:48 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-03-15 14:41:48 +0000
commitfce629d2e9eddd957411caa5fed0e1146c745bd8 (patch)
treef539d967c8dac4932b09de113b12b5115e352849 /compiler/rustc_codegen_cranelift/src/driver/jit.rs
parent992d154f3a84cc8abcefcf6e6cf3698e4821b506 (diff)
parentdec0daa8f6d0a0e1c702f169abb6bf3eee198c67 (diff)
downloadrust-fce629d2e9eddd957411caa5fed0e1146c745bd8.tar.gz
rust-fce629d2e9eddd957411caa5fed0e1146c745bd8.zip
Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into sync_cg_clif-2023-03-15
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/driver/jit.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/src/driver/jit.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/driver/jit.rs b/compiler/rustc_codegen_cranelift/src/driver/jit.rs
index 8b5a2da2c59..f6a48e3257b 100644
--- a/compiler/rustc_codegen_cranelift/src/driver/jit.rs
+++ b/compiler/rustc_codegen_cranelift/src/driver/jit.rs
@@ -311,7 +311,11 @@ fn dep_symbol_lookup_fn(
         .find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
         .unwrap()
         .1;
-    for &cnum in &crate_info.used_crates {
+    // `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to
+    // get a postorder which ensures that all dependencies of a dylib are loaded before the dylib
+    // itself. This helps the dynamic linker to find dylibs not in the regular dynamic library
+    // search path.
+    for &cnum in crate_info.used_crates.iter().rev() {
         let src = &crate_info.used_crate_source[&cnum];
         match data[cnum.as_usize() - 1] {
             Linkage::NotLinked | Linkage::IncludedFromDylib => {}