From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1246594-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 9D4101382C5
	for <garchives@archives.gentoo.org>; Fri, 29 Jan 2021 20:46:00 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B1A65E09DA;
	Fri, 29 Jan 2021 20:45:59 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 81006E09DA
	for <gentoo-commits@lists.gentoo.org>; Fri, 29 Jan 2021 20:45:59 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 486813404A5
	for <gentoo-commits@lists.gentoo.org>; Fri, 29 Jan 2021 20:45:58 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id A21B14AA
	for <gentoo-commits@lists.gentoo.org>; Fri, 29 Jan 2021 20:45:56 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1611953150.c31ae3b3a3df3277b878f88de17d508bde370aee.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/libgcrypt/files/, dev-libs/libgcrypt/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-libs/libgcrypt/files/libgcrypt-1.9.1-fix-no-asm-on-amd64-x86.patch dev-libs/libgcrypt/libgcrypt-1.9.1-r1.ebuild dev-libs/libgcrypt/libgcrypt-1.9.1.ebuild
X-VCS-Directories: dev-libs/libgcrypt/files/ dev-libs/libgcrypt/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: c31ae3b3a3df3277b878f88de17d508bde370aee
X-VCS-Branch: master
Date: Fri, 29 Jan 2021 20:45:56 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 17f95e3b-4c16-4698-aa28-f1dbce89b766
X-Archives-Hash: 7951e72423a462001114317c9f7e956c

commit:     c31ae3b3a3df3277b878f88de17d508bde370aee
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 29 20:43:14 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 29 20:45:50 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c31ae3b3

dev-libs/libgcrypt: fix USE=-asm build

Closes: https://bugs.gentoo.org/767859
Package-Manager: Portage-3.0.14, Repoman-3.0.2
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../libgcrypt-1.9.1-fix-no-asm-on-amd64-x86.patch  | 141 +++++++++++++++++++++
 ...rypt-1.9.1.ebuild => libgcrypt-1.9.1-r1.ebuild} |   1 +
 2 files changed, 142 insertions(+)

