Re: [PATCH] lib: make notmuch shared library install_name be full path on Mac OS X

Subject: Re: [PATCH] lib: make notmuch shared library install_name be full path on Mac OS X

Date: Thu, 26 Feb 2015 12:14:23 -0600

To: David Bremner

Cc: notmuch@notmuchmail.org

From: J. Lewis Muir


On 2/25/15 1:34 AM, David Bremner wrote:
> Unfortunately we did not receive any feedback from Mac users in the
> meantime. It would be nice to know that your patch won't break the
> existing macports and brew packages.  I suppose that those work
> because they install the libraries into a well known location.

Hi, David.

I just tried installing to /usr/local (now on OS X Yosemite 10.10.2),
and you're right about that; it appears that because it's a standard
location, it works without my patch.  Looking at the dyld(1) man page,
it says the following for the DYLD_FALLBACK_LIBRARY_PATH environment
variable (and I think the fact that /usr/local/lib is in the default
list is the reason why it works without the patch):

  This is a colon separated list of directories that contain
  libraries.  It is used as the default location for libraries
  not found in their install path.  By default, it is set to
  $(HOME)/lib:/usr/local/lib:/lib:/usr/lib.

However, if I install to /opt, it does *not* work without my patch.  So,
I'm still confident that the patch is correct and needed.

The reason it works in Homebrew is twofold.  One, assuming Homebrew
installs packages to /usr/local, the dynamic linker finds the notmuch
library in /usr/local/lib because it's in the default list of locations
that the dynamic linker looks for libraries.  Two, Homebrew globally
corrects all install names in dynamically shared libraries and binaries
for all packages.  So, even if the package is broken, Homebrew corrects
it automatically, and no one ever knows.

The reason it works in MacPorts is because they apply a patch that's the
same as what I submitted!  See:

  https://trac.macports.org/browser/trunk/dports/mail/notmuch/files/patch-lib-Makefile.local.diff

For any OS X notmuch developer willing to test this, here are
the five commands to run to reproduce the problem (note: another
libnotmuch*.dylib must *not* be in /usr/local/lib where it would
be found automatically by the dynamic linker; similarly, no DYLD_*
environment variables should be set for this test; obviously, change the
CFLAGS and LDFLAGS environment variables in the ./configure command to
point to where the libraries are that notmuch needs):

===
$ git clone git://notmuchmail.org/git/notmuch
$ CFLAGS='-I/pkg/include' LDFLAGS='-L/pkg/lib' ./configure --prefix=/opt --without-emacs
$ make
$ make install
$ /opt/bin/notmuch --version
===

When I run the just-installed notmuch in that last command, it produces
the following output:

===
dyld: Library not loaded: libnotmuch.4.dylib
  Referenced from: /opt/bin/notmuch
  Reason: image not found
Trace/BPT trap: 5 (core dumped)
===

Regards,

Lewis

Thread: