From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bhavin Gandhi Newsgroups: gmane.emacs.bugs Subject: bug#52488: Try basename of agrv0's realpath for .pdmp lookup in libexecdir Date: Wed, 15 Dec 2021 00:31:02 +0530 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000052096905d31fd116" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22099"; mail-complaints-to="usenet@ciao.gmane.io" To: 52488@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 14 20:02:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1mxD3z-0005WB-S6 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Dec 2021 20:02:11 +0100 Original-Received: from localhost ([::1]:50478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxD3y-0006YK-9v for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Dec 2021 14:02:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxD3q-0006Y7-Qj for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 14:02:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxD3q-0001ut-Ht for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 14:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mxD3q-0004kM-9g for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 14:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Bhavin Gandhi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Dec 2021 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52488 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163950850118209 (code B ref -1); Tue, 14 Dec 2021 19:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Dec 2021 19:01:41 +0000 Original-Received: from localhost ([127.0.0.1]:59604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxD3U-0004jc-Q1 for submit@debbugs.gnu.org; Tue, 14 Dec 2021 14:01:41 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:52070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxD3R-0004jT-R0 for submit@debbugs.gnu.org; Tue, 14 Dec 2021 14:01:38 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxD3R-0006Uu-KF for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 14:01:37 -0500 Original-Received: from [2607:f8b0:4864:20::b35] (port=33733 helo=mail-yb1-xb35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxD3P-0001rL-8c for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 14:01:37 -0500 Original-Received: by mail-yb1-xb35.google.com with SMTP id d10so48856255ybn.0 for ; Tue, 14 Dec 2021 11:01:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=gYsaT8OgNmS+l9FfF3TTWRu6tiprI04XYJfjiXLOUso=; b=fProEFKF2C56IdbrDwKYEfHYjbuI3EnkmOsVQvF75+xKzPIyBMCCzJ3Mi4IAB0Huoi Pt0Ba5cRPP1e3rUt0jF0dfoLXzqW7qo9n/+jRCnzFv5kTDFQFZEy9uuPDb6Bgrak06r9 L9SOmiyS2sCTkdcpbgsou9qUqZ+FaGzGTUQc3opwIEHknOfW4G1iyqDXHZeFgQQoiEW5 WHYUNIzDDs4bhNlT3fj/c+ky+CYDxzjoEdf06KZR46U6PZ/vaZWvA41SoWuACOa0RBqt NJc7tU+A5U2LiE7XeEXixTDNTsDHKarWNl4vRQ5v5Dr+jhau4K95AllozHZOxTZUlYWI 8CHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gYsaT8OgNmS+l9FfF3TTWRu6tiprI04XYJfjiXLOUso=; b=dQv4gXHQ8KhoW2MHRLugue4AZc8/gcn7f/c1hjQsFNg5AHuegq1fvxzEr9is2tkyTu YQCHvMV5DZYqDNS29auYrrNRgbNYPyb6j0Ot/Zh7y8+yNJo/SRSHP/HLCsqDG6LTvSl4 d1Z6cEuFrg/Mt/M6qhXGjhsLsZoCYI51inx+BklMx8jrCp6HlGB7OCWgj8CZaTwpT90V tgc9FOOaDtkiUWiDZNu4wvmTNYZaBaKFV6Iptlsm8j8UGZWLTwVWEz/Qq5MrfQcGPOys H1m6G4jaGjVBbUdpYDPO0r9QHtrgDz5vaDQBNEOmQKmZe9D1dI0EJ+UO4k1WQGlICDiE es2Q== X-Gm-Message-State: AOAM532KweGpeitYkMdUKBjvAeKbgnfg0bjD4NrJssPowrnlyX0/rqjp O9huUCdm2xfwVajlovOME2Z8oaLOREVRLmX88n8FwiDtgof96A== X-Google-Smtp-Source: ABdhPJwu+Elq8U3ggaRgq8xCe+4xq0C0G6j/RKAmMwfElm7VsSnNFCanjw5SZyP5tveQHNNSRHjY2N5a208F60R+6qQ= X-Received: by 2002:a25:1f02:: with SMTP id f2mr903449ybf.714.1639508492813; Tue, 14 Dec 2021 11:01:32 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::b35 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::b35; envelope-from=bhavin7392@gmail.com; helo=mail-yb1-xb35.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222387 Archived-At: --00000000000052096905d31fd116 Content-Type: text/plain; charset="UTF-8" Referring to this message https://debbugs.gnu.org/52376#86 it is advised to keep the .pdmp file in the libexecdir instead of putting it along side the Emacs executable. Currently the load_pdump from emacs.c first looks for a .pdmp file in the same directory where Emacs executable is present. While doing that it calls load_pdump_find_executable, which tries to resolve symlinks and finds the real name of the binary being invoked. Then this name is used to find the .pdmp file. /* If the executable name contains a slash, we have some kind of path already, so just resolve symlinks and return the result. */ /* People put on PATH a symlink to the real Emacs executable, with all the auxiliary files where the real executable lives. Support that. */ IIUC when searching for the .pdmp file in the libexecdir (path_exec), it uses argv0 and does not find the actual binary name by resolving symlinks. /* Finally, look for basename(argv0)+".pdmp" in PATH_EXEC. This way, they can rename both the executable and its pdump file in PATH_EXEC, and have several Emacs configurations in the same versioned libexec subdirectory. */ Why do you want that? As the comment from load_pdump_find_executable explains, there are setups where the /usr/bin/emacs is a symlink managed by something like alternatives. This symlink eventually points to an Emacs binary like emacs-28.0.90. These kind of setups are used to have installation of multiple versions of Emacs on the same system. Supporting resolution of these symlinks while searching for a .pdmp file will make it possible to put the .pdmp files in libexecdir instead of putting those in the /usr/bin/. I think this should be in addition to the possibilities tried currently. > Why don't you configure each Emacs build with a different libexecdir > instead? Sure, but there are some common files in that directory like hexl, movemail, etc, which package maintainers have put into a common package like emacs-common. How to reproduce? Install Emacs using make install on your system with correct libexecdir (it is /usr/libexec/ in my case). This will create a symlink /usr/bin/emacs which points to /usr/bin/emacs-28.0.90. Now rename the .pdmp file with: $ sudo mv /usr/libexec/emacs/28.0.90/x86_64-linux-gnu/{emacs.pdmp,emacs-28.0.90.pdmp} Now start Emacs: $ emacs -Q Loading loadup.el (source)... Dump mode: nil Using load-path (/usr/share/emacs/28.0.90/lisp /usr/share/emacs/28.0.90/lisp/emacs-lisp /usr/share/emacs/28.0.90/lisp/progmodes /usr/share/emacs/28.0.90/lisp/language /usr/share/emacs/28.0.90/lisp/international /usr/share/emacs/28.0.90/lisp/textmodes /usr/share/emacs/28.0.90/lisp/vc) Loading emacs-lisp/byte-run... Symbol's function definition is void: file-name-sans-extension Note that the Emacs build above is created with --with-native-compilation. I'm not sure if this bug's severity is wishlist or not, so I'm not setting it right now. --00000000000052096905d31fd116 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Referring to this message https://debbugs.gnu.org/52376#86 it is advised
to keep = the .pdmp file in the libexecdir instead of putting it along
side the Em= acs executable.

