Subject: Re: bug#47558: 28.0.50; dlopen 'image not found' gccemacs native-lisp macos

From: Alan Third <[email-masked]>
Date: Sat, 3 Apr 2021 15:01:20 +0100

On Sat, Apr 03, 2021 at 09:32:20AM +0300, Eli Zaretskii wrote:
> > Date: Fri, 2 Apr 2021 22:51:56 +0100
> > From: Alan Third <[email-masked]>
> > Cc: [email-masked], [email-masked]
> > 
> > I think I've figured that out, but there's actually another wrinkle.
> > 'make install' is installing the eln files in
> > 
> >     nextstep/Emacs.app/Contents/MacOS/lib/emacs/28.0.50/native-lisp/28.0.50-24e3df15
> > 
> > but the emacs executable is looking for them in
> > 
> >     nextstep/Emacs.app/Contents/MacOS/../native-lisp/28.0.50-24e3df15/
> 
> The above happens on all platforms, so it isn't macOS specific, right?
> Or are you saying there's something macOS specific in ${libdir}?  in
> the latter case, what's the story there?

I think that is what happens on other platforms, but the issue here is
that the emacs executable is placed in an unusual position relative to
the other files because of the NS app bundle format. I'll try to
explain it below, but my knowledge is not deep.

> > And just to add the confusion I feel they should *actually* be
> > installed in
> > 
> >     nextstep/Emacs.app/Contents/Resources/native-lisp
> > 
> > or similar.
> 
> Why is that?

NS uses a special directory structure that appears to the system as an
application. It looks something like this:

Emacs.app
 + Contents
   + MacOS
   | + Emacs <-- The executable
   + Resources
   | + icons
   | + etc
   | + include
   | + info
   | + lisp
   | + ...
   + Info.plist
   + ...

The layout is ever so slightly different under GNUstep.

As far as I can tell the only thing that should be in the
Contents/MacOS directory are executables, practically everything else
lives under Resources.

nsterm.m has three functions for finding the correct path for etc,
exec and the lisp load path. I imagine what we want to do is install
the eln files under Resources, then add a new function that returns the
location of them and use it to set the correct path at the point where
Emacs loads the files.

It's not entirely clear to me where the load path is set, is it

    fixup_eln_load_path (Lisp_Object directory)

in comp.c?

-- 
Alan Third