[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finalizing 'inhibit-automatic-native-compilation'
From: |
Aymeric Agon-Rambosson |
Subject: |
Re: Finalizing 'inhibit-automatic-native-compilation' |
Date: |
Fri, 10 Feb 2023 09:37:16 +0100 |
User-agent: |
mu4e 1.6.10; emacs 28.1 |
Le jeudi 9 février 2023 à 12:11, Eli Zaretskii <eliz@gnu.org> a
écrit :
Would it possible to add a constant value, like
'compile-but-no-output, that would have exactly the second
behaviour I was mentioning before, that is compiling
trampolines
but not even trying to output them anywhere, by passing nil as
the
last argument of `comp--native-compile' ?
Argh, the last argument to comp--native-compile is not
documented.
AFAIR, setting it to nil means the trampoline will be written to
temporary-file-directory, right? Because I don't think we can
compile
a trampoline without writing it to some file, from which we will
thereafter load it. (Andrea, please correct me if I'm wrong.)
If so,
we could assume Lisp programs will use temporary-file-directory
if
they need this, would that be good enough?
I'm asking this because this is already what
`inhibit-automatic-native-compilation' does :
(defun comp-trampoline-compile (subr-name)
"Synthesize compile and return a trampoline for SUBR-NAME."
(let* ((lambda-list (comp-make-lambda-list-from-subr
(symbol-function subr-name)))
;; The synthesized trampoline must expose the exact same
ABI of
;; the primitive we are replacing in the function reloc
table.
(form `(lambda ,lambda-list
(let ((f #',subr-name))
(,(if (memq '&rest lambda-list) #'apply
'funcall)
f
,@(cl-loop
for arg in lambda-list
unless (memq arg '(&optional &rest))
collect arg)))))
;; Use speed 1 for compilation speed and not to optimize
away
;; funcall calls!
(byte-optimize nil)
(native-comp-speed 1)
(lexical-binding t))
(comp--native-compile
form nil
;; If we've disabled nativecomp, don't write the trampolines
to
;; the eln cache (but create them).
(unless inhibit-automatic-native-compilation
(cl-loop
for dir in (if native-compile-target-directory
(list (expand-file-name
comp-native-version-dir
native-compile-target-directory))
(comp-eln-load-path-eff))
for f = (expand-file-name
(comp-trampoline-filename subr-name)
dir)
unless (file-exists-p dir)
do (ignore-errors
(make-directory dir t)
(cl-return f))
when (file-writable-p f)
do (cl-return f)
finally (error "Cannot find suitable directory for output
in \
`native-comp-eln-load-path'"))))))
The line :
(unless inhibit-automatic-native-compilation
Could be replaced with :
(unless (equal comp-enable-subr-trampolines
'compile-but-no-output)
To the same effect (the current effect of
`inhibit-automatic-native-compilation', with which we haven't had
issues so far).
As a side note, Lars' comment seems to say that it is completely
possible to attach a trampoline to a primitive without saving said
trampoline anywhere (not even in `temporary-file-directory').
This is supported by the fact the *optional* outputting of the
trampoline to the file system is done by the function
`comp--native-compile', with last argument set to a filename,
while the association of this trampoline with the primitive is
done by the (primitive) function `comp--trampoline-install'. So
these two actions (outputting and attaching) are independent.
I completely agree that the last argument of
`comp--native-compile' could be documented, particularly what
exactly happens when it is set to nil.
Best,
Aymeric
- Re: Finalizing 'inhibit-automatic-native-compilation', (continued)
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/02
- Re: Finalizing 'inhibit-automatic-native-compilation', Sean Whitton, 2023/02/02
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/06
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/06
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/07
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/07
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/09
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/09
- Re: Finalizing 'inhibit-automatic-native-compilation', Sean Whitton, 2023/02/09
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/10
- Re: Finalizing 'inhibit-automatic-native-compilation',
Aymeric Agon-Rambosson <=
- Re: Finalizing 'inhibit-automatic-native-compilation', Andrea Corallo, 2023/02/10
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/10
- Re: Finalizing 'inhibit-automatic-native-compilation', Andrea Corallo, 2023/02/11
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/11
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/11
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/12
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/12
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/12
- Re: Finalizing 'inhibit-automatic-native-compilation', Eli Zaretskii, 2023/02/12
- Re: Finalizing 'inhibit-automatic-native-compilation', Aymeric Agon-Rambosson, 2023/02/14