Currently the load_pdump from emacs.c first looks fo= r a .pdmp file in
the same directory where Emacs executable is present. = While doing that
it calls load_pdump_find_executable, which tries to res= olve symlinks and
finds the real name of the binary being invoked. Then = this name is used
to find the .pdmp file.

=C2=A0 /* If the execu= table name contains a slash, we have some kind of
=C2=A0 =C2=A0 =C2=A0pa= th already, so just resolve symlinks and return the result. =C2=A0*/
=C2=A0/* People put on PATH a symlink to the real Emacs
=C2=A0 =C2= =A0 executable, with all the auxiliary files where the real
=C2=A0 =C2= =A0 executable lives.=C2=A0 Support that. =C2=A0*/


IIUC when sea= rching for the .pdmp file in the libexecdir (path_exec), it
uses argv0 a= nd does not find the actual binary name by resolving
symlinks.

= =C2=A0 =C2=A0 =C2=A0 /* Finally, look for basename(argv0)+".pdmp"= in PATH_EXEC.
This way, they can rename both the executable and its p= dump
file in PATH_EXEC, and have several Emacs configurations in
= the same versioned libexec subdirectory. =C2=A0*/


Why do you wan= t that?

As the comment from load_pdump_find_executable explains, the= re are
setups where the /usr/bin/emacs is a symlink managed by something= like
alternatives. This symlink eventually points to an Emacs binary li= ke
emacs-28.0.90. These kind of setups are used to have installation of<= br>multiple versions of Emacs on the same system.

Supporting resolut= ion of these symlinks while searching for a .pdmp file
will make it poss= ible to put the .pdmp files in libexecdir instead of
putting those in th= e /usr/bin/. I think this should be in addition to
the possibilities tri= ed currently.

> Why don't you configure each Emacs build with= a different libexecdir
> instead?

Sure, but there are some co= mmon files in that directory like hexl,
movemail, etc, which package mai= ntainers have put into a common package
like emacs-common.

How to= reproduce?

Install Emacs using make install on your system with cor= rect libexecdir
(it is /usr/libexec/ in my case). This will create a sym= link
/usr/bin/emacs which points to /usr/bin/emacs-28.0.90.

Now r= ename the .pdmp file with:

$ sudo mv /usr/libexec/emacs/28.0.90/x86_= 64-linux-gnu/{emacs.pdmp,emacs-28.0.90.pdmp}

Now start Emacs:
$ emacs -Q
Loading loadup.el (source)...
Dump mode: nil
Using loa= d-path (/usr/share/emacs/28.0.90/lisp /usr/share/emacs/28.0.90/lisp/emacs-l= isp /usr/share/emacs/28.0.90/lisp/progmodes /usr/share/emacs/28.0.90/lisp/l= anguage /usr/share/emacs/28.0.90/lisp/international /usr/share/emacs/28.0.9= 0/lisp/textmodes /usr/share/emacs/28.0.90/lisp/vc)
Loading emacs-lisp/by= te-run...
Symbol's function definition is void: file-name-sans-exten= sion

Note that the Emacs build above is created with
--with-nativ= e-compilation.

I'm not sure if this bug's severity is wishli= st or not, so I'm not setting
it right now.
--00000000000052096905d31fd116--