Skip to content

Commit

Permalink
Format sources into the error message when loading codegen backends
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Jan 10, 2024
1 parent fcaeb45 commit 49afea0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,17 @@ 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 {
let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| {
let err = format!("couldn't load codegen backend {path:?}: {err}");
let err = err.sources().fold(String::new(), |s, c| write!(s, ": {}", c).unwrap());
let err = format!("couldn't load codegen backend {path:?}{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}");
let err = err.sources().fold(String::new(), |s, c| write!(s, ": {}", c).unwrap());
let err = format!(
"`__rustc_codegen_backend` symbol lookup in the codegen backend failed: {err}"
);
early_dcx.early_fatal(err);
});

Expand Down

0 comments on commit 49afea0

Please sign in to comment.