Skip to content

Commit 49afea0

Browse files
committed
Format sources into the error message when loading codegen backends
cc rust-lang/rustc_codegen_cranelift#1447
1 parent fcaeb45 commit 49afea0

File tree

1 file changed

+6
-2
lines changed
  • compiler/rustc_interface/src

1 file changed

+6
-2
lines changed

compiler/rustc_interface/src/util.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
163163

164164
fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
165165
let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| {
166-
let err = format!("couldn't load codegen backend {path:?}: {err}");
166+
let err = err.sources().fold(String::new(), |s, c| write!(s, ": {}", c).unwrap());
167+
let err = format!("couldn't load codegen backend {path:?}{err}");
167168
early_dcx.early_fatal(err);
168169
});
169170

170171
let backend_sym = unsafe { lib.get::<MakeBackendFn>(b"__rustc_codegen_backend") }
171172
.unwrap_or_else(|e| {
172-
let err = format!("couldn't load codegen backend: {e}");
173+
let err = err.sources().fold(String::new(), |s, c| write!(s, ": {}", c).unwrap());
174+
let err = format!(
175+
"`__rustc_codegen_backend` symbol lookup in the codegen backend failed: {err}"
176+
);
173177
early_dcx.early_fatal(err);
174178
});
175179

0 commit comments

Comments
 (0)