all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44128@debbugs.gnu.org
Subject: bug#44128: bug#47800: [native-comp] could not resolve realpath of "emacs"
Date: Fri, 16 Apr 2021 17:41:52 +1200	[thread overview]
Message-ID: <88c1c243-2427-4917-f932-afdd7400279a@orcon.net.nz> (raw)
In-Reply-To: <83im4ny4a6.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2275 bytes --]

On 16/04/21 3:08 am, Eli Zaretskii wrote (on bug 47800):
> Does the untested patch below fix the problem?

That didn't change the outcomes for me.

I've just tried some very basic debugging with the attached patch
(yours plus some debug output) which gives me the following outputs:


$ cd /tmp

$ ls emacs
ls: cannot access 'emacs': No such file or directory


$ emacs --version
load_pdump_find_executable: candidate: /home/phil/bin/emacs
=> file: /home/phil/bin/emacs
=> (link) realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
load_pdump: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
real_filename( /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50 )
=> realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
set_invocation_vars: emacs
real_filename( emacs )
=> realpath: (null)
emacs: could not resolve realpath of "emacs": No such file or directory


$ mkdir emacs

$ emacs --version
load_pdump_find_executable: candidate: /home/phil/bin/emacs
=> file: /home/phil/bin/emacs
=> (link) realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
load_pdump: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
real_filename( /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50 )
=> realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
set_invocation_vars: emacs
real_filename( emacs )
=> realpath: /tmp/emacs
emacs: /tmp/../native-lisp/28.0.50-abd7aa58/preloaded/window-0d1b8b93-581f9fcd.eln: cannot open shared object file: No such file or directory


$ /home/phil/emacs/native-comp/usr/local/bin/emacs --version
load_pdump: /home/phil/emacs/native-comp/usr/local/bin/emacs
real_filename( /home/phil/emacs/native-comp/usr/local/bin/emacs )
=> realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
set_invocation_vars: /home/phil/emacs/native-comp/usr/local/bin/emacs
real_filename( /home/phil/emacs/native-comp/usr/local/bin/emacs )
=> realpath: /home/phil/emacs/native-comp/usr/local/bin/emacs-28.0.50
GNU Emacs 28.0.50
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.


[-- Attachment #2: bug47800.patch --]
[-- Type: text/x-patch, Size: 2212 bytes --]

diff --git a/src/emacs.c b/src/emacs.c
index a256564..0503504 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -446,6 +446,7 @@ terminate_due_to_signal (int sig, int backtrace_limit)
 static char *
 real_filename (char *filename)
 {
+  fprintf (stderr, "real_filename( %s )\n", filename);
   char *real_name;
 #ifdef WINDOWSNT
   /* w32_my_exename resolves symlinks internally, so no need to
@@ -453,6 +454,7 @@ real_filename (char *filename)
   real_name = xstrdup (filename);
 #else
   real_name = realpath (filename, NULL);
+  fprintf (stderr, "=> realpath: %s\n", real_name);
   if (!real_name)
     fatal ("could not resolve realpath of \"%s\": %s",
 	   filename, strerror (errno));
@@ -495,6 +497,7 @@ set_invocation_vars (char *argv0, char const *original_pwd)
   if (! NILP (handler))
     raw_name = concat2 (slash_colon, raw_name);
 
+  fprintf (stderr, "set_invocation_vars: %s\n", SSDATA (raw_name));
   char *filename = real_filename (SSDATA (raw_name));
   raw_name = build_unibyte_string (filename);
   xfree (filename);
@@ -843,10 +846,18 @@ load_pdump_find_executable (char const *argv0, ptrdiff_t *candidate_size)
       memcpy (candidate + 0, path_part, path_part_length);
       candidate[path_part_length] = DIRECTORY_SEP;
       memcpy (candidate + path_part_length + 1, argv0, argv0_length + 1);
+      fprintf (stderr, "load_pdump_find_executable: candidate: %s\n", candidate);
       struct stat st;
       if (file_access_p (candidate, X_OK)
 	  && stat (candidate, &st) == 0 && S_ISREG (st.st_mode))
-	return candidate;
+	{
+	  fprintf (stderr, "=> file: %s\n", candidate);
+	  if (lstat (candidate, &st) == 0 && S_ISLNK (st.st_mode)) {
+	    fprintf (stderr, "=> (link) realpath: %s\n", realpath (candidate, NULL));
+	    return realpath (candidate, NULL);
+	  }
+	  return candidate;
+	}
       *candidate = '\0';
     }
   while (*path++ != '\0');
@@ -912,6 +923,7 @@ load_pdump (int argc, char **argv, char const *original_pwd)
      the dump in the hardcoded location.  */
   if (dump_file && *dump_file)
     {
+      fprintf (stderr, "load_pdump: %s\n", dump_file);
       char *real_exename = real_filename (dump_file);
       xfree (dump_file);
       dump_file = real_exename;

  reply	other threads:[~2021-04-16  5:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 14:09 bug#47800: [native-comp] could not resolve realpath of "emacs" Dario Gjorgjevski
2021-04-15 14:17 ` Phil Sainty
2021-04-15 14:26   ` Dario Gjorgjevski
2021-04-15 15:08     ` Eli Zaretskii
2021-04-16  5:41       ` Phil Sainty [this message]
2021-04-16  6:41         ` bug#44128: #44128: [feature/native-comp] When invoking a symlink to the 'emacs' binary Emacs fails to start Eli Zaretskii
2021-04-16 11:18           ` Phil Sainty
2021-04-16  8:57       ` bug#47800: [native-comp] could not resolve realpath of "emacs" Dario Gjorgjevski
2021-04-16  9:08         ` Dario Gjorgjevski
2021-04-16  9:23           ` Dario Gjorgjevski
2021-04-16  9:27             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-16  9:37               ` Dario Gjorgjevski
2021-04-16 10:56               ` Phil Sainty
2021-04-16 11:32                 ` Phil Sainty
2021-04-16 12:32               ` Eli Zaretskii
2021-04-16 19:23                 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-16 19:38                   ` Eli Zaretskii
2021-04-16 20:07                     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-17  7:13                       ` Eli Zaretskii
2021-04-17  7:39                         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-17 14:16                   ` Eli Zaretskii
2021-04-15 14:44 ` Eli Zaretskii
2021-04-16  9:53 ` wilde
2021-04-17 14:00   ` Eli Zaretskii
2021-04-17 19:12     ` wilde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88c1c243-2427-4917-f932-afdd7400279a@orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=44128@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.