diff options
author | Andrea Corallo <akrl@sdf.org> | 2020-09-19 10:27:41 +0200 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2020-09-21 21:46:07 +0200 |
commit | 69c32e01875f33ba1cc4ad37d0940375cd0c6e27 (patch) | |
tree | a0a13425813f61508d138aa42700c198974b2939 /lisp/emacs-lisp | |
parent | 5a8be1719a80031ea3833749b1e82de8d5a39787 (diff) | |
download | emacs-69c32e01875f33ba1cc4ad37d0940375cd0c6e27.tar.gz emacs-69c32e01875f33ba1cc4ad37d0940375cd0c6e27.tar.bz2 emacs-69c32e01875f33ba1cc4ad37d0940375cd0c6e27.zip |
* Sandbox syncronous libgccjit invocation on interactive sessions
Avoid unnecessary memory fragmentation/leakeage
* lisp/emacs-lisp/comp.el (comp-final1): New function.
(comp-final): Invoke `comp-final1' in a child process if in an
interactive session or directly otherwhise.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 25e2de9d5d2..4795d2fc07e 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -2475,8 +2475,7 @@ Prepare every function for final compilation and drive the C back-end." (unless comp-dry-run (comp--compile-ctxt-to-file name)))) -(defun comp-final (_) - "Final pass driving the C back-end for code emission." +(defun comp-final1 () (let (compile-result) (comp--init-ctxt) (unwind-protect @@ -2485,6 +2484,45 @@ Prepare every function for final compilation and drive the C back-end." (and (comp--release-ctxt) compile-result)))) +(defun comp-final (_) + "Final pass driving the C back-end for code emission." + (if noninteractive + (comp-final1) + ;; Call comp-final1 in a child process. + (let* ((output (comp-ctxt-output comp-ctxt)) + (print-escape-newlines t) + (print-length nil) + (print-level nil) + (print-quoted t) + (print-gensym t) + (print-circle t) + (expr `(progn + (require 'comp) + (setf comp-speed ,comp-speed + comp-debug ,comp-debug + comp-verbose ,comp-verbose + comp-ctxt ,comp-ctxt + comp-eln-load-path ',comp-eln-load-path + comp-native-driver-options + ',comp-native-driver-options + load-path ',load-path) + ,comp-async-env-modifier-form + (message "Compiling %s..." ',output) + (comp-final1))) + (temp-file (make-temp-file + (concat "emacs-int-comp-" + (file-name-base output) "-") + nil ".el"))) + (with-temp-file temp-file + (insert (prin1-to-string expr))) + (with-temp-buffer + (if (zerop + (call-process (expand-file-name invocation-name + invocation-directory) + nil t t "--batch" "-l" temp-file)) + output + (signal 'native-compiler-error (buffer-string))))))) + ;;; Compiler type hints. ;; Public entry points to be used by user code to give comp |