emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/native-comp-eln-caches b296fb0 1/3: Make install target function


From: Andrea Corallo
Subject: scratch/native-comp-eln-caches b296fb0 1/3: Make install target functional for new eln-cache directory arrangement
Date: Sun, 16 Aug 2020 13:02:26 -0400 (EDT)

branch: scratch/native-comp-eln-caches
commit b296fb025c36af2ca13b04252fafb63faedcd9d1
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Make install target functional for new eln-cache directory arrangement
    
        * src/comp.h (fixup_eln_load_path): New extern.
    
        * src/comp.c (fixup_eln_load_path): New function.
    
        * src/pdumper.c (dump_do_dump_relocation): Update to make use of
        'fixup_eln_load_path'.
    
        * lisp/loadup.el: Update to store in the compilation unit the
        correct eln-cache installed path. Rename --lisp-dest -> --eln-dest
        and.
    
        * Makefile.in: Pass the eln destination directory to
        src/Makefile. Rename LISP_DESTDIR -> ELN_DESTDIR.
        (ELN_DESTDIR): Define.
        (install-eln): New target.
        (install): Add install-eln as prerequisite.
    
        * src/Makefile.in: Rename --lisp-dest -> --eln-dest and
        LISP_DESTDIR -> ELN_DESTDIR.
---
 Makefile.in     | 14 ++++++++++++--
 lisp/loadup.el  | 44 ++++++++++++++++++++++----------------------
 src/Makefile.in |  2 +-
 src/comp.c      | 21 +++++++++++++++++++++
 src/comp.h      |  2 ++
 src/pdumper.c   | 15 ++-------------
 6 files changed, 60 insertions(+), 38 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 253f7f7..0e488f2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -108,6 +108,8 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
 am__v_at_0 = @
 am__v_at_1 =
 
+HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@
+
 # ==================== Where To Install Things ====================
 
 # Location to install Emacs.app under GNUstep / macOS.
@@ -330,6 +332,8 @@ CONFIG_STATUS_FILES_IN = \
 COPYDIR = ${srcdir}/etc ${srcdir}/lisp
 COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
 
+ELN_DESTDIR = "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}/"
+
 all: ${SUBDIR} info
 
 .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver
