GNU bug report logs -
#67260
[PATCH emacs-team 0/2] Think ahead when compiling
Previous Next
Full log
View this message in rfc822 format
Liliana Marie Prikler <liliana.prikler <at> gmail.com> writes:
> With this series I get 94/97.
I was able to confirm that as well.
> The remaining three
Namely, the 'ucs-normalize, 'mule-util, and 'term/internal features.
For each of these the .eln files exist, but the version that gets loaded
in Guix is the byte-compiled one, unless some extra steps are taken.
> ... don't appear to be preloaded through the loadup script, so I have
> no idea how to catch them or whether it's even worth doing so.
I dug into this a little deeper. It seems that by adjusting the
load-path one is able to load the natively-compiled variants instead of
the byte-compiled for these features. Oddly, this adjustment doesn't
seem to be needed in non-Guix Emacs which may suggest the presence of a
bug. I'm hoping you have some insight that explains this difference in
behaviour.
After modifying the previous test-native-comp-p--preloaded.el (in
hindsight, the preloaded part may be a misnomer) with the below patch I
got all the 97 cases passing.
#+begin_src diff
diff -u ./test-native-comp-p--preloaded.el ./test-native-comp-p--preloaded.el
--- ./test-native-comp-p--preloaded.el 2024-02-17 08:49:36.294930488 -0500
+++ ./test-native-comp-p--preloaded.el 2024-02-17 08:38:45.102839041 -0500
@@ -155,8 +155,50 @@
(x-dnd-init-frame)
(x-handle-no-bitmap-icon)))
+(defun hack/tweak-load-path-in-guix ()
+ "Tweak `load-path' to allow natively compiled versions to be loaded.
+
+If we ensure that the `load-path' entries for `term/internal',
+`mule-util' and `ucs-normalize' exist and they occur before the
+share/emacs/<emacs-version>/lisp entry then we are able to load
+the natively compiled versions of these libraries. Of those
+three, the entry for `term/internal' is missing whereas the
+others currently occur after the share/emacs/<emacs-version>/lisp
+entry. We remedy that here.
+
+Notably, in non-Guix Emacs this isn't needed. I.e., the fact
+that the share/emacs/<emacs-version>/lisp entry precedes the
+entries for `mule-util' and `ucs-normalize' is okay as is the
+fact that the entry for `term/internal' is missing."
+ (when (getenv "GUIX_ENVIRONMENT")
+ (require 'find-func)
+ ;; first we'll add the missing entry for `term/internal'
+ (add-to-list 'load-path
+ (directory-file-name
+ (file-name-directory
+ (find-library-name (symbol-name 'term/internal))))
+ ;; NOTE: we don't need to append; doing so simply to confirm that
+ ;; it's only the relative position wrt the
+ ;; share/emacs/<emacs-version>/lisp entry that matters.
+ t)
+ ;; then we'll ensure that the entry for share/emacs/<emacs-version>/lisp is at
+ ;; the end
+ (let* ((sitelisppath (format "/share/emacs/%s/lisp"
+ emacs-version))
+ (pathsuffix (seq-filter
+ #'(lambda (x)
+ (string-suffix-p sitelisppath x))
+ load-path))
+ (pathprefix (seq-filter
+ #'(lambda (x)
+ (not
+ (string-suffix-p sitelisppath x)))
+ load-path)))
+ (setq load-path (append pathprefix pathsuffix)))))
+
(defun report/compilation-status/run ()
"Run all cases and report those that aren't native-compiled."
+ (hack/tweak-load-path-in-guix)
(let* ((results (mapcar (lambda (args) (apply #'report/compilation-status args))
report/compilation-status/cases/preloaded))
(failing (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
@@ -169,5 +211,5 @@
(if failing
(concat (format " %s failing cases below:\n\n" numfailing)
(pp-to-string failing))
- " Success!"))))
+ " Success!\n"))))
;; guix/hacking/reviews/emacs-aot/test-native-comp-p/preloaded ends here
Diff finished. Sat Feb 17 08:50:04 2024
#+end_src
I'm also attaching, for reference, the updated
test-native-comp-p--preloaded.el in its entirety.
--
Suhail
This bug report was last modified 1 year and 78 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.