diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-01-19 19:27:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 19:27:00 +0100 |
| commit | ae09415fa4e994992d95b702eb876910ded8f19b (patch) | |
| tree | fb730d643f10904842b0aeb100ed181e20365184 /compiler/rustc_interface/src/util.rs | |
| parent | cad609d9e3a33cfef1727dcb0682e05f1f036afa (diff) | |
| parent | 1dc3ab02cdba905aa1cce73d938c8e825107a8e8 (diff) | |
| download | rust-ae09415fa4e994992d95b702eb876910ded8f19b.tar.gz rust-ae09415fa4e994992d95b702eb876910ded8f19b.zip | |
Rollup merge of #119815 - nagisa:nagisa/polishes-libloading-use-somewhat, r=bjorn3
Format sources into the error message when loading codegen backends cc https://github.com/rust-lang/rustc_codegen_cranelift/issues/1447 cc `@bjorn3`
Diffstat (limited to 'compiler/rustc_interface/src/util.rs')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 9fd44e46b31..76b9e8de75f 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -162,15 +162,21 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( } fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn { + fn format_err(e: &(dyn std::error::Error + 'static)) -> String { + e.sources().map(|e| format!(": {e}")).collect() + } let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| { - let err = format!("couldn't load codegen backend {path:?}: {err}"); + let err = format!("couldn't load codegen backend {path:?}{}", format_err(&err)); early_dcx.early_fatal(err); }); let backend_sym = unsafe { lib.get::<MakeBackendFn>(b"__rustc_codegen_backend") } .unwrap_or_else(|e| { - let err = format!("couldn't load codegen backend: {e}"); - early_dcx.early_fatal(err); + let e = format!( + "`__rustc_codegen_backend` symbol lookup in the codegen backend failed{}", + format_err(&e) + ); + early_dcx.early_fatal(e); }); // Intentionally leak the dynamic library. We can't ever unload it |
