From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: Finalizing 'inhibit-automatic-native-compilation' Date: Fri, 10 Feb 2023 16:53:59 +0000 Message-ID: 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> <87a61lkjb7.fsf@X570GP> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2427"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Eli Zaretskii , spwhitton@spwhitton.name, monnier@iro.umontreal.ca, emacs-devel@gnu.org, larsi@gnus.org, rlb@defaultvalue.org To: Aymeric Agon-Rambosson Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 10 17:54:53 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 1pQWfk-0000Uw-BQ for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Feb 2023 17:54:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQWf6-0001xG-Es; Fri, 10 Feb 2023 11:54:12 -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 1pQWf5-0001wz-36 for emacs-devel@gnu.org; Fri, 10 Feb 2023 11:54:11 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQWf2-00037r-Rg; Fri, 10 Feb 2023 11:54:10 -0500 Original-Received: from ma.sdf.org (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 31AGrxJW011567 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Fri, 10 Feb 2023 16:53:59 GMT In-Reply-To: <87a61lkjb7.fsf@X570GP> (Aymeric Agon-Rambosson's message of "Fri, 10 Feb 2023 09:37:16 +0100") Received-SPF: pass client-ip=205.166.94.24; envelope-from=akrl@sdf.org; helo=mx.sdf.org X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:303110 Archived-At: Aymeric Agon-Rambosson writes: > Le jeudi 9 f=C3=A9vrier 2023 =C3=A0 12:11, Eli Zaretskii a= =C3=A9crit > : > >>> 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-direc= tory)) > (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 > 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'). Unfortunatelly it is not, in posix to dynamically load code dlopen is used and a file is necessary. See DLOPEN(3) Best Regards Andrea