Re: [PATCH] lib: fix clang build
authorJani Nikula <jani@nikula.org>
Sun, 18 Aug 2013 18:57:52 +0000 (21:57 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:27 +0000 (09:56 -0800)
24/3ec87824545a34b347e34ead406ce8b2c9a295 [new file with mode: 0644]

diff --git a/24/3ec87824545a34b347e34ead406ce8b2c9a295 b/24/3ec87824545a34b347e34ead406ce8b2c9a295
new file mode 100644 (file)
index 0000000..cef706c
--- /dev/null
@@ -0,0 +1,231 @@
+Return-Path: <jani@nikula.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 ECC5E429E59\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:58:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 ToFk+A7toAv9 for <notmuch@notmuchmail.org>;\r
+       Sun, 18 Aug 2013 11:57:55 -0700 (PDT)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 12169431FDB\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:57:54 -0700 (PDT)\r
+Received: by mail-bk0-f53.google.com with SMTP id d7so1205213bkh.12\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:57:53 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
+       :user-agent:date:message-id:mime-version:content-type;\r
+       bh=O/tTDsO9B3j/dlFKE7Dhqe0FUvBArLs2gjWiXh8JYTA=;\r
+       b=APpURbZIoXe9MJDnYNNk1p+mATSph2hQSNCgBNRa8Lgn1jHhM+CgKtf0bfMzJyxlUH\r
+       L1RkjAX0DHH47amfPUfAV3JXHfeBV/UaGquDpvPoYQoxOhH9m/LlR00lIEWgOFtoCVCU\r
+       b9D97Uuh5NVzL0HQBqLQ75D4fglIo1ZJrGS0xtP3CdyTRUgwQGyPkAU3GJSPQXzIf8nC\r
+       OtF03MLW6F9bHQe9nuPOA2lHA9eZEJpRbfCsdBK7ifdtx+9jB4w0h17j4VLdQnKG63oa\r
+       RIdI2h0W/S7vknI2NNfUZ7CFtBMr+PrcFQUKB4sygqMWFdpLQGdlEzLIy4qId6nc9xzK\r
+       7t6Q==\r
+X-Gm-Message-State:\r
+ ALoCoQmzxuV9WF2x2XKkPU9qsv7pUsrtf4ANfoThit/omK/Oul43iQ/ipBGOWKQ7zFAT8N/dlJ+F\r
+X-Received: by 10.204.62.201 with SMTP id y9mr1546025bkh.23.1376852273669;\r
+       Sun, 18 Aug 2013 11:57:53 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+       if11sm1085185bkc.15.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 18 Aug 2013 11:57:52 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] lib: fix clang build\r
+In-Reply-To: <m2txim7sjk.fsf@guru.guru-group.fi>\r
+References: <1376775001-16528-1-git-send-email-jani@nikula.org>\r
+       <m2txim7sjk.fsf@guru.guru-group.fi>\r
+User-Agent: Notmuch/0.15.2+227~g40b2846 (http://notmuchmail.org) Emacs/24.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sun, 18 Aug 2013 21:57:52 +0300\r
+Message-ID: <87r4dqesi7.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: Simonas Kazlauskas <s@kazlauskas.me>\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, 18 Aug 2013 18:58:01 -0000\r
+\r
+On Sun, 18 Aug 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+> On Sun, Aug 18 2013, Jani Nikula <jani@nikula.org> wrote:\r
+>\r
+>> Long story short, fix build on recent (3.2+) clang.\r
+>>\r
+>> The long story for posterity follows.\r
+>>\r
+>> gcc 4.6 added new warnings about structs with greater visibility than\r
+>> their fields. The warnings were silenced by adjusting visibility in\r
+>>\r
+>> commit d5523ead90b6be2b07d4af745b8ed9b980a6b9f1\r
+>> Author: Carl Worth <cworth@cworth.org>\r
+>> Date:   Wed May 11 13:23:13 2011 -0700\r
+>>\r
+>>     Mark some structures in the library interface with visibility=default attribute.\r
+>>\r
+>> Later on,\r
+>>\r
+>> commit 3b76adf9e2c026dd03b820f4c6eab50e25444113\r
+>> Author: Austin Clements <amdragon@MIT.EDU>\r
+>> Date:   Sat Jan 14 19:17:33 2012 -0500\r
+>>\r
+>>     lib: Add support for automatically excluding tags from queries\r
+>>\r
+>> changed visibility of struct _notmuch_string_list for the same reason, and\r
+>>\r
+>> commit 1a53f9f116fa7c460cda3df532be921baaafb082\r
+>> Author: Mark Walters <markwalters1009@gmail.com>\r
+>> Date:   Thu Mar 1 22:30:38 2012 +0000\r
+>>\r
+>>     lib: Add the exclude flag to notmuch_query_search_threads\r
+>>\r
+>> split the struct _notmuch_string_list and its typedef\r
+>> notmuch_string_list_t as a way to make a forward declaration for\r
+>> _notmuch_thread_create().\r
+>>\r
+>> The subtle difference was that the struct definition now had 'visible'\r
+>> in it, while the typedef didn't, and it was within the #pragma GCC\r
+>> visibility push(hidden) block. This went unnoticed, as the then common\r
+>> versions of clang didn't care about this.\r
+>>\r
+>> A later change in clang (I did not dig into when this change was\r
+>> introduced) caused the following error:\r
+>>\r
+>> CXX  -O2 lib/database.o\r
+>> In file included from lib/database.cc:21:\r
+>> In file included from ./lib/database-private.h:33:\r
+>> ./lib/notmuch-private.h:479:8: error: visibility does not match previous declaration\r
+>> struct visible _notmuch_string_list {\r
+>>        ^\r
+>> ./lib/notmuch-private.h:67:33: note: expanded from macro 'visible'\r
+>>                                 ^\r
+>> ./lib/notmuch-private.h:52:13: note: previous attribute is here\r
+>>             ^\r
+>> 1 error generated.\r
+>> make: *** [lib/database.o] Error 1\r
+>>\r
+>> This is slightly misleading due to the reference to the #pragma. The\r
+>> real culprit is the typedef within the #pragma.\r
+>>\r
+>> We could just add 'visible' to the typedef, or move the typedef\r
+>> outside of the #pragma, and be done with it, but juggle the\r
+>> declarations a bit to accommodate moving the typedef back with the\r
+>> struct, and keep the visibility attribute in one place.\r
+>>\r
+>> The problem was originally reported by Simonas Kazlauskas\r
+>> <s@kazlauskas.me> in id:20130418102507.GA23688@godbox but I was only\r
+>> able to reproduce and investigate now that I upgraded clang.\r
+>> ---\r
+>>  lib/notmuch-private.h |   28 +++++++++++++---------------\r
+>>  1 file changed, 13 insertions(+), 15 deletions(-)\r
+>>\r
+>> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+>> index eced03e..af185c7 100644\r
+>> --- a/lib/notmuch-private.h\r
+>> +++ b/lib/notmuch-private.h\r
+>> @@ -162,8 +162,6 @@ typedef enum _notmuch_find_flags {\r
+>>  \r
+>>  typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;\r
+>\r
+> Looks good to me (except log message is a bit excessive (?) maybe\r
+> it is reasonable to have it, though (TL;DR ;)...\r
+>>  \r
+>> -typedef struct _notmuch_string_list notmuch_string_list_t;\r
+>> -\r
+>\r
+> anyway, would\r
+>\r
+> typedef struct visible _notmuch_string_list notmuch_string_list_t;\r
+>\r
+> have helped here (if yes is your resolution nicer ?? :D )\r
+\r
+Yes, it would have. Read the commit message! :p\r
+\r
+Jani.\r
+\r
+\r
+>\r
+> Tomi\r
+>\r
+>\r
+>>  /* database.cc */\r
+>>  \r
+>>  /* Lookup a prefix value by name.\r
+>> @@ -228,17 +226,6 @@ _notmuch_directory_create (notmuch_database_t *notmuch,\r
+>>  unsigned int\r
+>>  _notmuch_directory_get_document_id (notmuch_directory_t *directory);\r
+>>  \r
+>> -/* thread.cc */\r
+>> -\r
+>> -notmuch_thread_t *\r
+>> -_notmuch_thread_create (void *ctx,\r
+>> -                   notmuch_database_t *notmuch,\r
+>> -                   unsigned int seed_doc_id,\r
+>> -                   notmuch_doc_id_set_t *match_set,\r
+>> -                   notmuch_string_list_t *excluded_terms,\r
+>> -                   notmuch_exclude_t omit_exclude,\r
+>> -                   notmuch_sort_t sort);\r
+>> -\r
+>>  /* message.cc */\r
+>>  \r
+>>  notmuch_message_t *\r
+>> @@ -476,11 +463,11 @@ typedef struct _notmuch_string_node {\r
+>>      struct _notmuch_string_node *next;\r
+>>  } notmuch_string_node_t;\r
+>>  \r
+>> -struct visible _notmuch_string_list {\r
+>> +typedef struct visible _notmuch_string_list {\r
+>>      int length;\r
+>>      notmuch_string_node_t *head;\r
+>>      notmuch_string_node_t **tail;\r
+>> -};\r
+>> +} notmuch_string_list_t;\r
+>>  \r
+>>  notmuch_string_list_t *\r
+>>  _notmuch_string_list_create (const void *ctx);\r
+>> @@ -509,6 +496,17 @@ notmuch_filenames_t *\r
+>>  _notmuch_filenames_create (const void *ctx,\r
+>>                        notmuch_string_list_t *list);\r
+>>  \r
+>> +/* thread.cc */\r
+>> +\r
+>> +notmuch_thread_t *\r
+>> +_notmuch_thread_create (void *ctx,\r
+>> +                   notmuch_database_t *notmuch,\r
+>> +                   unsigned int seed_doc_id,\r
+>> +                   notmuch_doc_id_set_t *match_set,\r
+>> +                   notmuch_string_list_t *excluded_terms,\r
+>> +                   notmuch_exclude_t omit_exclude,\r
+>> +                   notmuch_sort_t sort);\r
+>> +\r
+>>  NOTMUCH_END_DECLS\r
+>>  \r
+>>  #ifdef __cplusplus\r
+>> -- \r
+>> 1.7.10.4\r
+>>\r
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r