Subject: bug#44128: [feature/native-comp]

From: Phil Sainty <[email-masked]>
Date: Fri, 16 Apr 2021 00:12:57 +1200

On 15/04/21 6:52 pm, Eli Zaretskii wrote:>> $ emacs-native-comp -Q
>> emacs: could not resolve realpath of "emacs-native-comp": No such file or directory
>
> Where in the Emacs sources does this message come from, please?
Looks like real_filename() in emacs.c:

/* Return the real filename following symlinks in case.
   The caller should deallocate the returned buffer.  */

static char *
real_filename (char *filename)
{
  char *real_name;
#ifdef WINDOWSNT
  /* w32_my_exename resolves symlinks internally, so no need to
     call realpath.  */
  real_name = xstrdup (filename);
#else
  real_name = realpath (filename, NULL);
  if (!real_name)
    fatal ("could not resolve realpath of \"%s\": %s",
	   filename, strerror (errno));
#endif
  return real_name;
}

> What happens if you invoke it via a full absolute file name,
> not relying on PATH?

That still works.

> What happens if you call the symlink 'emacs' and not
> 'emacs-native-comp'?

Curious things.  It doesn't work, and it apparently gets confused
by the 'emacs' directory in my HOME directory too.

$ hash emacs

$ alias emacs
bash: alias: emacs: not found

$ command -v emacs
/home/phil/bin/emacs

$ ls -lad `command -v emacs`
lrwxrwxrwx 1 phil phil 48 Apr 15 23:51 /home/phil/bin/emacs -> /home/phil/emacs/native-comp/usr/local/bin/emacs

$ pwd
/home/phil

$ ls -lad emacs
drwxrwxr-x 25 phil phil 4096 Mar 28 23:30 emacs

$ emacs --version
emacs: /home/phil/../native-lisp/28.0.50-abd7aa58/preloaded/window-0d1b8b93-581f9fcd.eln: cannot open shared object file: No such file or directory

$ cd ..

$ pwd
/home

$ emacs --version
emacs: could not resolve realpath of "emacs": No such file or directory

$ /home/phil/emacs/native-comp/usr/local/bin/emacs --version
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.

$ cd /home/phil/emacs/native-comp/usr/local/bin/

$ emacs --version
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.

$ /home/phil/emacs/native-comp/usr/local/bin/emacs -Q --batch --eval "(message \"%s %s\" emacs-repository-branch emacs-repository-version)"
feature/native-comp bfaa6df492c85d7de007cf69316cbdeea653d703

$ git log -3 bfaa6df492c85d7de007cf69316cbdeea653d703
commit bfaa6df492c85d7de007cf69316cbdeea653d703 (HEAD -> feature/native-comp, origin/feature/native-comp)
Author: Andrea Corallo <[email-masked]>
Date:   Wed Apr 14 20:00:04 2021 +0200

    * configure.ac: Fix native-comp FreeBSD build.

commit 95dd6bb08038e31515568943dcfae13afac8ff70
Author: Eli Zaretskii <[email-masked]>
Date:   Wed Apr 14 17:28:19 2021 +0300

    Fix MS-Windows build following last change

    * src/emacs.c (real_filename) [WINDOWSNT]: Fix off-by-one error
    when allocating storage for a file name.

commit 0c1fc9d581ad64efc96c1efccbb4d057796ef807
Author: Andrea Corallo <[email-masked]>
Date:   Wed Apr 14 15:04:19 2021 +0200

    * Fix native-comp startup for symliked binary (bug#44128)

            * src/emacs.c (real_filename): New function.
            (set_invocation_vars, load_pdump): Make use of.