[PATCH 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
authorBlake Jones <blakej@foo.net>
Sun, 4 Nov 2012 03:15:59 +0000 (20:15 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:17 +0000 (09:50 -0800)
df/9d80c5cac3a6a2f08f5e4101ac1e7ea7cffef1 [new file with mode: 0644]

diff --git a/df/9d80c5cac3a6a2f08f5e4101ac1e7ea7cffef1 b/df/9d80c5cac3a6a2f08f5e4101ac1e7ea7cffef1
new file mode 100644 (file)
index 0000000..5af695f
--- /dev/null
@@ -0,0 +1,156 @@
+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 30154431FD2\r
+       for <notmuch@notmuchmail.org>; Sat,  3 Nov 2012 20:24:21 -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 qRwXGBUsvogE for <notmuch@notmuchmail.org>;\r
+       Sat,  3 Nov 2012 20:24:20 -0700 (PDT)\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 171BF431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  3 Nov 2012 20:24:20 -0700 (PDT)\r
+Received: from foo.net (localhost [127.0.0.1])\r
+       by foo.net (8.14.5+Sun/8.14.5) with ESMTP id qA43GGa3025693;\r
+       Sat, 3 Nov 2012 20:16:16 -0700 (PDT)\r
+Received: (from blakej@localhost)\r
+       by foo.net (8.14.5+Sun/8.14.5/Submit) id qA43GGQx025692;\r
+       Sat, 3 Nov 2012 20:16:16 -0700 (PDT)\r
+From: Blake Jones <blakej@foo.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 07/10] gen-version-script: parse Solaris "nm" output (Solaris\r
+       support)\r
+Date: Sat,  3 Nov 2012 20:15:59 -0700\r
+Message-Id: <1351998962-25135-8-git-send-email-blakej@foo.net>\r
+X-Mailer: git-send-email 1.7.3.2\r
+In-Reply-To: <1351998962-25135-1-git-send-email-blakej@foo.net>\r
+References: <1351998962-25135-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]); Sat, 03 Nov 2012 20:16:16 -0700 (PDT)\r
+X-Mailman-Approved-At: Sun, 04 Nov 2012 01:30:19 -0800\r
+Cc: Blake Jones <blakej@foo.net>\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: Sun, 04 Nov 2012 03:24:21 -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.9.2\r
+\r