diff --git a/dev-libs/libgcrypt/files/libgcrypt-1.9.1-fix-no-asm-on-amd64-x86.patch b/dev-libs/libgcrypt/files/libgcrypt-1.9.1-fix-no-asm-on-amd64-x86.patch
new file mode 100644
index 00000000000..875c2237008
--- /dev/null
+++ b/dev-libs/libgcrypt/files/libgcrypt-1.9.1-fix-no-asm-on-amd64-x86.patch
@@ -0,0 +1,141 @@
+Broken in https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=8d404a629167d67ed56e45de3e65d1e0b7cdeb24;hp=3b34bd6e178614d6021ee7d1140646f7c8ed7519
+https://dev.gnupg.org/T5277
+https://bugs.gentoo.org/767859
+
+This is a revert of that commit, as suggested by upstream in the linked bug.
+diff --git a/random/rand-internal.h b/random/rand-internal.h
+index 34221569..d99c6671 100644
+--- a/random/rand-internal.h
++++ b/random/rand-internal.h
+@@ -141,7 +141,7 @@ void _gcry_rndhw_poll_fast (void (*add)(const void*, size_t,
+                             enum random_origins origin);
+ size_t _gcry_rndhw_poll_slow (void (*add)(const void*, size_t,
+                                           enum random_origins),
+-                              enum random_origins origin, size_t req_length);
++                              enum random_origins origin);
+ 
+ 
+ 
+diff --git a/random/rndhw.c b/random/rndhw.c
+index 3cf9acc3..2829382c 100644
+--- a/random/rndhw.c
++++ b/random/rndhw.c
+@@ -198,33 +198,24 @@ _gcry_rndhw_poll_fast (void (*add)(const void*, size_t, enum random_origins),
+ 
+ 
+ /* Read 64 bytes from a hardware RNG and return the number of bytes
+-   actually read.  However hardware source is let account only
+-   for up to 50% (or 25% for RDRAND) of the requested bytes.  */
++   actually read.  */
+ size_t
+ _gcry_rndhw_poll_slow (void (*add)(const void*, size_t, enum random_origins),
+-                       enum random_origins origin, size_t req_length)
++                       enum random_origins origin)
+ {
+   size_t nbytes = 0;
+ 
+   (void)add;
+   (void)origin;
+ 
+-  req_length /= 2; /* Up to 50%. */
+-
+ #ifdef USE_DRNG
+   if ((_gcry_get_hw_features () & HWF_INTEL_RDRAND))
+-    {
+-      req_length /= 2; /* Up to 25%. */
+-      nbytes += poll_drng (add, origin, 0);
+-    }
++    nbytes += poll_drng (add, origin, 0);
+ #endif
+ #ifdef USE_PADLOCK
+   if ((_gcry_get_hw_features () & HWF_PADLOCK_RNG))
+     nbytes += poll_padlock (add, origin, 0);
+ #endif
+ 
+-  if (nbytes > req_length)
+-    nbytes = req_length;
+-
+   return nbytes;
+ }
+diff --git a/random/rndlinux.c b/random/rndlinux.c
+index a22db177..f378a549 100644
+--- a/random/rndlinux.c
++++ b/random/rndlinux.c
+@@ -190,10 +190,19 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t,
+     }
+ 
+ 
+-  /* First read from a hardware source.  Note that _gcry_rndhw_poll_slow lets
+-     it account only for up to 50% (or 25% for RDRAND) of the requested
+-     bytes.  */
+-  n_hw = _gcry_rndhw_poll_slow (add, origin, length);
++  /* First read from a hardware source.  However let it account only
++     for up to 50% (or 25% for RDRAND) of the requested bytes.  */
++  n_hw = _gcry_rndhw_poll_slow (add, origin);
++  if ((_gcry_get_hw_features () & HWF_INTEL_RDRAND))
++    {
++      if (n_hw > length/4)
++        n_hw = length/4;
++    }
++  else
++    {
++      if (n_hw > length/2)
++        n_hw = length/2;
++    }
+   if (length > 1)
+     length -= n_hw;
+ 
+diff --git a/src/g10lib.h b/src/g10lib.h
+index 243997eb..cba2e237 100644
+--- a/src/g10lib.h
++++ b/src/g10lib.h
+@@ -217,8 +217,6 @@ char **_gcry_strtokenize (const char *string, const char *delim);
+ 
+ 
+ /*-- src/hwfeatures.c --*/
+-#if defined(HAVE_CPU_ARCH_X86)
+-
+ #define HWF_PADLOCK_RNG         (1 << 0)
+ #define HWF_PADLOCK_AES         (1 << 1)
+ #define HWF_PADLOCK_SHA         (1 << 2)
+@@ -238,28 +236,20 @@ char **_gcry_strtokenize (const char *string, const char *delim);
+ #define HWF_INTEL_RDTSC         (1 << 15)
+ #define HWF_INTEL_SHAEXT        (1 << 16)
+ 
+-#elif defined(HAVE_CPU_ARCH_ARM)
+-
+-#define HWF_ARM_NEON            (1 << 0)
+-#define HWF_ARM_AES             (1 << 1)
+-#define HWF_ARM_SHA1            (1 << 2)
+-#define HWF_ARM_SHA2            (1 << 3)
+-#define HWF_ARM_PMULL           (1 << 4)
+-
+-#elif defined(HAVE_CPU_ARCH_PPC)
++#define HWF_ARM_NEON            (1 << 17)
++#define HWF_ARM_AES             (1 << 18)
++#define HWF_ARM_SHA1            (1 << 19)
++#define HWF_ARM_SHA2            (1 << 20)
++#define HWF_ARM_PMULL           (1 << 21)
+ 
+-#define HWF_PPC_VCRYPTO         (1 << 0)
+-#define HWF_PPC_ARCH_3_00       (1 << 1)
+-#define HWF_PPC_ARCH_2_07       (1 << 2)
++#define HWF_PPC_VCRYPTO         (1 << 22)
++#define HWF_PPC_ARCH_3_00       (1 << 23)
++#define HWF_PPC_ARCH_2_07       (1 << 24)
+ 
+-#elif defined(HAVE_CPU_ARCH_S390X)
+-
+-#define HWF_S390X_MSA           (1 << 0)
+-#define HWF_S390X_MSA_4         (1 << 1)
+-#define HWF_S390X_MSA_8         (1 << 2)
+-#define HWF_S390X_VX            (1 << 3)
+-
+-#endif
++#define HWF_S390X_MSA           (1 << 25)
++#define HWF_S390X_MSA_4         (1 << 26)
++#define HWF_S390X_MSA_8         (1 << 27)
++#define HWF_S390X_VX            (1 << 28)
+ 
+ gpg_err_code_t _gcry_disable_hw_feature (const char *name);
+ void _gcry_detect_hw_features (void);

diff --git a/dev-libs/libgcrypt/libgcrypt-1.9.1.ebuild b/dev-libs/libgcrypt/libgcrypt-1.9.1-r1.ebuild
similarity index 98%
rename from dev-libs/libgcrypt/libgcrypt-1.9.1.ebuild
rename to dev-libs/libgcrypt/libgcrypt-1.9.1-r1.ebuild
index a40209631d4..952a5816824 100644
--- a/dev-libs/libgcrypt/libgcrypt-1.9.1.ebuild
+++ b/dev-libs/libgcrypt/libgcrypt-1.9.1-r1.ebuild
@@ -21,6 +21,7 @@ BDEPEND="doc? ( virtual/texi2dvi )"
 PATCHES=(
 	"${FILESDIR}"/${PN}-1.6.1-uscore.patch
 	"${FILESDIR}"/${PN}-multilib-syspath.patch
+	"${FILESDIR}"/${PN}-1.9.1-fix-no-asm-on-amd64-x86.patch
 )
 
 MULTILIB_CHOST_TOOLS=(