From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aymeric Agon-Rambosson Newsgroups: gmane.emacs.devel Subject: Re: Finalizing 'inhibit-automatic-native-compilation' Date: Fri, 10 Feb 2023 09:37:16 +0100 Message-ID: <87a61lkjb7.fsf@X570GP> References: <837cx8cey0.fsf@gnu.org> <837cx6a8me.fsf@gnu.org> <83357ua6ja.fsf@gnu.org> <83zga28ra8.fsf@gnu.org> <83r0vd97s0.fsf@gnu.org> <83lell73yv.fsf@gnu.org> <87sffo3as7.fsf@melete.silentflame.com> <83v8kkxzzx.fsf@gnu.org> <87r0v811pm.fsf@melete.silentflame.com> <87cz6nxdqy.fsf@X570GP> <83357irhnv.fsf@gnu.org> <87ttzy2lgi.fsf@X570GP> <83a61pprm8.fsf@gnu.org> <87mt5ncjuk.fsf@X570GP> <83cz6jm9mo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40356"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 28.1 Cc: spwhitton@spwhitton.name, monnier@iro.umontreal.ca, emacs-devel@gnu.org, akrl@sdf.org, larsi@gnus.org, rlb@defaultvalue.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 10 09:48:13 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQP4m-000AJQ-51 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Feb 2023 09:48:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQP4L-0003NH-8i; Fri, 10 Feb 2023 03:47:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQOuM-0007Bb-OC for emacs-devel@gnu.org; Fri, 10 Feb 2023 03:37:26 -0500 Original-Received: from forward500c.mail.yandex.net ([178.154.239.208]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQOuK-0005dc-6V; Fri, 10 Feb 2023 03:37:26 -0500 Original-Received: from sas1-7233446457c4.qloud-c.yandex.net (sas1-7233446457c4.qloud-c.yandex.net [IPv6:2a02:6b8:c14:260f:0:640:7233:4464]) by forward500c.mail.yandex.net (Yandex) with ESMTP id 5796A5F5B2; Fri, 10 Feb 2023 11:37:19 +0300 (MSK) Original-Received: by sas1-7233446457c4.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id Gba3r7AYn4Y1-83fkz6BX; Fri, 10 Feb 2023 11:37:18 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1676018238; bh=AflYRFjIpSjmqXS2Seo1H0QWwtMBTO8esQqKxs8NBUw=; h=Cc:Message-ID:References:Date:Subject:In-reply-to:To:From; b=BckiHTo1BTZlR2pTFO8f2xz6ft/vlXNeYhYLnzxVx16oifbHefsxFMqxgzW2aMmI3 ZIL2hABbrQJvnQ0MLsUBKG6puJOyXl04P8Ac5RHF4PAvB8qW8n2zJ9h9qvzFORBxuS ZHTuLIfhX5O6DDuFHGxzwuPIe52TgNn0PsWWAeEk= Authentication-Results: sas1-7233446457c4.qloud-c.yandex.net; dkim=pass header.i=@yandex.com In-reply-to: <83cz6jm9mo.fsf@gnu.org> Received-SPF: pass client-ip=178.154.239.208; envelope-from=aymeric.agon@yandex.com; helo=forward500c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 Feb 2023 03:47:43 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303103 Archived-At: Le jeudi 9 f=C3=A9vrier 2023 =C3=A0 12:11, Eli Zaretskii a=20 =C3=A9crit : >> Would it possible to add a constant value, like=20 >> 'compile-but-no-output, that would have exactly the second=20 >> behaviour I was mentioning before, that is compiling=20 >> trampolines=20 >> but not even trying to output them anywhere, by passing nil as=20 >> the=20 >> last argument of `comp--native-compile' ? > > Argh, the last argument to comp--native-compile is not=20 > documented. > AFAIR, setting it to nil means the trampoline will be written to > temporary-file-directory, right? Because I don't think we can=20 > compile > a trampoline without writing it to some file, from which we will > thereafter load it. (Andrea, please correct me if I'm wrong.)=20 > If so, > we could assume Lisp programs will use temporary-file-directory=20 > if > they need this, would that be good enough? I'm asking this because this is already what=20 `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=20 ABI of ;; the primitive we are replacing in the function reloc=20 table. (form `(lambda ,lambda-list (let ((f #',subr-name)) (,(if (memq '&rest lambda-list) #'apply=20 '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=20 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=20 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=20 comp-native-version-dir native-compile-target-direct= ory)) (comp-eln-load-path-eff)) for f =3D (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=20 in \ `native-comp-eln-load-path'")))))) The line : (unless inhibit-automatic-native-compilation Could be replaced with : (unless (equal comp-enable-subr-trampolines=20 'compile-but-no-output) To the same effect (the current effect of=20 `inhibit-automatic-native-compilation', with which we haven't had=20 issues so far). As a side note, Lars' comment seems to say that it is completely=20 possible to attach a trampoline to a primitive without saving said=20 trampoline anywhere (not even in `temporary-file-directory'). This is supported by the fact the *optional* outputting of the=20 trampoline to the file system is done by the function=20 `comp--native-compile', with last argument set to a filename,=20 while the association of this trampoline with the primitive is=20 done by the (primitive) function `comp--trampoline-install'. So=20 these two actions (outputting and attaching) are independent. I completely agree that the last argument of=20 `comp--native-compile' could be documented, particularly what=20 exactly happens when it is set to nil. Best, Aymeric