1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

* 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.
This commit is contained in:
Andrea Corallo 2020-09-19 10:27:41 +02:00
parent 5a8be1719a
commit 69c32e0187

View File

@ -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