@@ -135,6 +135,10 @@ static void * dl_get_sym(dl_handle * handle, const char * name) {
135
135
return p;
136
136
}
137
137
138
+ static const char * dl_error () {
139
+ return " " ;
140
+ }
141
+
138
142
#else
139
143
140
144
using dl_handle = void ;
@@ -155,6 +159,11 @@ static void * dl_get_sym(dl_handle * handle, const char * name) {
155
159
return dlsym (handle, name);
156
160
}
157
161
162
+ static const char * dl_error () {
163
+ const char *rslt = dlerror ();
164
+ return rslt != nullptr ? rslt : " " ;
165
+ }
166
+
158
167
#endif
159
168
160
169
using dl_handle_ptr = std::unique_ptr<dl_handle, dl_handle_deleter>;
@@ -240,7 +249,7 @@ struct ggml_backend_registry {
240
249
dl_handle_ptr handle { dl_load_library (path) };
241
250
if (!handle) {
242
251
if (!silent) {
243
- GGML_LOG_ERROR (" %s: failed to load %s\n " , __func__, path_str (path).c_str ());
252
+ GGML_LOG_ERROR (" %s: failed to load %s: %s \n " , __func__, path_str (path).c_str (), dl_error ());
244
253
}
245
254
return nullptr ;
246
255
}
@@ -530,7 +539,7 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
530
539
if (filename.native ().find (file_prefix) == 0 && ext == file_extension) {
531
540
dl_handle_ptr handle { dl_load_library (entry) };
532
541
if (!handle && !silent) {
533
- GGML_LOG_ERROR (" %s: failed to load %s\n " , __func__, path_str (entry.path ()).c_str ());
542
+ GGML_LOG_ERROR (" %s: failed to load %s: %s \n " , __func__, path_str (entry.path ()).c_str (), dl_error ());
534
543
}
535
544
if (handle) {
536
545
auto score_fn = (ggml_backend_score_t ) dl_get_sym (handle.get (), " ggml_backend_score" );
0 commit comments