enrich error info when tries to dlopen Enzyme

This commit is contained in:
sgasho
2026-01-04 22:56:17 +09:00
parent 85c8ff69cb
commit d7fa6e527f
3 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
codegen_llvm_autodiff_component_unavailable = failed to load our autodiff backend. Did you install it via rustup?
codegen_llvm_autodiff_component_unavailable = failed to load our autodiff backend.
.note = load error: {$err}
codegen_llvm_autodiff_without_enable = using the autodiff feature requires -Z autodiff=Enable
codegen_llvm_autodiff_without_lto = using the autodiff feature requires setting `lto="fat"` in your Cargo.toml
+4 -1
View File
@@ -34,7 +34,10 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_component_unavailable)]
pub(crate) struct AutoDiffComponentUnavailable;
#[note]
pub(crate) struct AutoDiffComponentUnavailable {
pub err: String,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_without_lto)]
+4 -2
View File
@@ -249,8 +249,10 @@ fn init(&self, sess: &Session) {
use crate::back::lto::enable_autodiff_settings;
if sess.opts.unstable_opts.autodiff.contains(&AutoDiff::Enable) {
if let Err(_) = llvm::EnzymeWrapper::get_or_init(&sess.opts.sysroot) {
sess.dcx().emit_fatal(crate::errors::AutoDiffComponentUnavailable);
if let Err(err) = llvm::EnzymeWrapper::get_or_init(&sess.opts.sysroot) {
sess.dcx().emit_fatal(crate::errors::AutoDiffComponentUnavailable {
err: format!("{err:?}"),
});
}
enable_autodiff_settings(&sess.opts.unstable_opts.autodiff);
}