[PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
authorBlake Jones <blakej@foo.net>
Mon, 5 Nov 2012 19:02:00 +0000 (11:02 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:21 +0000 (09:50 -0800)
26/ed8fb35d598f53c359675d66a6168ca89eeb2c [new file with mode: 0644]

diff --git a/26/ed8fb35d598f53c359675d66a6168ca89eeb2c b/26/ed8fb35d598f53c359675d66a6168ca89eeb2c
new file mode 100644 (file)
index 0000000..19e2bf6
--- /dev/null
@@ -0,0 +1,154 @@
+Return-Path: <blakej@foo.net>\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 61AEC431FC2\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Nov 2012 11:02:30 -0800 (PST)\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 2mUchTC1uyJi for <notmuch@notmuchmail.org>;\r
+       Mon,  5 Nov 2012 11:02:28 -0800 (PST)\r
+Received: from foo.net (70-36-235-136.dsl.static.sonic.net [70.36.235.136])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 280AD431FCF\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Nov 2012 11:02:25 -0800 (PST)\r
+Received: from foo.net (localhost [127.0.0.1])\r
+       by foo.net (8.14.5+Sun/8.14.5) with ESMTP id qA5J2NoJ019127;\r
+       Mon, 5 Nov 2012 11:02:23 -0800 (PST)\r
+Received: (from blakej@localhost)\r
+       by foo.net (8.14.5+Sun/8.14.5/Submit) id qA5J2NTm019126;\r
+       Mon, 5 Nov 2012 11:02:23 -0800 (PST)\r
+From: Blake Jones <blakej@foo.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output\r
+       (Solaris support)\r
+Date: Mon,  5 Nov 2012 11:02:00 -0800\r
+Message-Id: <1352142123-18286-8-git-send-email-blakej@foo.net>\r
+X-Mailer: git-send-email 1.7.3.2\r
+In-Reply-To: <1352142123-18286-1-git-send-email-blakej@foo.net>\r
+References: <1352142123-18286-1-git-send-email-blakej@foo.net>\r
+X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2\r
+       (foo.net [127.0.0.1]); Mon, 05 Nov 2012 11:02:23 -0800 (PST)\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, 05 Nov 2012 19:02:30 -0000\r
+\r
+The output of "nm" on Solaris is substantially different from that on\r
+Linux, and the current version of gen-version-script is tied to the\r
+Linux "nm" output.  This patch separates the parts of "nm" processing\r
+which are dependent on the output format into a couple shell functions,\r
+and makes another shell function to use the appropriate version of\r
+"c++filt" to demangle symbols.  It also modifies lib/Makefile.local\r
+to pass the generated symbol table correctly to the Solaris linker.\r
+---\r
+ lib/Makefile.local        |    4 +++\r
+ lib/gen-version-script.sh |   50 ++++++++++++++++++++++++++++++++++++++++----\r
+ 2 files changed, 49 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+index 0c6b258..2068e4a 100644\r
+--- a/lib/Makefile.local\r
++++ b/lib/Makefile.local\r
+@@ -30,7 +30,11 @@ LIBRARY_SUFFIX = so\r
+ LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)\r
+ SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)\r
+ LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)\r
++ifeq ($(PLATFORM),SOLARIS)\r
++LIBRARY_LINK_FLAG = -shared -Wl,-M notmuch.sym -Wl,-soname=$(SONAME) -Wl,--no-undefined -lc\r
++else\r
+ LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) -Wl,--no-undefined\r
++endif\r
+ ifeq ($(PLATFORM),OPENBSD)\r
+ LIBRARY_LINK_FLAG += -lc\r
+ endif\r
+diff --git a/lib/gen-version-script.sh b/lib/gen-version-script.sh\r
+index 76670d5..d7d96da 100644\r
+--- a/lib/gen-version-script.sh\r
++++ b/lib/gen-version-script.sh\r
+@@ -1,3 +1,4 @@\r
++#!/bin/sh\r
+ \r
+ # we go through a bit of work to get the unmangled names of the\r
+ # typeinfo symbols because of\r
+@@ -11,10 +12,44 @@ fi\r
+ HEADER=$1\r
+ shift\r
+ \r
++if [ `uname -s` == SunOS ] ; then\r
++    #\r
++    # Using Solaris "nm", a defined symbol looks like this:\r
++    #\r
++    # [Index]    Value    Size Type  Bind  Other Shndx   Name\r
++    # [15]    |    128|     16|FUNC |GLOB |0    |1      |notmuch_tags_get\r
++    #\r
++    # and an undefined symbol looks like this:\r
++    #\r
++    # [Index]    Value    Size Type  Bind  Other Shndx   Name\r
++    # [35]    |      0|      0|NOTY |GLOB |0    |UNDEF  |notmuch_tags_get\r
++    #\r
++    find_xapian_error() {\r
++      nawk -F'\|' '$7 !~ "UNDEF" && $8 ~ "Xapian.*Error" { print $8 }'\r
++    }\r
++    find_compat_syms() {\r
++      nawk -F'\|' '$7 !~ "UNDEF" && $8 ~ "get(line|delim)" { print $8 ";" }'\r
++    }\r
++    demangle() {\r
++      gc++filt "$@"\r
++    }\r
++else\r
++    find_xapian_error() {\r
++      awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $3 ~ "Xapian.*Error" {print $3}'\r
++    }\r
++    find_compat_syms() {\r
++      awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $2 == "T" && $3 ~ "^get(line|delim)$" {print $3 ";"}'\r
++    }\r
++    demangle() {\r
++      c++filt "$@"\r
++    }\r
++fi\r
++\r
+ printf '{\nglobal:\n'\r
+-nm  $* | awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $3 ~ "Xapian.*Error" {print $3}' | sort | uniq | \\r
+-while read sym; do\r
+-    demangled=$(c++filt $sym)\r
++\r
++# Find the typeinfo for "Xapian::*Error"s.\r
++nm $* | find_xapian_error | sort | uniq | while read sym; do\r
++    demangled=$(demangle $sym)\r
+     case $demangled in\r
+       typeinfo*) \r
+           printf "\t$sym;\n"\r
+@@ -23,6 +58,11 @@ while read sym; do\r
+           ;;\r
+     esac\r
+ done\r
+-nm $* | awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $2 == "T" && $3 ~ "^get(line|delim)$" {print $3 ";"}'\r
+-sed  -n 's/^[[:space:]]*\(notmuch_[a-z_]*\)[[:space:]]*(.*/ \1;/p' $HEADER\r
++\r
++# Find the "compat" syms that we need to export.\r
++nm $* | find_compat_syms\r
++\r
++# Finally, get the real notmuch symbols.\r
++sed -n 's/^[  ]*\(notmuch_[a-z_]*\)[  ]*(.*/ \1;/p' $HEADER\r
++\r
+ printf "local: *;\n};\n"\r
+-- \r
+1.7.3.2\r
+\r