Re: [PATCH 2/3] build: fix DSO dependencies
authorFelipe Contreras <felipe.contreras@gmail.com>
Fri, 29 Oct 2010 23:17:18 +0000 (02:17 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:20 +0000 (09:37 -0800)
c5/637092c8e7d70cd65e1c27976ec9b0a6e403b6 [new file with mode: 0644]

diff --git a/c5/637092c8e7d70cd65e1c27976ec9b0a6e403b6 b/c5/637092c8e7d70cd65e1c27976ec9b0a6e403b6
new file mode 100644 (file)
index 0000000..19e8c8d
--- /dev/null
@@ -0,0 +1,144 @@
+Return-Path: <felipe.contreras@gmail.com>\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 D5E6E40D16C\r
+       for <notmuch@notmuchmail.org>; Fri, 29 Oct 2010 16:18:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.999\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+       DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001]\r
+       autolearn=ham\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 OEbgUecQ3P3Q for <notmuch@notmuchmail.org>;\r
+       Fri, 29 Oct 2010 16:17:50 -0700 (PDT)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53])\r
+       by olra.theworths.org (Postfix) with ESMTP id AC61E40D16F\r
+       for <notmuch@notmuchmail.org>; Fri, 29 Oct 2010 16:17:19 -0700 (PDT)\r
+Received: by bwz7 with SMTP id 7so3484576bwz.26\r
+       for <notmuch@notmuchmail.org>; Fri, 29 Oct 2010 16:17:18 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:mime-version:received:received:in-reply-to\r
+       :references:date:message-id:subject:from:to:cc:content-type\r
+       :content-transfer-encoding;\r
+       bh=F1kdWlxasvvdrehEY0MoemlOMf80bkxp5w3Aqe7Fa0w=;\r
+       b=Cm4Jtu8xSqlTb1R1G0jmlqUxAHmi6bgJATGt68FIi1YZPEB6S0sCXtE9S/PcgfFuUm\r
+       gjoHxgCbSOYONgErBMX7Yo50BZTNAPrcnUj/vAiENNd9wIsgJK/rt+ClzjdS5fT0soq4\r
+       IY8LnmmJiubkG8jYSkDtuP2yY+Onh7CKSu0dg=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
+       :cc:content-type:content-transfer-encoding;\r
+       b=LaiGQ5TFiRkO72QSpC7C+Yj31p27/KMtKXduKRjcdlscFviBplj/leVEUnJbPSLChs\r
+       uGucvHFy93i3fh/MsnXSbWTGvhdb+yJqL3Wu0fEoPxps3TPR+KdKaKY+TB+4vZp15qPG\r
+       nMUgPd34+0VTJMKYkLPy1RtG2DdJ4IHb/279A=\r
+MIME-Version: 1.0\r
+Received: by 10.204.46.33 with SMTP id h33mr10516656bkf.95.1288394238663; Fri,\r
+       29 Oct 2010 16:17:18 -0700 (PDT)\r
+Received: by 10.204.58.204 with HTTP; Fri, 29 Oct 2010 16:17:18 -0700 (PDT)\r
+In-Reply-To: <87pqus65pv.fsf@yoom.home.cworth.org>\r
+References: <1275735915-22650-1-git-send-email-felipe.contreras@gmail.com>\r
+       <1275735915-22650-3-git-send-email-felipe.contreras@gmail.com>\r
+       <87pqus65pv.fsf@yoom.home.cworth.org>\r
+Date: Sat, 30 Oct 2010 02:17:18 +0300\r
+Message-ID: <AANLkTi=iMwf7tMs6C7EFb7ZMhHFfXsZvqA2SovUOsGZW@mail.gmail.com>\r
+Subject: Re: [PATCH 2/3] build: fix DSO dependencies\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: Carl Worth <cworth@cworth.org>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\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: Fri, 29 Oct 2010 23:18:01 -0000\r
+\r
+Hello,\r
+\r
+On Sat, Oct 30, 2010 at 12:37 AM, Carl Worth <cworth@cworth.org> wrote:\r
+> On Sat, =C2=A05 Jun 2010 14:05:14 +0300, Felipe Contreras <felipe.contrer=\r
+as@gmail.com> wrote:\r
+>> At least on Fedora 13, this doesn't link; the linker finds the\r
+>> dependencies, and aborts saying we should include them.\r
+> ...\r
+>> We do need to link at least to what we really use, the linker resolves\r
+>> the dependencies of our dependencies at loading time. So let's only\r
+>> specify what we use directly.\r
+>\r
+> You're certainly right that the linking was bogus. The notmuch binary\r
+> was only linking directly against libnotmuch (which in turned linked\r
+> against GMime, Xapian, and talloc). But meanwhile, the notmuch binary\r
+> is also directly using GMime and talloc so should be linking directly\r
+> against those.\r
+>\r
+>> -ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)\r
+>> =C2=A0FINAL_NOTMUCH_LDFLAGS +=3D $(CONFIGURE_LDFLAGS)\r
+>> -FINAL_NOTMUCH_LINKER =3D CXX\r
+>> -endif\r
+>\r
+> But the change above causes the notmuch binary to also link directly\r
+> against Xapian, (which the binary does not use directly), so that's\r
+> undesired.\r
+\r
+Yes, I wanted to fix that in subsequent patches, but my first\r
+objective was to get it to build.\r
+\r
+>> - =C2=A0 =C2=A0 gmime_ldflags=3D$(pkg-config --libs $gmimepc)\r
+>> + =C2=A0 =C2=A0 if [ $linker_resolves_library_dependencies =3D "1" ]; th=\r
+en\r
+>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gmime_ldflags=3D"-lgmime-2.6=\r
+ -lgobject-2.0 -lglib-2.0"\r
+>> + =C2=A0 =C2=A0 else\r
+>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gmime_ldflags=3D$(pkg-config=\r
+ --libs $gmimepc)\r
+>> + =C2=A0 =C2=A0 fi\r
+>\r
+> This part I don't understand. Why is it necessary to avoid using\r
+> pkg-config in this case? That sounds to me like a maintenance\r
+> nightmare. If the pkg-config information for GMime is wrong then we\r
+> should get that fixed, and not workaround it.\r
+\r
+Well, it's not possible: pkg-config is supposed to work on win32 and\r
+osx, so all the dependencies must be there, so:\r
+\r
+% pkg-config --libs gmime-2.6\r
+-pthread -lgmime-2.6 -lgio-2.0 -lgobject-2.0 -lgmodule-2.0\r
+-lgthread-2.0 -lrt -lglib-2.0\r
+\r
+Means we would be linking to many libraries we are not going to use directl=\r
+y.\r
+\r
+Fortunately, I found the solution after writing that patch:\r
+-Wl,--as-needed. With this the linker would automatically figure out\r
+that we actually want to link only to -lgmime-2.6 -lgobject-2.0\r
+-lglib-2.0.\r
+\r
+> So, finally, I implemented a much more narrow fix for the linking\r
+> problem, (simply adding $(GMIME_LDFLAGS) and $(TALLOC_LDFLAGS) to the\r
+> FINAL_NOTMUCH_LDFLAGS assignement).\r
+>\r
+> I tested this by installing binutils-gold on my Debian system. This\r
+> caused a compilation failure before my patch, but compilation succeeds\r
+> after my patch. I'm optimistic that this means that a Fedora compilation\r
+> will work as well now. Can you test that please?\r
+\r
+Patch #1 is not needed if gmime_ldflags in patch #2 are not changed\r
+conditionally, which can be achieved by --as-needed.\r
+\r
+I just sent my proposed updated patches.\r
+\r
+--=20\r
+Felipe Contreras\r