From: Eli Zaretskii <eliz@gnu.org>
Date: Thu, 10 Feb 2022 17:12:19 +0000 (+0200)
Subject: Merge from origin/emacs-28
X-Git-Tag: emacs-29.0.90~2385
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2d897f7c6691b3f72ce43ae1827307653ed9fc0b;p=emacs.git

Merge from origin/emacs-28

# Conflicts:
#	lisp/startup.el
---

2d897f7c6691b3f72ce43ae1827307653ed9fc0b
diff --cc lisp/startup.el
index 053afa104d0,d369f3ef84e..ad4942b7f73
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@@ -519,71 -519,10 +519,73 @@@ DIRS are relative.
        xdg-dir)
       (t emacs-d-dir))))
  
 +(defvar comp--compilable)
 +(defvar comp--delayed-sources)
 +(defun startup--require-comp-safely ()
 +  "Require the native compiler avoiding circular dependencies."
 +  (when (featurep 'native-compile)
 +    ;; Require comp with `comp--compilable' set to nil to break
 +    ;; circularity.
 +    (let ((comp--compilable nil))
 +      (require 'comp))
 +    (native--compile-async comp--delayed-sources nil 'late)
 +    (setq comp--delayed-sources nil)))
 +
 +(declare-function native--compile-async "comp.el"
 +                  (files &optional recursively load selector))
 +(defun startup--honor-delayed-native-compilations ()
 +  "Honor pending delayed deferred native compilations."
 +  (when (and (native-comp-available-p)
 +             comp--delayed-sources)
 +    (startup--require-comp-safely))
 +  (setq comp--compilable t))
 +
  (defvar native-comp-eln-load-path)
+ (defvar native-comp-deferred-compilation)
+ (defvar comp-enable-subr-trampolines)
  
 +(defvar startup--original-eln-load-path nil
 +  "Original value of `native-comp-eln-load-path'.")
 +
 +(defun startup-redirect-eln-cache (cache-directory)
 +  "Redirect the user's eln-cache directory to CACHE-DIRECTORY.
 +CACHE-DIRECTORY must be a single directory, a string.
 +This function destructively changes `native-comp-eln-load-path'
 +so that its first element is CACHE-DIRECTORY.  If CACHE-DIRECTORY
 +is not an absolute file name, it is interpreted relative
 +to `user-emacs-directory'.
 +For best results, call this function in your early-init file,
 +so that the rest of initialization and package loading uses
 +the updated value."
 +  (let ((tmp-dir (and (equal (getenv "HOME") "/nonexistent")
 +                      (file-writable-p (expand-file-name
 +                                        (or temporary-file-directory "")))
 +                      (car native-comp-eln-load-path))))
 +    (if tmp-dir
 +        (setq native-comp-eln-load-path
 +              (cdr native-comp-eln-load-path)))
 +    ;; Remove the original eln-cache.
 +    (setq native-comp-eln-load-path
 +          (cdr native-comp-eln-load-path))
 +    ;; Add the new eln-cache.
 +    (push (expand-file-name (file-name-as-directory cache-directory)
 +                            user-emacs-directory)
 +          native-comp-eln-load-path)
 +    (when tmp-dir
 +      ;; Recompute tmp-dir, in case user-emacs-directory affects it.
 +      (setq tmp-dir (make-temp-file "emacs-testsuite-" t))
 +      (add-hook 'kill-emacs-hook (lambda () (delete-directory tmp-dir t)))
 +      (push tmp-dir native-comp-eln-load-path))))
 +
 +(defun startup--update-eln-cache ()
 +  "Update the user eln-cache directory due to user customizations."
 +  ;; Don't override user customizations!
 +  (when (equal native-comp-eln-load-path
 +               startup--original-eln-load-path)
 +    (startup-redirect-eln-cache "eln-cache")
 +    (setq startup--original-eln-load-path
 +          (copy-sequence native-comp-eln-load-path))))
 +
  (defun normal-top-level ()
    "Emacs calls this function when it first starts up.
  It sets `command-line-processed', processes the command-line,
@@@ -601,8 -540,16 +603,16 @@@ It is the default value of the variabl
      (setq user-emacs-directory
  	  (startup--xdg-or-homedot startup--xdg-config-home-emacs nil))
  
+     (unless (native-comp-available-p)
+       ;; Disable deferred async compilation and trampoline synthesis
+       ;; in this session.  This is necessary if libgccjit is not
+       ;; available on MS-Windows, but Emacs was built with
+       ;; native-compilation support.
+       (setq native-comp-deferred-compilation nil
+             comp-enable-subr-trampolines nil))
+ 
      (when (featurep 'native-compile)
 -      ;; Form `native-comp-eln-load-path'.
 +      ;; Form the initial value of `native-comp-eln-load-path'.
        (let ((path-env (getenv "EMACSNATIVELOADPATH")))
          (when path-env
            (dolist (path (split-string path-env path-separator))