@@ -422,7 +426,7 @@ dirstate = .git/logs/HEAD
 VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate))
 src: Makefile
        $(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' 
BIN_DESTDIR='$(DESTDIR)${bindir}/' \
-                LISP_DESTDIR='$(DESTDIR)${lispdir}/' all
+                ELN_DESTDIR='$(ELN_DESTDIR)' all
 
 blessmail: Makefile src
        $(MAKE) -C lib-src maybe-blessmail
@@ -469,7 +473,7 @@ $(srcdir)/configure: $(srcdir)/configure.ac 
$(srcdir)/m4/*.m4
 ## don't have to duplicate the list of utilities to install in
 ## this Makefile as well.
 
-install: all install-arch-indep install-etcdoc install-arch-dep 
install-$(NTDIR) blessmail
+install: all install-arch-indep install-etcdoc install-arch-dep 
install-$(NTDIR) blessmail install-eln
        @true
 
 ## Ensure that $subdir contains a subdirs.el file.
@@ -753,6 +757,12 @@ install-etc:
          done ; \
        done
 
+### Install native compiled Lisp files.
+install-eln:
+ifeq ($(HAVE_NATIVE_COMP),yes)
+       find eln-cache -type f -exec ${INSTALL_DATA} -D "{}" "$(ELN_DESTDIR){}" 
\;
+endif
+
 ### Build Emacs and install it, stripping binaries while installing them.
 install-strip:
        $(MAKE) INSTALL_STRIP=-s install
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 31843fc..aaa5888 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -449,33 +449,33 @@ lost after dumping")))
 ;; At this point, we're ready to resume undo recording for scratch.
 (buffer-enable-undo "*scratch*")
 
-(when (native-comp-available-p)
+(when (boundp 'comp-ctxt)
   ;; Fix the compilation unit filename to have it working when
   ;; when installed or if the source directory got moved.  This is set to be
   ;; a pair in the form: (rel-path-from-install-bin . rel-path-from-local-bin).
   (let ((h (make-hash-table :test #'eq))
-        (lisp-src-dir (expand-file-name (concat default-directory "../lisp")))
         (bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
-        (lisp-dest-dir (cadr (member "--lisp-dest" command-line-args))))
-    (mapatoms (lambda (s)
-                (let ((f (symbol-function s)))
-                  (when (subr-native-elisp-p f)
-                    (puthash (subr-native-comp-unit f) nil h)))))
-    (maphash (lambda (cu _)
-               (native-comp-unit-set-file
-                cu
-               (cons
-                 ;; Relative path from the installed binary.
-                 (file-relative-name
-                  (concat lisp-dest-dir
-                         (replace-regexp-in-string
-                           (regexp-quote lisp-src-dir) ""
-                           (native-comp-unit-file cu)))
-                 bin-dest-dir)
-                 ;; Relative path from the built uninstalled binary.
-                 (file-relative-name (native-comp-unit-file cu)
-                                     invocation-directory))))
-            h)))
+        (eln-dest-dir (cadr (member "--eln-dest" command-line-args))))
+    (when (and bin-dest-dir eln-dest-dir)
+      (setq eln-dest-dir
+            (concat eln-dest-dir "eln-cache/" comp-native-path-postfix "/"))
+      (mapatoms (lambda (s)
+                  (let ((f (symbol-function s)))
+                    (when (subr-native-elisp-p f)
+                      (puthash (subr-native-comp-unit f) nil h)))))
+      (maphash (lambda (cu _)
+                 (native-comp-unit-set-file
+                  cu
+                 (cons
+                   ;; Relative path from the installed binary.
+                   (file-relative-name (concat eln-dest-dir
+                                               (file-name-nondirectory
+                                                (native-comp-unit-file cu)))
+                                       bin-dest-dir)
+                   ;; Relative path from the built uninstalled binary.
+                   (file-relative-name (native-comp-unit-file cu)
+                                       invocation-directory))))
+              h))))
 
 (when (hash-table-p purify-flag)
   (let ((strings 0)
diff --git a/src/Makefile.in b/src/Makefile.in
index 7380a87..31a5a7e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -587,7 +587,7 @@ endif
 ifeq ($(DUMPING),pdumper)
 $(pdmp): emacs$(EXEEXT)
        LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump 
\
-               --bin-dest $(BIN_DESTDIR) --lisp-dest $(LISP_DESTDIR)
+               --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR)
        cp -f $@ $(bootstrap_pdmp)
 endif
 
diff --git a/src/comp.c b/src/comp.c
index b795afa..d42bb4f 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4529,6 +4529,27 @@ maybe_defer_native_compilation (Lisp_Object 
function_name,
 /* Functions used to load eln files.  */
 /**************************************/
 
+/* Fixup the system eln-cache dir.  This is the last entry in
+   `comp-eln-load-path'.  */
+void
+fixup_eln_load_path (Lisp_Object directory)
+{
+  Lisp_Object last_cell = Qnil;
+  Lisp_Object tmp = Vcomp_eln_load_path;
+  FOR_EACH_TAIL (tmp)
+    if (CONSP (tmp))
+      last_cell = tmp;
+
+  Lisp_Object eln_cache_sys =
+    Ffile_name_directory (concat2 (Vinvocation_directory,
+                                  directory));
+  /* One directory up...  */
+  eln_cache_sys =
+    Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil,
+                                     make_fixnum (-1)));
+  Fsetcar (last_cell, eln_cache_sys);
+}
+
 typedef char *(*comp_lit_str_func) (void);
 
 /* Deserialize read and return static object.  */
diff --git a/src/comp.h b/src/comp.h
index 687e426..9270f8b 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -101,6 +101,8 @@ extern void dispose_all_remaining_comp_units (void);
 
 extern void clean_package_user_dir_of_old_comp_units (void);
 
+extern void fixup_eln_load_path (Lisp_Object directory);
+
 #else /* #ifdef HAVE_NATIVE_COMP */
 
 static inline void
diff --git a/src/pdumper.c b/src/pdumper.c
index ca055a1..8172389 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5249,23 +5249,12 @@ dump_do_dump_relocation (const uintptr_t dump_base,
              {
                fclose (file);
                installation_state = INSTALLED;
-               /* FIXME  Vcomp_eln_load_path = ?? */
+               fixup_eln_load_path (XCAR (comp_u->file));
              }
            else
              {
                installation_state = LOCAL_BUILD;
-               /* Fixup `comp-eln-load-path' so emacs can be invoked
-                  position independently.  */
-               Lisp_Object eln_cache_sys =
-                 Ffile_name_directory (concat2 (Vinvocation_directory,
-                                                XCDR (comp_u->file)));
-               /* One directory up...  */
-               eln_cache_sys =
-                 Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil,
-                                                   make_fixnum (-1)));
-               /* FIXME for subsequent dumps we should fixup only the
-                  last entry.  */
-               Vcomp_eln_load_path = Fcons (eln_cache_sys, Qnil);
+               fixup_eln_load_path (XCDR (comp_u->file));
              }
          }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]