Bug 151349 - [Patch] security/libgcrypt Fix build with Clang
Summary: [Patch] security/libgcrypt Fix build with Clang
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Koop Mast
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-09 21:50 UTC by Koop Mast
Modified: 2010-11-02 12:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Koop Mast freebsd_committer freebsd_triage 2010-10-09 21:50:03 UTC
	libgcrypt fails to build with clang. This is due to a inline problem
	This is because Gcc defaults to the gnu89 standard and clang to the 
	gnu99 standard. In these standards the inline keyword has different 
	meanings.

	The other build issue is that Clang doesn't like some of the asm
	casts in longlong.h, this patch was adapted from the longlong.h commit
	that want in head for revision 211505 and 211537.
	Submitted by:	Dimitry Andric <dim@FreeBSD.org>
	

	<how to correct or work around the problem, if known (multiple lines)>

--- libgcrypt-clang.diff begins here ---
Index: security/libgcrypt/Makefile
===================================================================
RCS file: /home/pcvs/ports/security/libgcrypt/Makefile,v
retrieving revision 1.44
diff -a -u -r1.44 Makefile
--- security/libgcrypt/Makefile	2 Aug 2009 19:35:29 -0000	1.44
+++ security/libgcrypt/Makefile	9 Oct 2010 20:30:43 -0000
@@ -17,6 +17,7 @@
 
 USE_BZIP2=	yes
 USE_AUTOTOOLS=	libtool:22
+USE_CSTD=	gnu89
 GNU_CONFIGURE=	yes
 CONFIGURE_ENV=	MAKEINFO="makeinfo --no-split"
 USE_LDCONFIG=	yes
