[PATCH] lib: make notmuch shared library install_name be full path on Mac OS X
authorJ. Lewis Muir <jlmuir@imca-cat.org>
Mon, 1 Sep 2014 03:13:47 +0000 (22:13 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:21 +0000 (10:04 -0800)
47/98c1b80c7438c1c2d78edfce6d7614d09d1454 [new file with mode: 0644]

diff --git a/47/98c1b80c7438c1c2d78edfce6d7614d09d1454 b/47/98c1b80c7438c1c2d78edfce6d7614d09d1454
new file mode 100644 (file)
index 0000000..288ba61
--- /dev/null
@@ -0,0 +1,167 @@
+Return-Path: <jlmuir@imca-cat.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 58946431FBF\r
+       for <notmuch@notmuchmail.org>; Sun, 31 Aug 2014 20:14:38 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id isOzsMot1If9 for <notmuch@notmuchmail.org>;\r
+       Sun, 31 Aug 2014 20:14:30 -0700 (PDT)\r
+Received: from tuna.imca.aps.anl.gov (tuna.imca.aps.anl.gov [164.54.200.33])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4A650431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 31 Aug 2014 20:14:30 -0700 (PDT)\r
+Received: from localhost (seal.imca.aps.anl.gov [164.54.200.39])\r
+       by tuna.imca.aps.anl.gov (Postfix) with ESMTP id DFE3F2004B;\r
+       Sun, 31 Aug 2014 22:14:29 -0500 (CDT)\r
+From: "J. Lewis Muir" <jlmuir@imca-cat.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] lib: make notmuch shared library install_name be full path on\r
+       Mac OS X\r
+Date: Sun, 31 Aug 2014 22:13:47 -0500\r
+Message-Id: <1409541227-38895-1-git-send-email-jlmuir@imca-cat.org>\r
+X-Mailer: git-send-email 1.8.5.2 (Apple Git-48)\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 01 Sep 2014 03:14:38 -0000\r
+\r
+The install_name of libnotmuch.dylib on Mac OS X is what is written\r
+into a program that links against it.  If it is just the name of the\r
+shared library file, as opposed to the full path, the program won't be\r
+able to find it when it runs and will abort.  Instead, the install_name\r
+should be the full path to the shared library (in its final installed\r
+location).\r
+\r
+An example on Mac OS X Mavericks (10.9.4) follows.\r
+\r
+We configure, build, and install notmuch, assuming the user has write\r
+access to /opt:\r
+\r
+===\r
+$ CFLAGS='-I/pkg/include' LDFLAGS='-L/pkg/lib' ./configure \\r
+      --prefix=/opt/notmuch-current --without-emacs\r
+$ make\r
+$ make install\r
+===\r
+\r
+We inspect the installed notmuch library using the otool system program:\r
+\r
+===\r
+$ otool -L /opt/notmuch-current/lib/libnotmuch.dylib\r
+/opt/notmuch-current/lib/libnotmuch.dylib:\r
+  libnotmuch.3.dylib \\r
+(compatibility version 3.1.0, current version 3.1.0)\r
+  /pkg/lib/libgmime-2.4.2.dylib \\r
+(compatibility version 7.0.0, current version 7.33.0)\r
+  /pkg/lib/libgobject-2.0.0.dylib \\r
+(compatibility version 3801.0.0, current version 3801.2.0)\r
+  /pkg/lib/libglib-2.0.0.dylib \\r
+(compatibility version 3801.0.0, current version 3801.2.0)\r
+  /pkg/lib/libintl.8.dylib \\r
+(compatibility version 10.0.0, current version 10.2.0)\r
+  /pkg/lib/libtalloc.2.1.1.dylib \\r
+(compatibility version 0.0.0, current version 0.0.0)\r
+  /pkg/lib/libz.1.dylib \\r
+(compatibility version 2.0.0, current version 2.2.0)\r
+  /pkg/lib/libxapian.22.dylib \\r
+(compatibility version 29.0.0, current version 29.4.0)\r
+  /usr/lib/libc++.1.dylib \\r
+(compatibility version 1.0.0, current version 120.0.0)\r
+  /usr/lib/libSystem.B.dylib \\r
+(compatibility version 1.0.0, current version 1197.1.1)\r
+===\r
+\r
+That's not good.  The second line shows the install_name, and it's not a\r
+full path, so any program that links against it as a dependent library\r
+will not be able to find it.\r
+\r
+We try running the notmuch program (which is linked against the notmuch\r
+library), and, sure enough, it aborts:\r
+\r
+===\r
+$ /opt/notmuch-current/bin/notmuch --version\r
+dyld: Library not loaded: libnotmuch.3.dylib\r
+  Referenced from: /opt/notmuch-current/bin/notmuch\r
+  Reason: image not found\r
+Trace/BPT trap: 5\r
+===\r
+\r
+After applying this commit to fix the problem and configuring, building,\r
+and installing again as above, the notmuch library's install_name is now\r
+the correct full path:\r
+\r
+===\r
+$ otool -L /opt/notmuch-current/lib/libnotmuch.dylib\r
+/opt/notmuch-current/lib/libnotmuch.dylib:\r
+  /opt/notmuch-current/lib/libnotmuch.3.dylib \\r
+(compatibility version 3.1.0, current version 3.1.0)\r
+  /pkg/lib/libgmime-2.4.2.dylib \\r
+(compatibility version 7.0.0, current version 7.33.0)\r
+  /pkg/lib/libgobject-2.0.0.dylib \\r
+(compatibility version 3801.0.0, current version 3801.2.0)\r
+  /pkg/lib/libglib-2.0.0.dylib \\r
+(compatibility version 3801.0.0, current version 3801.2.0)\r
+  /pkg/lib/libintl.8.dylib \\r
+(compatibility version 10.0.0, current version 10.2.0)\r
+  /pkg/lib/libtalloc.2.1.1.dylib \\r
+(compatibility version 0.0.0, current version 0.0.0)\r
+  /pkg/lib/libz.1.dylib \\r
+(compatibility version 2.0.0, current version 2.2.0)\r
+  /pkg/lib/libxapian.22.dylib \\r
+(compatibility version 29.0.0, current version 29.4.0)\r
+  /usr/lib/libc++.1.dylib \\r
+(compatibility version 1.0.0, current version 120.0.0)\r
+  /usr/lib/libSystem.B.dylib \\r
+(compatibility version 1.0.0, current version 1197.1.1)\r
+===\r
+\r
+And the notmuch program is able to find the notmuch library when run:\r
+\r
+===\r
+$ /opt/notmuch-current/bin/notmuch --version\r
+notmuch 0.18.1+84~g658a00e\r
+===\r
+\r
+References:\r
+\r
+* http://www.finkproject.org/doc/porting/porting.en.html#\\r
+shared.build-lib\r
+\r
+* https://developer.apple.com/library/mac/documentation/DeveloperTools/\\r
+Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html\r
+---\r
+ lib/Makefile.local | 2 +-\r
+ 1 file changed, 1 insertion(+), 1 deletion(-)\r
+\r
+diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+index c56cba9..c83f387 100644\r
+--- a/lib/Makefile.local\r
++++ b/lib/Makefile.local\r
+@@ -27,7 +27,7 @@ LIBRARY_SUFFIX = dylib\r
+ LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)\r
+ SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)\r
+ LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)\r
+-LIBRARY_LINK_FLAG = -dynamiclib -install_name $(SONAME) -compatibility_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR) -current_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)\r
++LIBRARY_LINK_FLAG = -dynamiclib -install_name $(libdir)/$(SONAME) -compatibility_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR) -current_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)\r
+ else\r
+ LIBRARY_SUFFIX = so\r
+ LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)\r
+-- \r
+1.8.5.2 (Apple Git-48)\r
+\r