]> git.eshelyaron.com Git - emacs.git/commitdiff
* Warn when certain primitives are redefined (bug#61880)
authorAndrea Corallo <akrl@sdf.org>
Sun, 5 Mar 2023 09:46:18 +0000 (10:46 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sun, 5 Mar 2023 10:06:37 +0000 (11:06 +0100)
* lisp/emacs-lisp/comp.el (comp-warn-primitives): New constant.
(comp-subr-trampoline-install): Warn when a sensitive primitive is
being redefined.

lisp/emacs-lisp/comp.el

index 046d169f00fe07e413f61899eb3a4306319a82a9..48756caf100ea90bebd91668107ab76db506d09f 100644 (file)
@@ -698,11 +698,22 @@ Useful to hook into pass checkers.")
 (defvar comp-no-spawn nil
   "Non-nil don't spawn native compilation processes.")
 
+(defconst comp-warn-primitives
+  '(null memq gethash and subrp not subr-native-elisp-p
+         comp--install-trampoline concat if symbolp symbol-name make-string
+         length aset aref length> mapcar expand-file-name
+         file-name-as-directory file-exists-p native-elisp-load)
+  "List of primitives we want to warn about in case of redefinition.
+This are essential for the trampoline machinery to work properly.")
+
 ;; Moved early to avoid circularity when comp.el is loaded and
 ;; `macroexpand' needs to be advised (bug#47049).
 ;;;###autoload
 (defun comp-subr-trampoline-install (subr-name)
   "Make SUBR-NAME effectively advice-able when called from native code."
+  (when (memq subr-name comp-warn-primitives)
+    (warn "Redefining `%s' might breaks trampoline native compilation."
+          subr-name))
   (unless (or (null native-comp-enable-subr-trampolines)
               (memq subr-name native-comp-never-optimize-functions)
               (gethash subr-name comp-installed-trampolines-h))