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: Tue, 07 Feb 2023 13:56:00 +0000 Message-ID: References: <837cx8cey0.fsf@gnu.org> <83357vauh5.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> 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="2753"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Sean Whitton , Eli Zaretskii , 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 Tue Feb 07 14:57:03 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 1pPOSv-0000PW-4E for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Feb 2023 14:56:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPOSJ-0007X7-7u; Tue, 07 Feb 2023 08:56:19 -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 1pPOSH-0007Wh-H0 for emacs-devel@gnu.org; Tue, 07 Feb 2023 08:56:17 -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 1pPOSF-0000dV-2P; Tue, 07 Feb 2023 08:56:17 -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 317Du0C8012350 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Tue, 7 Feb 2023 13:56:01 GMT In-Reply-To: <87cz6nxdqy.fsf@X570GP> (Aymeric Agon-Rambosson's message of "Mon, 06 Feb 2023 11:57:41 +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:303035 Archived-At: Aymeric Agon-Rambosson writes: > Hello everyone, and sorry for my being late. > > Le jeudi 2 f=C3=A9vrier 2023 =C3=A0 09:17, Sean Whitton > a =C3=A9crit : > >> Aymeric, you investigated one of these cases in details. Would you >> be >> able to summarise the situation we had in Debian for Eli, please? > > The case Sean refers to is probably the packaging of projectile > (https://github.com/bbatsov/projectile). > > In the testbed of this package, the buttercup library > (https://github.com/jorgenschaefer/emacs-buttercup) is used to advise > some primitives, like `file-exists-p', `insert-file-contents', > `file-directory-p' and probably others. These primitives can be > advised so as to be replaced by a function that does nothing, or that > always returns a specific value, etc... > > The following test was interesting : > > (describe "projectile-parse-dirconfig-file" > (it "parses dirconfig and returns directories to ignore and keep" > (spy-on 'file-exists-p :and-return-value t) > (spy-on 'file-truename :and-call-fake (lambda (filename) > filename)) > (spy-on 'insert-file-contents :and-call-fake > (lambda (filename) > (save-excursion (insert > "\n-exclude\n+include\n#may-be-a-comment\nno-prefix\n > left-wspace\nright-wspace\t\n")))) > (expect (projectile-parse-dirconfig-file) :to-equal > '(("include/") > ("exclude" > "#may-be-a-comment" > "no-prefix" > "left-wspace" > "right-wspace") > nil)) > ;; same test - but with comment lines enabled using prefix '#' > (let ((projectile-dirconfig-comment-prefix ?#)) > (expect (projectile-parse-dirconfig-file) :to-equal > '(("include/") > ("exclude" > "no-prefix" > "left-wspace" > "right-wspace") > nil))) > )) > > The primitive `file-exists-p' is advised as to always return t, > whether the argument corresponds to an existing file or not. If we > assume the trampoline is not already there (and that is the case in > our build environment), a trampoline compilation is triggered, and > exits without error. The advice is effective only after that. > > Then `file-truename' is advised, but it is not a primitive. > > Then `insert-file-contents' is advised as well, it is a primitive. We > enter the function `comp-subr-trampoline-install', and we begin by > checking whether the corresponding trampoline already exists by > entering the function `comp-trampoline-search'. This function relies > on `file-exists-p', which answers that the file corresponding to the > compiled trampoline exists, even if it doesn't. Hence we enter > `native-elisp-load' with a filename that doesn't exist as argument, > and we error out : > > comp-subr-trampoline-install(insert-file-contents) > comp-trampoline-search(insert-file-contents) > native-elisp-load("/tmp/buttercupKuLmvD/28.2-4001e2a9/subr--trampoline-69= 6... > error: (native-lisp-load-failed "file does not exists" > "/tmp/buttercupKuLmvD/28.2-4001e2a9/subr--trampoline-696e736572742d66696c= 652d636f6e74656e7473_insert_file_contents_0.eln") > > We always get the error because the trampoline is never there > beforehand, and upstream did not get it precisely because it was lucky > to always have it before running the test. If we have to load *any* > trampoline after the advice of `file-exists-p' is effective, and we're > not lucky enough to already have the trampoline, then we reach the > error. Advising primitives is a dangerous action, it can lead the Emacs machinery to malfunction anytime, these misbehaviors are not documented and can change from version to version as from configuration to configuration. The programmer who advises or redefines a primitive should be ready to understand the underlying machinery and work out potential issues (as it was done in this case). I don't think this is a native comp specific problem, I'm sure one can find similar examples also on non native comp enabled Emacses. Best Regards Andrea