Index: security/libgcrypt/files/patch-mpi-longlong.h
===================================================================
RCS file: security/libgcrypt/files/patch-mpi-longlong.h
diff -N security/libgcrypt/files/patch-mpi-longlong.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ security/libgcrypt/files/patch-mpi-longlong.h	9 Oct 2010 20:30:43 -0000
@@ -0,0 +1,42 @@
+--- mpi/longlong.h.org	2010-02-22 11:04:43.000000000 +0100
++++ mpi/longlong.h	2010-09-23 17:34:08.000000000 +0200
+@@ -437,8 +437,8 @@ extern USItype __udiv_qrnnd ();
+ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+   __asm__ ("addl %5,%1\n"                                               \
+ 	   "adcl %3,%0"                                                 \
+-	   : "=r" ((USItype)(sh)),                                      \
+-	     "=&r" ((USItype)(sl))                                      \
++	   : "=r" (sh),                                                 \
++	     "=&r" (sl)                                                 \
+ 	   : "%0" ((USItype)(ah)),                                      \
+ 	     "g" ((USItype)(bh)),                                       \
+ 	     "%1" ((USItype)(al)),                                      \
+@@ -446,22 +446,22 @@ extern USItype __udiv_qrnnd ();
+ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+   __asm__ ("subl %5,%1\n"                                               \
+ 	   "sbbl %3,%0"                                                 \
+-	   : "=r" ((USItype)(sh)),                                      \
+-	     "=&r" ((USItype)(sl))                                      \
++	   : "=r" (sh),                                                 \
++	     "=&r" (sl)                                                 \
+ 	   : "0" ((USItype)(ah)),                                       \
+ 	     "g" ((USItype)(bh)),                                       \
+ 	     "1" ((USItype)(al)),                                       \
+ 	     "g" ((USItype)(bl)))
+ #define umul_ppmm(w1, w0, u, v) \
+   __asm__ ("mull %3"                                                    \
+-	   : "=a" ((USItype)(w0)),                                      \
+-	     "=d" ((USItype)(w1))                                       \
++	   : "=a" (w0),                                                 \
++	     "=d" (w1)                                                  \
+ 	   : "%0" ((USItype)(u)),                                       \
+ 	     "rm" ((USItype)(v)))
+ #define udiv_qrnnd(q, r, n1, n0, d) \
+   __asm__ ("divl %4"                                                    \
+-	   : "=a" ((USItype)(q)),                                       \
+-	     "=d" ((USItype)(r))                                        \
++	   : "=a" (q),                                                  \
++	     "=d" (r)                                                   \
+ 	   : "0" ((USItype)(n0)),                                       \
+ 	     "1" ((USItype)(n1)),                                       \
+ 	     "rm" ((USItype)(d)))
--- libgcrypt-clang.diff ends here ---
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2010-10-09 21:50:12 UTC
Responsible Changed
From-To: freebsd-ports-bugs->kwm

Submitter has GNATS access (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2010-10-09 21:50:14 UTC
Maintainer of security/libgcrypt,

Please note that PR ports/151349 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/151349

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2010-10-09 21:50:16 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 Hirohisa Yamaguchi 2010-10-18 23:38:15 UTC
Hi,

Thanks for the patch.
I checkt it under FreeBSD 9.0-CURRENT/amd64 (as of 2010-10-12) with
> FreeBSD clang version 2.8 (tags/RELEASE_28 115870) 20101007
> Target: x86_64-undermydesk-freebsd9.0

USE_CSTD=3Dgnu89
seems to work okay here.

But, I don't see any difference with or without the patch against =
mpi/longlong.h.
Is it specific to a particular version of clang?

On 10/10/2010, at 5:50, Edwin Groothuis wrote:
> Please note that PR ports/151349 has just been submitted.
> The full text of the PR can be found at:
>    http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/151349

--=20

	Hirohisa Yamaguchi
	  <umq@ueo.co.jp>=
Comment 5 Koop Mast 2010-10-29 13:37:57 UTC
Hmm seems my reply didn't make it to GNATS, let me do a recap.

The mpi/longlong.h patch is needed for i386. 
Without this patch clang trows the error below. 

A similar patch was committed to head in the follow revision:
http://svn.freebsd.org/viewvc/base/head/contrib/gcc/longlong.h?r1=169690&r2=211537

Also the use of -fheinous-gnu-extensions is discouraged, because it might be gone without any notice.

-Koop
---------------------------------------------------------------------------
mpih-div.c:84:3: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build
      with -fheinous-gnu-extensions
                udiv_qrnnd(divisor_limb_inverted, dummy,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mpih-div.c:84:14: note: instantiated from:
                udiv_qrnnd(divisor_limb_inverted, dummy,
                           ^
Comment 6 Hirohisa Yamaguchi 2010-11-01 15:48:17 UTC
Hi,

On 10/19/2010, at 8:13, Koop Mast wrote:
>> But, I don't see any difference with or without the patch against
>> mpi/longlong.h.
>> Is it specific to a particular version of clang?
>=20
> No it doesn't have anything to do with clang version, it depends on =
the
> arch your building libgcrypt on. The longlong.h patch is needed for
> i386. When trying to compile libgcrypt on i386 without the patch clang
> will output the following (only the first few lines).

I got i386 box today, and got it.
I attach a patch with slight change in LICENSE block.

--=20

	Hirohisa Yamaguchi
	  <umq@ueo.co.jp>
=0C=0C=0C

diff -Npru ports.orig/security/libgcrypt/Makefile =
ports/security/libgcrypt/Makefile
--- ports.orig/security/libgcrypt/Makefile	2010-07-27 =
10:24:39.000000000 +0900
+++ ports/security/libgcrypt/Makefile	2010-11-01 23:21:16.000000000 =
+0900
@@ -15,10 +15,12 @@ COMMENT=3D	General purpose crypto library=20
=20
 LIB_DEPENDS=3D	gpg-error.0:${PORTSDIR}/security/libgpg-error
=20
-LICENSE=3D	GPLv2
-LICENSE_FILE=3D	${WRKSRC}/COPYING
+LICENSE=3D	GPLv2 LGPL21
+LICENSE_FILE=3D	${WRKSRC}/COPYING ${WRKSRC}/COPYING.LIB
+LICENSE_COMB=3D	multi
 USE_BZIP2=3D	yes
 USE_AUTOTOOLS=3D	libtool:22
+USE_CSTD=3D	gnu89
 GNU_CONFIGURE=3D	yes
 CONFIGURE_ENV=3D	MAKEINFO=3D"makeinfo --no-split"
 USE_LDCONFIG=3D	yes
diff -Npru ports.orig/security/libgcrypt/distinfo =
ports/security/libgcrypt/distinfo
--- ports.orig/security/libgcrypt/distinfo	2010-07-27 =
10:24:39.000000000 +0900
+++ ports/security/libgcrypt/distinfo	2010-11-01 23:21:16.000000000 =
+0900
@@ -1,3 +1,2 @@
-MD5 (libgcrypt-1.4.6.tar.bz2) =3D dbf99425a4fe9217c84ce3a35d938634
 SHA256 (libgcrypt-1.4.6.tar.bz2) =3D =
3e4b30da6b357b565333d0222133b64a0414be99ba72733081165c8ea9bc6b85
 SIZE (libgcrypt-1.4.6.tar.bz2) =3D 1151877
diff -Npru ports.orig/security/libgcrypt/files/patch-mpi-longlong.h =
ports/security/libgcrypt/files/patch-mpi-longlong.h
--- ports.orig/security/libgcrypt/files/patch-mpi-longlong.h	=
1970-01-01 09:00:00.000000000 +0900
+++ ports/security/libgcrypt/files/patch-mpi-longlong.h	2010-11-01 =
23:21:16.000000000 +0900
@@ -0,0 +1,42 @@
+--- ./mpi/longlong.h.orig	2010-02-22 19:04:43.000000000 +0900
++++ ./mpi/longlong.h	2010-11-01 18:25:34.000000000 +0900
+@@ -437,8 +437,8 @@
+ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+   __asm__ ("addl %5,%1\n"                                              =
 \
+ 	   "adcl %3,%0"                                                 =
\
+-	   : "=3Dr" ((USItype)(sh)),                                     =
 \
+-	     "=3D&r" ((USItype)(sl))                                     =
 \
++	   : "=3Dr" (sh),                                                =
 \
++	     "=3D&r" (sl)                                                =
 \
+ 	   : "%0" ((USItype)(ah)),                                      =
\
+ 	     "g" ((USItype)(bh)),                                       =
\
+ 	     "%1" ((USItype)(al)),                                      =
\
+@@ -446,22 +446,22 @@
+ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+   __asm__ ("subl %5,%1\n"                                              =
 \
+ 	   "sbbl %3,%0"                                                 =
\
+-	   : "=3Dr" ((USItype)(sh)),                                     =
 \
+-	     "=3D&r" ((USItype)(sl))                                     =
 \
++	   : "=3Dr" (sh),                                                =
 \
++	     "=3D&r" (sl)                                                =
 \
+ 	   : "0" ((USItype)(ah)),                                       =
\
+ 	     "g" ((USItype)(bh)),                                       =
\
+ 	     "1" ((USItype)(al)),                                       =
\
+ 	     "g" ((USItype)(bl)))
+ #define umul_ppmm(w1, w0, u, v) \
+   __asm__ ("mull %3"                                                   =
 \
+-	   : "=3Da" ((USItype)(w0)),                                     =
 \
+-	     "=3Dd" ((USItype)(w1))                                      =
 \
++	   : "=3Da" (w0),                                                =
 \
++	     "=3Dd" (w1)                                                 =
 \
+ 	   : "%0" ((USItype)(u)),                                       =
\
+ 	     "rm" ((USItype)(v)))
+ #define udiv_qrnnd(q, r, n1, n0, d) \
+   __asm__ ("divl %4"                                                   =
 \
+-	   : "=3Da" ((USItype)(q)),                                      =
 \
+-	     "=3Dd" ((USItype)(r))                                       =
 \
++	   : "=3Da" (q),                                                 =
 \
++	     "=3Dd" (r)                                                  =
 \
+ 	   : "0" ((USItype)(n0)),                                       =
\
+ 	     "1" ((USItype)(n1)),                                       =
\
+ 	     "rm" ((USItype)(d)))
Comment 7 Hirohisa Yamaguchi 2010-11-01 22:38:51 UTC
Hi,

At Tue, 2 Nov 2010 00:48:17 +0900,
Yamaguchi Hirohisa wrote:
> I attach a patch with slight change in LICENSE block.

The patch sent previously looks corrupted.
attaching it again.

-- 

	Hirohisa Yamaguchi
	  <umq@ueo.co.jp>

diff -Npru ports.orig/security/libgcrypt/Makefile ports/security/libgcrypt/Makefile
--- ports.orig/security/libgcrypt/Makefile	2010-07-27 10:24:39.000000000 +0900
+++ ports/security/libgcrypt/Makefile	2010-11-01 23:21:16.000000000 +0900
@@ -15,10 +15,12 @@ COMMENT=	General purpose crypto library 
 
 LIB_DEPENDS=	gpg-error.0:${PORTSDIR}/security/libgpg-error
 
-LICENSE=	GPLv2
-LICENSE_FILE=	${WRKSRC}/COPYING
+LICENSE=	GPLv2 LGPL21
+LICENSE_FILE=	${WRKSRC}/COPYING ${WRKSRC}/COPYING.LIB
+LICENSE_COMB=	multi
 USE_BZIP2=	yes
 USE_AUTOTOOLS=	libtool:22
+USE_CSTD=	gnu89
 GNU_CONFIGURE=	yes
 CONFIGURE_ENV=	MAKEINFO="makeinfo --no-split"
 USE_LDCONFIG=	yes
diff -Npru ports.orig/security/libgcrypt/distinfo ports/security/libgcrypt/distinfo
--- ports.orig/security/libgcrypt/distinfo	2010-07-27 10:24:39.000000000 +0900
+++ ports/security/libgcrypt/distinfo	2010-11-01 23:21:16.000000000 +0900
@@ -1,3 +1,2 @@
-MD5 (libgcrypt-1.4.6.tar.bz2) = dbf99425a4fe9217c84ce3a35d938634
 SHA256 (libgcrypt-1.4.6.tar.bz2) = 3e4b30da6b357b565333d0222133b64a0414be99ba72733081165c8ea9bc6b85
 SIZE (libgcrypt-1.4.6.tar.bz2) = 1151877
diff -Npru ports.orig/security/libgcrypt/files/patch-mpi-longlong.h ports/security/libgcrypt/files/patch-mpi-longlong.h
--- ports.orig/security/libgcrypt/files/patch-mpi-longlong.h	1970-01-01 09:00:00.000000000 +0900
+++ ports/security/libgcrypt/files/patch-mpi-longlong.h	2010-11-01 23:21:16.000000000 +0900
@@ -0,0 +1,42 @@
+--- ./mpi/longlong.h.orig	2010-02-22 19:04:43.000000000 +0900
++++ ./mpi/longlong.h	2010-11-01 18:25:34.000000000 +0900
+@@ -437,8 +437,8 @@
+ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+   __asm__ ("addl %5,%1\n"                                               \
+ 	   "adcl %3,%0"                                                 \
+-	   : "=r" ((USItype)(sh)),                                      \
+-	     "=&r" ((USItype)(sl))                                      \
++	   : "=r" (sh),                                                 \
++	     "=&r" (sl)                                                 \
+ 	   : "%0" ((USItype)(ah)),                                      \
+ 	     "g" ((USItype)(bh)),                                       \
+ 	     "%1" ((USItype)(al)),                                      \
+@@ -446,22 +446,22 @@
+ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+   __asm__ ("subl %5,%1\n"                                               \
+ 	   "sbbl %3,%0"                                                 \
+-	   : "=r" ((USItype)(sh)),                                      \
+-	     "=&r" ((USItype)(sl))                                      \
++	   : "=r" (sh),                                                 \
++	     "=&r" (sl)                                                 \
+ 	   : "0" ((USItype)(ah)),                                       \
+ 	     "g" ((USItype)(bh)),                                       \
+ 	     "1" ((USItype)(al)),                                       \
+ 	     "g" ((USItype)(bl)))
+ #define umul_ppmm(w1, w0, u, v) \
+   __asm__ ("mull %3"                                                    \
+-	   : "=a" ((USItype)(w0)),                                      \
+-	     "=d" ((USItype)(w1))                                       \
++	   : "=a" (w0),                                                 \
++	     "=d" (w1)                                                  \
+ 	   : "%0" ((USItype)(u)),                                       \
+ 	     "rm" ((USItype)(v)))
+ #define udiv_qrnnd(q, r, n1, n0, d) \
+   __asm__ ("divl %4"                                                    \
+-	   : "=a" ((USItype)(q)),                                       \
+-	     "=d" ((USItype)(r))                                        \
++	   : "=a" (q),                                                  \
++	     "=d" (r)                                                   \
+ 	   : "0" ((USItype)(n0)),                                       \
+ 	     "1" ((USItype)(n1)),                                       \
+ 	     "rm" ((USItype)(d)))
Comment 8 dfilter service freebsd_committer freebsd_triage 2010-11-02 12:19:00 UTC
kwm         2010-11-02 12:18:54 UTC

  FreeBSD ports repository

  Modified files:
    security/libgcrypt   Makefile distinfo 
  Added files:
    security/libgcrypt/files patch-mpi-longlong.h 
  Log:
  Fix linking with clang, and give longlong.h a simular treatment like was
  done in 9-current so clang can build it on i386.
  
  Update LICENSE block, and remove md5 sum.
  
  PR:             ports/151349
  Submitted by:   myself
  Approved by:    Yamaguchi Hirohisa <umq@ueo.co.jp> (maintainer)
  
  Revision  Changes    Path
  1.48      +4 -2      ports/security/libgcrypt/Makefile
  1.19      +0 -1      ports/security/libgcrypt/distinfo
  1.1       +42 -0     ports/security/libgcrypt/files/patch-mpi-longlong.h (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 9 Koop Mast freebsd_committer freebsd_triage 2010-11-02 12:19:09 UTC
State Changed
From-To: feedback->closed

Committed with your additions, Thanks! 

Sorry If I got your family and given name backwards. The two lastest replys, 
had them switched around. So I just took the last one.