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

From: Alan Third <[email-masked]>
Date: Mon, 5 Apr 2021 22:14:02 +0100

On Mon, Apr 05, 2021 at 08:21:25PM +0000, Andrea Corallo wrote:
> Alan Third <[email-masked]> writes:
> 
> > On Sun, Apr 04, 2021 at 07:10:50AM +0000, Andrea Corallo wrote:
> >> Eli Zaretskii <[email-masked]> writes:
> >> 
> >> >> Date: Sat, 3 Apr 2021 15:01:20 +0100
> >> >> From: Alan Third <[email-masked]>
> >> >> Cc: [email-masked], [email-masked]
> >> >> 
> >> >> 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?
> >> >
> >> > I hope Andrea (CC'ed) will be able to answer that.
> >> 
> >> Okay, as window is loaded and dumped during the build
> >> `comp-eln-load-path' here doesn't come into play.
> >> 
> >> While resurrecting from dump we locate preloaded eln files by filename
> >> (relative to the emacs executable position).  Indeed the complication is
> >> that we have to support both uninstalled but also installed builds.
> >> 
> >> To do that before dumping we inform Emacs of where will have to search
> >> the eln files if installed.  We do that using ELN_DESTDIR defined
> >> Makefile.in:326.
> >> 
> >> If the directory structure on MacOS is different I guess we have to add
> >> the correct information there.
> >
> > No matter what I set ELN_DESTDIR to, emacs still looks in
> >
> > /Users/alan/src/emacs/native/nextstep/Emacs.app/Contents/MacOS/../native-lisp/28.0.50-24e3df15
> >
> > so something isn't being updated, I guess?
> 
> That's possible, could you specify the full procedure you've used to
> reach this point?

./autogen.sh
./configure --with-ns --with-native-compilation
make
make install

Note: make install fails, I've had to apply this patch

@@ -749,7 +753,8 @@ install-etc:
 ### Install native compiled Lisp files.
 install-eln:
 ifeq ($(HAVE_NATIVE_COMP),yes)
-	find native-lisp -type f -exec ${INSTALL_DATA} -D "{}" "$(ELN_DESTDIR){}" \;
+	find native-lisp -type d -exec $(MKDIR_P) "$(ELN_DESTDIR){}" \; ; \
+	find native-lisp -type f -exec ${INSTALL_DATA} "{}" "$(ELN_DESTDIR){}" \;
 endif

but if you were to try this with GNUstep I suspect that wouldn't be
needed.

And I've tried modifying ELN_DESTDIR with this

@@ -323,7 +323,11 @@ CONFIG_STATUS_FILES_IN =
 COPYDIR = ${srcdir}/etc ${srcdir}/lisp
 COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
 
-ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/
+ifeq (${ns_self_contained},no)
+  ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/
+else
+  ELN_DESTDIR = ${ns_appresdir}/
+endif
 
 all: ${SUBDIR} info

which results in the .eln files being installed where I want, but
running the installed Emacs (nextstep/Emacs.app/MacOS/Emacs) still
gives the error

emacs:
dlopen(/Users/alan/src/emacs/native/nextstep/Emacs.app/Contents/MacOS/../native-lisp/28.0.50-24e3df15/window-0d1b8b93-513ac8ca.eln,
1): image not found

-- 
Alan Third