]> git.eshelyaron.com Git - emacs.git/commitdiff
* When advising search in `comp-eln-load-path' the first writable dir
authorAndrea Corallo <akrl@sdf.org>
Fri, 2 Oct 2020 12:42:43 +0000 (14:42 +0200)
committerAndrea Corallo <akrl@sdf.org>
Fri, 2 Oct 2020 12:48:48 +0000 (14:48 +0200)
* lisp/emacs-lisp/comp.el (comp-tampoline-compile): Do not crash
if we can't write in the first entry in `comp-eln-load-path' but
search for another one.

lisp/emacs-lisp/comp.el

index 02b08119f9c6ba942ee9a18d86add21ead9e1f0c..ef13c0ce63e745f85807ca6c5ff52e8c55265657 100644 (file)
@@ -2593,17 +2593,25 @@ Return the its filename if found or nil otherwise."
     ;; the primitive we are replacing in the function reloc table.
     (defalias trampoline-sym
       `(closure nil ,lambda-list
-         (let ((f #',subr-name))
-           (,(if (memq '&rest lambda-list) 'apply 'funcall)
-            f
-            ,@(cl-loop
-               for arg in lambda-list
-               unless (memq arg '(&optional &rest))
-                 collect arg)))))
-    (native-compile trampoline-sym nil
-                    (expand-file-name (comp-trampoline-filename subr-name)
-                                      (concat (car comp-eln-load-path)
-                                              comp-native-version-dir)))))
+                (let ((f #',subr-name))
+                  (,(if (memq '&rest lambda-list) 'apply 'funcall)
+                   f
+                   ,@(cl-loop
+                      for arg in lambda-list
+                      unless (memq arg '(&optional &rest))
+                      collect arg)))))
+    (native-compile
+     trampoline-sym nil
+     (cl-loop
+      for dir in comp-eln-load-path
+      for f = (expand-file-name
+               (comp-trampoline-filename subr-name)
+               (concat dir
+                       comp-native-version-dir))
+      when (file-writable-p f)
+        do (cl-return f)
+      finally (error "Can't find a writable directory in \
+`comp-eln-load-path'")))))
 
 ;;;###autoload
 (defun comp-subr-safe-advice (subr-name)