From 0144764d1dde8a2f1d413d042d46cea3e10a7d0a Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Fri, 12 Mar 2021 08:59:55 +0100 Subject: [PATCH] * Fix error reporting for async native compilation (bug#47024) * lisp/emacs-lisp/comp.el (comp--native-compile): During async compilation if we catch an error print it in a parsable way so we can report it to the user. --- lisp/emacs-lisp/comp.el | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 3d2a345e210..98f4dd6e1f6 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3970,12 +3970,24 @@ load once it finishes compiling." (comp-log (format "Done compiling %s" data) 0) (cl-loop for (pass . time) in (reverse report) do (comp-log (format "Pass %s took: %fs." pass time) 0)))) - (native-compiler-error - ;; Add source input. + (t (let ((err-val (cdr err))) - (signal (car err) (if (consp err-val) - (cons function-or-file err-val) - (list function-or-file err-val)))))) + ;; If we are doing an async native compilation print the + ;; error in the correct format so is parsable and abort. + (if (and comp-async-compilation + (not (eq (car err) 'native-compiler-error))) + (progn + (message (if err-val + "%s: Error: %s %s" + "%s: Error %s") + function-or-file + (get (car err) 'error-message) + (car-safe err-val)) + (kill-emacs -1)) + ;; Otherwise re-signal it adding the compilation input. + (signal (car err) (if (consp err-val) + (cons function-or-file err-val) + (list function-or-file err-val))))))) (if (stringp function-or-file) data ;; So we return the compiled function. -- 2.39.5